Worramet Chairungruang
Worramet Chairungruang

Reputation: 743

How to fix this error "A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade"

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

Upvotes: 37

Views: 196349

Answers (22)

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

Upvotes: 1

Liza
Liza

Reputation: 33

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

Upvotes: 1

emrettc
emrettc

Reputation: 1

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

Upvotes: -2

alper yolcu
alper yolcu

Reputation: 49

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

Upvotes: -2

GeekyChick
GeekyChick

Reputation: 37

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

Upvotes: 2

Kingsley Mitchell
Kingsley Mitchell

Reputation: 2589

Adding this line to gradle.properties.

org.gradle.jvmargs=-Xmx4608m

Upvotes: 1

Avkro
Avkro

Reputation: 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

Upvotes: -1

SenyaOhar
SenyaOhar

Reputation: 111

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'

Upvotes: 2

Robert
Robert

Reputation: 21

Run Flutter Clean, then restart your machine.

That did it for me.

Upvotes: 2

srinivasa rao pedada
srinivasa rao pedada

Reputation: 164

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

Upvotes: 1

Lahardi Alkawero
Lahardi Alkawero

Reputation: 341

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

Upvotes: 1

Nafees
Nafees

Reputation: 1034

It worked.Use these commands on VSCode.

  1. flutter clean
  2. flutter pub cache repair

Upvotes: 3

the korovay
the korovay

Reputation: 655

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

Upvotes: 1

silexcorp
silexcorp

Reputation: 1261

This worked:

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

Upvotes: 4

Worramet Chairungruang
Worramet Chairungruang

Reputation: 743

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

Upvotes: 37

Sumit Singh
Sumit Singh

Reputation: 1268

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.

Upvotes: 13

Avijit Nagare
Avijit Nagare

Reputation: 8802

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

Upvotes: 0

PearlByte
PearlByte

Reputation: 69

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.

Upvotes: 2

kevoroid
kevoroid

Reputation: 5302

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)

Upvotes: 2

Grzesl
Grzesl

Reputation: 64

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

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

Upvotes: 0

Pankaj
Pankaj

Reputation: 29

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.

Upvotes: 1

Worramet Chairungruang
Worramet Chairungruang

Reputation: 743

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

Upvotes: -3

Related Questions