Multiple Dex File build error following NS 2.5 Upgrade - android

Following the upgrade to Nativescript 2.5 I'm receiving a build error that I'm not quite sure how to fix. The error is:
Execution failed for task ':transformClassesWithDexForF0F1F2F3F4F5F6Debug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files
define Lcom/google/android/gms/iid/MessengerCompat$1;
I've spent some time looking into the issue and a Multiple Dex file exception seems to normally mean that two different versions of a dependency are being referenced. Yet I can't seem to find anything which relates to > MessengerCompat in the gradle files of any of my dependencies.
Thanks for any help!

For your case you could try to remove node_modules, platforms and hooks folders from your project and to clear npm cache with npm cache clear.
Then try to rebuild the app with tns run android.
It would also help if you could share the package.json file of the project.

Related

flutter More than one file was found with OS independent path 'AndroidManifest.xml'

I have a sample flutter project that has multiple lib modules that can build with
./gradlew app:assembleDevRelease
but for some reason when I run
flutter run --release --flavor dev
It is trying to run
./gradlew assembleDevRelease
command that of project level, then I got the error
> Task :track_sdk_plugin:mergeDevReleaseJavaResource FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':track_sdk_plugin:mergeDevReleaseJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> More than one file was found with OS independent path 'AndroidManifest.xml'
Any idea why this is not working? Can provide the gradle file if needed.
In my case, there were more than two AndroidManifest.xml files in one of the modules due to migrating from the old project.
Please search for the AndroidManifest.xml files under your project directory, if you could find there were more than one in src folder, only keep the one in src/main folder.
I had a similar case with the following error message:
More than one file was found with OS independent path 'lib/x86/libswscale.so'.
The problem was that I accidentally had both the following dependencies in my pubspec.yaml:
ffmpeg_kit_flutter_min_gpl: ^4.5.0
ffmpeg_kit_flutter: ^4.5.0-LTS
The top one of course has everything that the below one has and that caused the issue. The below one was unnecessary.

compileReleaseJavaWithJavaC failed for react native modules when building a release build

Task :react-native-device-info:compileReleaseJavaWithJavac FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':react-native-device-info:compileReleaseJavaWithJavac'.
java.io.FileNotFoundException: /workspace/eos-native/node_modules/react-native-device-info/android/build/intermediates/annotation_processor_list/release/annotationProcessors.json (No such file or directory)
The error makes sense , and the file is not there, but I have no idea why its not there? It is created when I run a debug version of the app and debug versions of my libraries, react-native-device-info, react-orientation-locker etc.. I've cleaned, gradle synched, rebuilt etc. but when trying to assemble or install a release build I get this error within seconds. What is causing the Java
I had the same problem in an android project (without react) when I added a library module.
After searching for a solution for quite some time, I finally deleted the .gradle directory in the project root folder.
This solved the problem for me.
update android gradle plugin to 3.3
update gradle to 4.10.3
fixed the issue for me.

Multiple dex files define Lcom/google/android/gms/internal/measurement/zzabn

Since this morning I cannot build my Android app because I get this error
What went wrong: Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define
Lcom/google/android/gms/internal/measurement/zzabn;
I have tried bumping the Firebase versions accordingly to 15.0.2 but then I get an other error...
Task :app:processDebugGoogleServices Found com.google.android.gms:play-services-maps:15.0.0, but version 15.0.2
is needed for the google-services plugin.
com.google.android.gms:play-services-maps:15.0.2 is not even released yet?
I have a build to push to production, what is the best way to build the app?
Please update the google-service plugin to:
classpath 'com.google.gms:google-services:3.3.0'
to be able to use the latest version of Firebase and to avoid the errors.
Read the following for more information:
https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html
Compilation failed to complete:Program type already present: com.google.android.gms.internal.measurement.zzabn
(Posted solution on behalf of the question author).
Removing com.google.gms.google-services at the bottom of my build.build makes it work.

Fail demo:transformDexArchiveWithExternalLibsDexMergerForMockDebug with a DexArchiveMergerException

After a rebuild I get :
Error:Execution failed for task ':demo:transformDexArchiveWithExternalLibsDexMergerForMockDebug'.
> com.android.builder.dexing.DexArchiveMergerException: com.android.tools.r8.errors.CompilationError: Program type already present: com.google.android.gms.common.internal.zzag
What does that error message mean? What is wrong?
when I replaces gradle implementation instruction by (the older) compile , it works.
The suggested workaround for this error is to delete the ./gradle folder inside your project or delete all the build folders and the gradle cache.
Additional references:
Dex error On Android Studio 3.0 Beta4
Unable to merge dex
Delete the .gradle directory.
Run your app again.
Notes
The .gradle directory is in your project's root folder. (You may have to show hidden files first.)
I have to do this every time I update a dependency module using Android 3.0.
Hope this helps!
This error (and any other Program type already present: com.google.android.gms.common.internal.xxxxxx error) can be caused by different Play Services and Firebase versions. Make sure all implementation 'com.google.android.gms:xxxx:12.0.0 and all implementation 'com.google.firebase:xxxxxx:12.0.0' have the same version (12.0.0) in this example.

Error due to same jars in sub-modules

I am building an apk using gradle which have multiple sub-modules. These sub-modules include few same jars. Due to this its giving error during compilation of my apk.
To be more specific, the same jar is 'com.android.support:support-v4:+' which is included in more than one sub-module. And during my apk compilation, i am getting error:
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
I found few similar questions, but still couldn't resolve this error. Please help.
You need to remove those com.android.support:support-v4 jar files and include only com.android.support:support-v4 jar in main application. If required you can copy same jar files in submodules.
Clean and build, now you check.
[I am using Eclipse hoping that clean n build would also be exist in Android Studio.]

Categories

Resources