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.
Related
I get this error when I try to run react-native run-android.
This is the full error message:
A problem occurred configuring project ':#react-native-async-storage_async-storage'.
com.android.builder.errors.EvalIssueException: defaultConfig contains custom BuildConfig fields, but the feature is disabled.
To enable the feature, add the following to your module-level build.gradle:
android.buildFeatures.buildConfig true
I've found these solutions to similar errors: this, this, this and this but, the problem still remains.
In other words,
I updated my java version to 15 (I tried also 19).
I tried different Gradle Versions (mainly of 8+).
I installed npm i jetifier.
I added android.buildFeatures.buildConfig true in android/app/build.gradle (ChatGPT suggestion).
There is also a suggestion to the issue I've opened here
I updated Android Studio
Additional notes:
The app is uploaded in Play Store and the last time I worked on it, was three months ago. So I guess I have to update something.
I used to have the community package #react-native-community/async-storage, which is deprecated, so I replaced it with this one: #react-native-async-storage/async-storage.
I had to integrate a library into my app and the library had its gradle version as 4.0.0, while my app had 3.2.2 (or something). So it bumped into the queries tag in the library (in its Manifest) that it wouldn’t recognize. Therefore I have updated the gradle version in my app to be the same as the library, at 4.0.0 (now I put it as 4.1.0, the latest).
The problem is that I bump into the following error:
`Execution failed for task ‘:app:processCanaryDebugManifest’.
Could not get unknown property ‘manifestOutputDirectory’ for task ‘:app:processCanaryDebugManifest’ of type com.android.build.gradle.tasks.ProcessMultiApkApplicationManifest.
This is based on this warning:
API 'variantOutput.getProcessManifest()' is obsolete and has been replaced with 'variantOutput.getProcessManifestProvider()'.
I haven’t been able to make any progress on this. I have ran the gradlew command with --stacktrace but all I get are errors from gradle, nothing specific. Do you know of any way to make this work? The only things I've found so far are issues with a Huawei thing, but it's not the case for me. Thanks!
PS. I'm not sure what additional info would be useful in this circumstance.
EDIT: I've downgraded to gradle 3.3.3 and commented out my new library dependecies, and now it says:
`Execution failed for task ':app:processCanaryDebugManifest'.
java.io.FileNotFoundException: property(interface org.gradle.api.file.Directory, transform(property(interface org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultProjectLayout$FixedDirectory, C:\build\myapp\app))))\AndroidManifest.xml (The filename, directory name, or volume label syntax is incorrect)`
Gradle version: 4.4
Android Plugin Version: 3.1.2
Hi.
I'm working on an Android which should be deploy by using a Mobile Device Management called AirWatch.
So since Android Gradle Plugin 3.0.0, even if I update application version code and version name, the MDM thinks that the last deployed version and the current one are the same.
Using dump badging command, I see that the platformBuildVersionName is empty. So when I disable aapt2 from my gradle properties file, platformBuildVersionName is filled. which allow me to deploy on the MDM. The problem is not up to date we don't when they will. So this is the work around I found. I know that the option 'android.enableAapt2' is deprecated and should not be used anymore.
My question is what's the meaning "It will be removed at the end of 2018"? Is that mean, at the end of 2018, my app will not compile anymore?
Thanks
The issue with platformBuildVersionName missing has been fixed recently in AAPT2.
AAPT2 it is now released it in GMaven for faster releases (so you need to have the google() dependency in your build.gradle file), so please try with android gradle plugin 3.2.0 alpha16 or newer which may already contain it. If that still doesn't work, keep an eye out for new versions, it should be released shortly (if it hasn't been yet).
As for the information about AAPT1 deprecation - it means that at some point in the near future, near the end of 2018, there will be a release of Android Gradle Plugin that removes the android.enableAapt2=false flag. AAPT1 will be completely removed then so the hacks with disabling AAPT2 won't work anymore. If you run into any other issues with AAPT2 please file them on issue tracker, so that the team can fix them before everyone will need to move away from AAPT1.
In 2019 New update
From Gradle.properties remove
android.enableAapt2=false this line
it will work now.
1.Projenin gradle.properties:
android.enableAapt2=false
2.File-> settings-Build, Execution > Instant run
unselected all options and rebuild projects
I've got this problem and I tried all the solutions available here an over the internet, but non of them worked for me. Adding multiDexEnabled true, adding multidex in gradle and extending my application from MultiDexApplication and ...
So please dont mark it duplicated, maybe someone could help. Thanks.
This is the stacktrace log:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\0.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\1.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\2.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\3.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\4.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\5.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\6.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\7.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\8.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\9.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\10.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\11.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\12.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\13.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\14.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\15.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\16.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\17.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\18.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\19.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\20.jar,
D:\AndroidStudioProjects\ChatterDevs\app\build\intermediates\transforms\dexBuilder\debug\21.jar
I've figured it out. I had some external dependencies that were also imported internally (with different versions). Removing duplicated imports fixed the issue for me. Hope this help someone.
This error happens when you add an external library which may not be compatible with your compileSdkVersion .
Be careful when you are adding an external library.
Make sure all your support libraries are same as compileSdkVersion of your build.gradle(Module:app) in my case it is 26.
In your defaultConfig category type multiDexEnabled true. This is the important part. multiDexEnabled True
Go to File | Settings | Build, Execution, Deployment | Instant Run and try to Enable/Disable Instant Run to hot swap... and click okay Enable Instant Run to Hot swap...
Sync Your project.
Lastly, Go to Build | click on Rebuild Project.
Note: Rebuild Project first cleans and then builds the project.
I'm transitioning over from Eclipse to Android Studio and I find that I'm still confused about the different components of Android Studio regarding detecting errors. I have a project with about 20 Java files and 30 XML files. I recently ran a clean and build and got
Gradle build finished with 5 error(s) in 13s 397 ms
Two XML files were indicated and in both of them there was whitespace in front of the first element with an error saying ...
Xml declaration should precede all document content
So I fixed those and ran the build again with no errors.
I then ran Lint and found 8 more XML files with errors (NB, errors, not warning) saying "Element selector doesn't have required attribute:layout_height ". This error was apparently due to these files being in a layout folder instead of a drawable folder, although why that didn't cause problems in Eclipse is unclear.
My Questions:
Why does Gradle Build only detect some errors, but other have
to be found via lint?
What categories of errors will be found via Gradle Build?
How hard is it to add something to the Gradle Build script to find
all errors?
Edit: actually this is also true for regular Java files - I'll get "0 errors" in the Gradle build and then I'll step into a source file in the debugger and see 4 errors from Lint.
Why does Gradle Build only detect some errors, but other have to be
found via lint?
Lint errors are not compile errors, but code issues, and by default AndroidStudio will not check those. (Same goes for standard javac).
What categories of errors will be found via Gradle Build?
Gradle will detect all compile time errors, annotation processing, packaging errors, dex, signing, incorectly defined xml, incorrect file naming, etc.
How hard is it to add something to the Gradle Build script to find all errors?
Surprisingly easy in fact, source
To enable lint checks when compiling add in your application level build.gradle
android {
lintOptions {
// set to true to turn off analysis progress reporting by lint
quiet false
// if true, stop the gradle build if errors are found
abortOnError true
// if true, only report errors
ignoreWarnings false
}
...
}
If this will not work for U, add lint after each make, to do this you can follow this answer
I will add that this config will detect all enabled inspections with severity warning and error under:
File > Other Settings > Default Settings > Editor > Inspections
Android Studio will run code inspections checks live so all lint warnigns / errors are displayed in code while editing, lint errors are marked with red underscore, and warnings by marking code fragment with yellow background. Even if lint errors are marked the same as compile time errors they will not stop build by default.