40

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'}

enter image description here

6

22 Answers 22

38

Finally I fixed it.

  • Change org.gradle.jvmargs=-Xmx1536m to org.gradle.jvmargs=-Xmx1536m -Duser.country=US -Duser.language=en

  • Change classpath 'com.android.tools.build:gradle:3.5.0' to classpath 'com.android.tools.build:gradle:3.4.2'


Android Studio - How to fix Internal error when trying to read zip file

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you man, org.gradle.jvmargs=-Xmx1536m -Duser.country=US -Duser.language=en worked for me
I change for my part classpath 'com.android.tools.build:gradle:3.5.3' to classpath 'com.android.tools.build:gradle:3.5.2'
13

Simply degrade the version from

classpath 'com.android.tools.build:gradle:3.5.0'

to

classpath 'com.android.tools.build:gradle:3.4.2'

then no need to change anything,

You can try Invalidate Caches/Restart if not working.

2 Comments

Had to downgrade from Gradle version 4.0.0 to 3.4.2 while building with Ionic. Do you by any chance know why this solution works?
Downgrading from 4.0.1 to 3.4.2 was the only solution that worked for me. Thanks!
5

This worked:

gradle.properties.org.gradle.jvmargs=-xmx4608m

1 Comment

Earlier, invalidate cache and restart worked for me but the problem surfaced again. Then gradle.properties.org.gradle.jvmargs=-xmx4608m worked.
3

It worked.Use these commands on VSCode.

  1. flutter clean
  2. flutter pub cache repair

Comments

2

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)

1 Comment

I modified my gradle.properties file with the following line to solve OutOfMemroyError exception while running an Android build. My understanding is that this is double the default memory settings, and that increasing the Xmx value will give better results vs the XX:MaxPermSize parameter. If you need more, just increase the Xmx parameter. org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m
2

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.

Comments

2

Run Flutter Clean, then restart your machine.

That did it for me.

Comments

2

For those who are scared of degrading gradle or so, recommend doing it because that resolved the issue for me. Dowgraded from:

classpath 'com.android.tools.build:gradle:4.0.3'

to:

classpath 'com.android.tools.build:gradle:4.0.0'

Comments

2

I got the same error. This solved mine.

  1. Change 'com.android.tools.build:gradle:3.5.0' to 'com.android.tools.build:gradle:4.1.3'
  2. File -->> Invalid caches/Restart
  3. pubspec.yaml -->> pub upgrade
  4. Change dependencies version to latest
  5. Pub get
  6. flutter run

Comments

2

For FLutter, make sure you added android/key.properties

storeFile=/Users/umerwaqas/Downloads/keystore/THREADS AI.jks
storePassword=123456
keyAlias=userapp
keyPassword=123456

enter image description here

Comments

1

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.

Comments

1

Had same issue, proposed solutions did't work for me. In my case problem was caused by signing config: I did set storePassword field, but didn't set keyPassword field in my signingConfigs section (passwords were same). So if you have your signing config in app's build.gradle file, try to set Key Password field in File -> Project Structure -> Modules dialogue or by adding keyPassword field in your signingConfigs section in build.gradle:

android {
    signingConfigs {
        release {
            storeFile file('C:\\PathToKey\\key.jks')
            storePassword 'myPassword'
            keyAlias 'myAlias'
            keyPassword 'myPassword'
        }
    }
    ...
}

1 Comment

For some reason, the way I had it set up to pull the keyPassword from a file stopped working. I'd have NEVER thought to investigate that based on this extremely weird error, thanks so much!
1

I'm using Android Studio 4.0.0 and everything is fine until suddenly I got this error when clean and rebuild project. I don't know why. I tried many solution suggested but no luck. Finally I try to uninstall Android Studio 4.0.1 and this error is GONE and enable to run in emulator like before

Comments

1

In my case problem arose due to gradle version upgradation from 6.2 all to 6.6 all in gradle wrapper. So i wiped data of avd and restarted it and then deleted .gradle folder in android/.gradle and then run yarn start --reset-cache and yarn android. Then it worked for me

Comments

1

Adding this line to gradle.properties.

org.gradle.jvmargs=-Xmx4608m

1 Comment

Can you give an explanation for why this worked for you?
1

I had the same issue and I upgrade the compiled SDK version and IT worked fine.

Comments

0

Check if your APK is locked by external tool (or even IDE)

(...)\app\release\app-release.apk

Comments

0

In my case i was mentioned android:src = "@drawable/screen" in launch_background.xml file.

but, could not added image in drawable folder. Putting image screen.jpg in drawable folder fixed my issue.

enter image description here

1 Comment

This pointed me in the right direction, I had typo in my launch_screen.xml, thanks a lot!
-1

In my case I solved the problem

  1. uninstalling my antivirus which was fishy (downloaded from chrome).

"ionic cordova build android" command started working again

Comments

-2

well the thing i do was simply restarting my computer. It works for a lot of these kind of rubbish errors android studio raises.

Comments

-2

player - publishing setting- build under - custom main manifest deselect build again

Comments

-3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.