Qt Android app error: com.android.builder.dexing.DexArchiveMergerException - android

So I am having this strange error when I try to compile my Qt application for Android. My build.gradle is practically (except for package name) the same as this one here https://github.com/Larpon/QtFirebaseExample/blob/master/App/platforms/android/build.gradle. When I try to compile however I get a long list of errors beginning with:
What went wrong: Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForDebug'.
BUILD FAILED in 8s 21 actionable tasks: 8 executed, 13 up-to-date com.android.builder.dexing.DexArchiveMergerException: Error while
merging dex archives:
I have read similar threads on here which suggest enabling multiDexEnabled = true, I have already tried and also tried to clean my app but it doesn't work. I have also tried to add implementation 'com.android.support:multidex:1.0.3' in the dependencies section of my build.gradle but no luck. Finally I have also set but nothing works.
defaultConfig {
applicationId "packagename" // Used by Firebase auto-config (the google-services.json from Firebase console)
minSdkVersion 23
targetSdkVersion 28
//versionCode 1
//versionName "1.0"
//testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
// Enabling multidex support.
multiDexEnabled = true
}

So I was able to fix the problem by migrating to AndroidX as noted here https://developer.android.com/jetpack/androidx/migrate. After modifying the necessary files the compilation error disappeared.

Related

Build Release: Version code not found in manifest

I generated a project using React-Native and followed the official RN guide to publish to Play Store.
When I get to the buildRelease step. This outputs the following error:
Execution failed for task ':java:packageReleaseBundle'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Version code not found in manifest.
When I use assembleRelease however, the build creates an apk without any issues. What am I missing?
The default config under app/build.gradle is configured as such:
defaultConfig {
applicationId "com.company.appname"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0.0"
missingDimensionStrategy 'react-native-camera', 'general'
}
In my case, i had to disable enableSeparateBuildPerCPUArchitecture
def enableSeparateBuildPerCPUArchitecture = false

Execution failed for task ':app:mergeDebugResources'. [string/com.crashlytics.android.build_id] Error: Duplicate resources

I was trying to add Firebase Crashlytics to my app and I followed this tutorial. When I ran the app, I am getting the following duplication runtime exception.
Execution failed for task ':app:mergeDebugResources'.
> [string/com.crashlytics.android.build_id] /home/chinkysight/Desktop/Pecha/build/app/generated/fabric/res/debug/values/com_crashlytics_build_id.xml [string/com.crashlytics.android.build_id] /home/chinkysight/Desktop/Pecha/build/app/generated/crashlytics/res/debug/values/com_crashlytics_build_id.xml: Error: Duplicate resources
Try to delete your build folder in app/build. And then try a clean build
Might be you have not enabled multidex,
Please go to app/build.gradle, if it is not enabled then enable it and restart the app again.
here is how you can do that:
Goto ->
/android/app/build.gradle and add
multidrxEnabled true
In defaultConfig
It should look like this:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.chat_app_flutter_firebase"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
//Enable multidex by adding this line
multiDexEnabled true
}

android studio 3.0.1 showing unable to merge dex why?

I upgraded the android studio 2.x.x to android studio 3.0.1 after importing the project gradle building is successful. But when installing app showing the error message
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
my app grdle is given below
Why it's showing this error and how to fix it? unable to install the app on the emulator.
Already tried the clean and rebuild option in android studio but it doesn't fix the issue
Try with the following
If your minSdkVersion is set to 21 or higher
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
...
}
if your minSdkVersion is set to 20 or lower,
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
If this does not resolve, try through these posts post 1 , android_dev or post 2
To remove this Dex issue just implement one dependency.
This issue occur when we are using multiple different service from the same server. Suppose we are using ads and Firestore in a project and both have a repository maven. so we need to call different data with on repository we need dex dependency to implement.
The new update Dependency:-
implementation 'com.android.support:multidex:1.0.3'
or use testCompile inside compile such as :
implementation 'com.google.android.gms:play-services-ads:15.0.1'
testCompile 'com.google.firebase:firebase-firestore:17.0.1'
and also make multiDexEnabled true;
100 % it will work !

My build is ok but d APK It fails.over 64k, I tried google's site to fix the 2 errors although I just get more errors

Hello I get the 2 errors when trying to generate a signed APK. Although when I build the project it has O errors.
I have gone to the links tried to make the modifications but it comes up with more errors
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
Configure your app for multidex
Setting up your app project to use a multidex configuration requires that you make the following modifications to your app project, depending on the minimum Android version your app supports.
If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 25
multiDexEnabled true
}
...
}
However, if your minSdkVersion is set to 20 or lower, then you must use the multidex support library as follows:
Modify the module-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 25
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
This is the point I though I should put it in my code. I looked around and tried a couple more locations although I keep getting errors.
android {
compileSdkVersion 25
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.adventure.game"
minSdkVersion 10
targetSdkVersion 25
versionName '1'
versionNameSuffix '1.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
If anyone can help, that would be great.
Thanks in advance.
I had the 64k error in one of my apps, and the solution was not to use the multidex.
My problem was that I was importing all the google services with this line in my dependencies: compile 'com.google.android.gms:play-services:10.0.1'. Google brought 64k classes to my app, so I removed this compile line and imported only the services I needed (the location service).
You can find the complete list here.
And this worked for me.
I hope this will help you.

Unable to build apk

I am working on current location tracking but when I am trying to build apk it is showing ERRORS WHILE BUILDING APK.I am not getting the problem.
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_101\bin\java.exe'' finished with non-zero exit value 2
In your build.gradle add this line and try again:
multiDexEnabled true
Have you tried adding the heap size adjustment to your build.gradle file? For example this will set the max heap size for dexing to 4GB, and it will also enable
multiDexEnabled option.
android {
...
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
multiDexEnabled true
}
}
hi we have 2 ways to handle multidex,
first way we should add this snippet of code in gradle
defaultConfig {
applicationId "com.example"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
Second way we can use this code in our Application class,
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
thanks it may be helpful for you
There can be 2 solutions for your problem :
1. As you are developing location tracking app you might have included the whole google play services that includes several libraries.Better you try to include on maps services in you gradle file like
compile 'com.google.android.gms:play-services-maps:8.3.0'
If the above approach doesn't works try to Modify the module-level build.gradle file configuration to include the support library and enable multidex output, as shown in the following code
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Some of the dependencies's methods cross the 64k limit. Hence you have to introduced a support called as "MULTIDEX SUPPORT".
http://frogermcs.github.io/MultiDex-solution-for-64k-limit-in-Dalvik/
Multidex will allow to have any number of methods in an app (along with its associated third party libraries).
Even though lollipop and above version's do support the app to have any number of methods, pre-lollipop versions support only SINGLE DEX. Due to this, multidex has to be installed(REQUIRED) at the time of app installation. This way, your app can run even on pre-lollipop versions.
Android Studio project works on Lollipop but does not work on Kitkat
This will slow down your app a little bit as multidex will try to extract all the resources from dex files but once this process is done whenever you will open your app it will work fine.
In addition it won't give you any problem after you create a signed apk.

Categories

Resources