I am getting this error while I am building APK.
Cause 1: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
at org.gradle.workers.internal.DefaultWorkerExecutor$WorkerExecution.waitForCompletion(DefaultWorkerExecutor.java:285)
at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:115)
at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForCompletion(DefaultAsyncWorkTracker.java:87)
at org.gradle.workers.internal.DefaultWorkerExecutor.await(DefaultWorkerExecutor.java:150)
at com.android.build.gradle.internal.tasks.Workers$WorkerExecutorAdapter.await(Workers.kt:282)
at com.android.ide.common.resources.MergeWriter.end(MergeWriter.java:48)
at com.android.ide.common.resources.MergedResourceWriter.end(MergedResourceWriter.java:242)
at com.android.ide.common.resources.DataMerger.mergeData(DataMerger.java:292)
at com.android.ide.common.resources.ResourceMerger.mergeData(ResourceMerger.java:384)
at com.android.build.gradle.tasks.MergeResources.lambda$doFullTaskAction$1(MergeResources.java:261)
at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:58)
Tried to invalidate cache and restart android studio.Rebuild project but none of them works for me.
Finally found a solution for this by adding this line to gradle.properties.
org.gradle.jvmargs=-Xmx4608m
Try this, in Android Studio
File > Invalidate Caches/Restart...
I already had multidex enabled but the version was too old so upgraded and it fixed the issue:
// Old version
implementation "com.android.support:multidex:1.0.3"
// New version
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
In my case, I enabled multidex
Open [project_folder]/app/build.gradle and add following lines.
defaultConfig {
...
multiDexEnabled true
}
and
dependencies {
...
implementation 'com.android.support:multidex:2.0.1'
}
I removed this issue by adding the following lines
add multiDexEnabled true in android>app>build.gradle inside defaultConfig
add implementation 'com.android.support:multidex:1.0.3' in android>app>build.gradle inside dependencies
Encountered Similar issue... the fix for me was changing/updating the gradle version
classpath "com.android.tools.build:gradle:4.1.2"
to
classpath "com.android.tools.build:gradle:4.1.3"
worked for me
gradle.proprites
org.gradle.jvmargs=-Xmx1536M
build.gradle
defaultConfig {
multiDexEnabled true
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
and yet theses stuff did not fix my problem, until I increase the compileSdkVersion from 27 to 28, it worked for me.
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
crunchPngs false
}
}
}
I got an stacktrace similar to yours only when building to Lollipop or Marshmallow, and the solution was to disable Advanved profiling.
Find it here:
Run -> Edit Configurations -> Profiling -> Enable advanced profiling
https://stackoverflow.com/a/58029739/860488
search your code you must be referring to color in color.xml in an xml drawable.
go and give hex code instead of referencing....
Example:
in drawable.xml you must have called
android:fillColor="#color/blue"
change it to android:fillColor="#ffaacc"
hope it solve your problem...
please check if current icons are not on debug folder if so move them to main folder or recreate them
I also have the same issue , and you can add this
org.gradle.jvmargs=-Xmx4608m on your Gradle.properties
but in my case I change like this :
from :
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
to:
org.gradle.jvmargs=-Xmx4608m -Dfile.encoding=UTF-8
classpath 'com.android.tools.build:gradle:3.3.2'
Change the class path and it will work.
Solution for:
Caused by 4: com.android.builder.internal.aapt.AaptException: Dependent features configured but no package ID was set.
All feature modules have to apply the library plugin and NOT the application plugin.
build.gradle (:androidApp:feature_A)
apply plugin: 'com.android.library'
It all depends on the stacktrace of each one. Cause 1 WorkExecutionException may be the consequence of other causes. So I suggest reading the full stacktrace from the last cause printed towards the first cause. So if we solve the last cause, it is very likely that we will have fixed the chain of causes from the last to the first.
I attach an example of my stacktrace where the original or concrete problem was in the last cause:
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
Caused by: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-4.2.0-alpha16-6840111-linux Daemon #0: Unexpected error during link, attempting to stop daemon.
Caused by: java.io.IOException: Unable to make AAPT link command.
Caused by 4: com.android.builder.internal.aapt.AaptException: Dependent features configured but no package ID was set.
GL
Feature Package ID was not set
in my code i am using latest version of flutter and packages
and remove this error by adding the line in
multiDexEnabled true
in app level build.gradle
In right side of android studio
click gradle -> app -> build -> assemble.
then android studio will start building, and print you a proper message of the issue.
Working on android studio: 3.6.3 and gradle version:
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
Adding this line in
gradle.properties file
org.gradle.jvmargs=-Xmx512m
just add
android.enableJetifier=true
to the gradle.properties .
actually this happens mostly when you mess up with androidx and support libraries, some dependencies are currently not fully supporting androidX. so you have to enable jetfier.
I update this and worked for me in gradle wrapper properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
This fixed my issue.
cd android && ./gradlew clean
found the solution.
add this code to your build.gradle,
dependencies {
def multidex_version = "2.0.1"
implementation 'androidx.multidex:multidex:$multidex_version'
}
then enable the multidex to true
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
If you've tried all the solutions above and still doesn't resolve your issue.
This might not seemed related, but here's my take on it.
Try removing this from your Gradle dependency, I've spend 2 hours of my time because of this roadblock.
implementation "com.squareup.retrofit2:adapter-rxjava2:2.3.0"
I got this problem when I directly downloaded code files from GitHub but it was showing this error, but my colleague told me to use "Git bash here" and use the command to Gitclone it. After doing so it works fine.
In my case the issue was related to View Binding. It couldn't generate binding classes due to an invalid xml layout file. In the file I had a Switch with an id switch, which is a Java keyword. Renaming the Switch id resolved the issue.
How To Solve A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade Error?
To Solve A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade Error Just open your app/build.gradle file and change this line. androidx.core:core-ktx:+ replace with androidx.core:core-ktx:1.6.0 Here is an Example. If you are using androidx.core:core-ktx:+ then this will find the latest version of androidx.core:core-ktx:+ and the latest one is 1.7.0 and the latest version needs the Android 31 compile SDK. So that You are facing this issue. Here is Two Possible Solution use a specific version, use androidx.core:core-ktx:${version} instead of androidx.core:core-ktx:+ upgrade the compile SDK to Android 31
full article is Here
If any one having this issue in flutter after adding firebase storage. Do flutter clean and re run it, it will work
if you are stuck in this error below
Execution failed for task ':app:signReleaseBundle'. > A failure occurred while
executing com.android.build.gradle.internal.tasks.Workers$ActionFacade > 'other'
has different root
**then do it change the location your the .abb in time of generating to your
project(own project of this .aab) then go to app and then select the realese
folder to save your .aab **
try to add this to your gradle.properties
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
You may get an error like this when trying to build an app that uses a VectorDrawable for an Adaptive Icon. And your XML file contains "android:fillColor" with a <gradient> block:
res/drawable/icon_with_gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="96dp"
android:height="96dp"
android:viewportHeight="100"
android:viewportWidth="100">
<path
android:pathData="M1,1 H99 V99 H1Z"
android:strokeColor="?android:attr/colorAccent"
android:strokeWidth="2">
<aapt:attr name="android:fillColor">
<gradient
android:endColor="#156a12"
android:endX="50"
android:endY="99"
android:startColor="#1e9618"
android:startX="50"
android:startY="1"
android:type="linear" />
</aapt:attr>
</path>
</vector>
Gradient fill colors are commonly used in Adaptive Icons, such as in the tutorials here, here and here.
Even though the layout preview works fine, when you build the app, you will see an error like this:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Error while processing Project/app/src/main/res/drawable/icon_with_gradient.xml : null
(More info shown when the gradle build is run with --stack-trace flag):
Caused by: java.lang.NullPointerException
at com.android.ide.common.vectordrawable.VdPath.addGradientIfExists(VdPath.java:614)
at com.android.ide.common.vectordrawable.VdTree.parseTree(VdTree.java:149)
at com.android.ide.common.vectordrawable.VdTree.parse(VdTree.java:129)
at com.android.ide.common.vectordrawable.VdParser.parse(VdParser.java:39)
at com.android.ide.common.vectordrawable.VdPreview.getPreviewFromVectorXml(VdPreview.java:197)
at com.android.builder.png.VectorDrawableRenderer.generateFile(VectorDrawableRenderer.java:224)
at com.android.build.gradle.tasks.MergeResources$MergeResourcesVectorDrawableRenderer.generateFile(MergeResources.java:413)
at com.android.ide.common.resources.MergedResourceWriter$FileGenerationWorkAction.run(MergedResourceWriter.java:409)
The solution is to move the file icon_with_gradient.xml to drawable-v24/icon_with_gradient.xml or drawable-v26/icon_with_gradient.xml. It's because gradient fills are only supported in API 24 (Android 7) and above. More info here: VectorDrawable: Invalid drawable tag gradient
I know this might not be a complete or exact solution, but for those who are still facing issues even after doing what is given on this thread, check for your files in value folder. For me there was a typo and some missing values. Once i fixed them this error stopped.
If you getting this error saying signing-config.json (Access denied) means just exit the android studio and just go to the desktop home and click on the android studio icon and give Run as Administrator, this will sort out the problem (or) you can delete the signing-config.json and re-run the program :)
I'm trying to build a release app via Android Studio > Generate Signed Bundle or APK > Android App Bundle > Release
However gradle fails with
: > Task :core:transformClassesWithMergeClassesForRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core:transformClassesWithMergeClassesForRelease'.
> 1 exception was raised by workers:
java.util.zip.ZipException: duplicate entry: META-INF/app_release.kotlin_module
In my build.gradle I've tried adding:
packagingOptions {
exclude 'META-INF/app_release.kotlin_module'
}
But it isn't making any difference whatsoever.
How do I fix this?
For extra context, it's a multi module project.
I have a core module, and an installed module which is declared in the core build.gradle with dynamicFeatures = [":installed"]
Thanks
Please make sure all your dependencies are api or implementation,
I have the flowing dependency grap.
meemo_sdk:
api project(":gvoice")
app project:
implementation project(":gvoice")
implementation project("meemo_sdk")
It complains "META-INF/gvoice_debug.kotlin_module" collision.
After change api to implementation, it works!
So I figured it out.
I pressed shift twice in Android studio (to open up the search everywhere dialog) and searched for app_release.kotlin_module
I saw two files, that were under two of my dependencies (which funnily enough were libraries that I had created!)
I opened up these library projects, and in the build.gradle file I had to add:
ext {
PUBLISH_GROUP_ID = 'com.companyname'
PUBLISH_ARTIFACT_ID = 'packagename'
}
android {
...
compileOptions {
kotlinOptions.freeCompilerArgs += ['-module-name', "$PUBLISH_GROUP_ID.$PUBLISH_ARTIFACT_ID"]
}
}
Rebuilt the library projects with new versions, used these new versions in my other project, and it started compiling :)
Build -> Clean Project Worked for me
I found the same issue comes randomly by using Android Studio 4.2.1 and Java8, I sorted out successfully by deleting .gradle file in the project (not the main one) every time I get the error.
Java version: JDK8221
Kotlin: 1.5.0
AndroidStudio: 4.2.1
Not the best solution but is a good workaround for now.
i am working on a react native android project but i am stuck on this error
> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
D8: Program type already present: androidx.versionedparcelable.NonParcelField
FAILURE: Build failed with an exception.
i have tried to change multi dex to false in build.gradle
defaultconfig {...
multiDexEnabled false
...}
i dont want to migrate to androidx , i just want to get rid of androidx & this error ;
please help me , thanks in advance
Based on my research couldn't not find an easy way or should I say a correct way to draw back from androidx, to solve the above issue just add the following to your gradle.properties
android.useAndroidX=true
android.enableJetifier=true
That might cause another issue like
Execution failed for task
':react-native-navigation:compileReactNative57_5DebugJavaWithJavac'
the reason of this error, if it occured, after migrating your android project to androidx, many of your react-native libraries ship native Java code and have not been updated, updating it manually is tedious, I was able to do so by using this library jetifier simply by running
npm i --save-dev jetifier
npx jetify
In my case there were still some libraries causing some issues such us react-native-fast-image, as a workaround, I created a gradle.properties inside /node_modules/react-native-fast-image/android and deactivated AndroidX and Jetifier for this module:
android.useAndroidX=false
android.enableJetifier=false
The answer that Ahmed posted is a great solution once you've migrated to AndroidX. In my case I found out that only one library in my application was using AndroidX from this thread
In short my solution was to simply yarn upgrade react-native-device-info#latest The app build as expected after rebuilding it
Please follow the following steps:
Open Android Studio
Click on Refactor on the top menu bar
Click on Migrate too AppCompat
I hope this shall help you
I ran into a similar problem: I'm updating an app for RN 0.60.0. In my case, I had a dependency in build.gradle with a '+' in its version, and that particular dependency got updated, which broke my build.
In my case, explicitly specifying the version number resolved my problem.
./gradlew app:dependencies will show a tree of your dependencies; this might point you in the right direction as well.
I'm trying to compile my project using "Build App Bundle (Google Play)" for the first time. However I am getting an error while merging dex archives.
I believe it is due to some of my plugins are using different version of some amazon module
first error printed in the console:
D8: Program type already present: com.amazon.ags.BuildConfig
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
When I search for com.amazon.ags.BuildConfig I find nothing. (But my assumption might be wrong)
I have tried to enable multiDex by adding the mainTemplate.gradle to my project
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
applicationId '**APPLICATIONID**'
multiDexEnabled true
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
}
But I'm still getting the same error, and I have no chance of knowing whether the new gradle file is actually included when building or if unity simply ignores it.
This is the error that pops up when the build fails:
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
C:\Users\path-to-project\unity\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\57,
C:\Users\path-to-project\unity\Temp\gradleOut\build\intermediates\transforms\externalLibsDexMerger\release\0,
C:\Users\path-to-project\unity\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\52.jar,
C:\Users\path-to-project\unity\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\54.jar
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
I see a lot of people lately solving similar error by removing unity ads and/or google ads plugins and re-enable them, I never used google ads, but I have tried to remove unity ads plugin, still no cigar, I have also tried with different version of the unity ads plugin both the one from asset store and the "built in extension" still no dice.
I have been on a discussion with some guys here but I have tried the solutions each one of them have provided without luck.
Any suggestions on how I can find out which plugin is causing this and how to fix it ?
Someone in the thread from unity forum finally posted a working solution. I'm gonna share it here as well so hopefully everyone who lands on the question with this issue will not have to spend 30 hours blindfolded resolving dex merging conflicts like I did.
Turns out that with the newer version of unity there is a few more options in the publish settings that needs to be set!
quoting RealPpTheBest s' answer
Go to player settings > Project Settings > Minify, in there, there
will be an option of Release, set it to Gradle .
For some reason when choosing gradle build these two are not automatically toggled, and maybe in some cases they don't have to be. But setting minify to Gradle (experimental) completely resolved all the build errors I was getting after updating unity.
EDIT: september-2019 - Solution above should still work, but:
I have lately been experimenting with choosing Proguard instead of the experimental Gradle minifier (can be selected in the dorpdown as well). When configured correctly proguard will also resolve your DEX limitation errors, and get rid of unused code and even compress your build size even more.
This post has a quite throughly detailed guide on how to enable and configure it. Keep in mind though, that the configuration will be unique to which dependencies you are using, so you will have to read up and do some custom configuration here most likely.
I also faced this error. what I did is, I changed minimum API level to marshmallow and also I checked development build in build setting. It worked for me.
I made a 9 patch image using Android Studio function "create 9-patch file".
Now android studio tells me that there is a "duplicate" resorces error, since I have image.png and image.9.png.
If deleted image.png (after even cleaning and rebulding the project) I get this error:
Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
Error:Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
Do you know how to solve this problem?
Remove both, then clean, then paste the desired one
First of all, as suggested, try Invalidating Cache. To do this: Click on File > Invalidate Cache / Restart.
If you have a conflicting library in lib folder, try removing it and rebuilding project. To do this, you can manually check lib folder in your project directory. Do you have a jar? Maybe you have multiple versions of same library in lib folder.
Also: you can: click on *File > Project Structure. Select app and see your libraries.
And, if your project is really big so that it exceeded the 65K methods dex limit in Android(typically happens if you used too many libraries). You can add multiDexEnabled to true in your top level build.gradle > defaultConfig
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
Optionally, you can increase heap size
dexOptions{
preDexLibraries = false
javaMaxHeapSize "4g" // 4GB
}