问题
I can't run my app on AVD. I get this error.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
My build.gradle
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}[E][1]}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'}
Error Pic
回答1:
Finally I fixed it.
- Change org.gradle.jvmargs=-Xmx1536m >>> org.gradle.jvmargs=-Xmx1536m -Duser.country=US -Duser.language=en
- Change classpath 'com.android.tools.build:gradle:3.5.0' >>> classpath 'com.android.tools.build:gradle:3.4.2'
Android Studio - How to fix Internal error when trying to read zip file
回答2:
This error can also be arise due any vector asset. I resolve by removing that vector asset file. Please check if you recently made any change to your vector asset file.
回答3:
Try this, in Android Studio
File > Invalidate Caches/Restart...
回答4:
This worked: gradle.properties.org.gradle.jvmargs=-xmx4608m
回答5:
Check if your APK is locked by external tool (or even IDE)
(...)\app\release\app-release.apk
回答6:
Make sure you have enough RAM for gradle process by updating org.gradle.jvmargs in your gradle.properties.
Make sure your Gradle version and gradle plugin are compatible; refer to this table: https://developer.android.com/studio/releases/gradle-plugin#updating-gradle (i suggest plugin 3.5.3 with gradle 5.4.1 as of this writing!)
And what might be happening to some without knowing it, is not using JDK 8! I tried with JDK 11 and saw many different R8 and dexing errors! Also looks like this whole setup does not work with Eclipse OpenJ9 JDK distribution! so make sure you are using standard OpenJDK of your OS (mine would be default OpenJDK-8 from Debian)
回答7:
I had the same issue in my flutter project and it happened suddenly when trying to build/debug. Nothing worked not even "File > Invalidate Caches/Restart..." Finally I did a "flutter clean" and "flutter packages get" and it worked.
回答8:
My build.gradle (Project)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My gradle-wrapper
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
来源:https://stackoverflow.com/questions/58084850/how-to-fix-this-error-a-failure-occurred-while-executing-com-android-build-grad