Fail demo:transformDexArchiveWithExternalLibsDexMergerForMockDebug with a DexArchiveMergerException - android

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.

Related

App Bundle build fails because of the sym_keyboard_feedback_delete.png file

I am trying to build my app using the Android app bundle. The apk gets generated fine but the bundle doesn't due to a "reserved file or directory name 'res'". Oddly it singles out this drawable file which exists only in the Android pie (28) SDK folder. I'm not using it anywhere in my module.
sym_keyboard_feedback_delete.png
I'm using the latest gradle version (3.2.1) and compiling against Android Pie (28). Any ideas?
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':packageProductionReleaseBundle'.
> java.util.concurrent.ExecutionException: com.android.tools.build.bundletool.exceptions.BundleFileTypesException$FileUsesReservedNameException:
File 'root/res/drawable-hdpi/sym_keyboard_feedback_delete.png' uses reserved file or directory name 'res'.
I've figured out the problem. One of the libraries I am using had a dependancy on the Google Android Library ยป 4.1.1.4, which contains resource file sym_keyboard_feedback_delete.png and others that occupy the res directory.
Excluding this module from the library dependancy has solved this issue.
exclude group: 'com.google.android'
It looks like one your dependencies is not compiled as an AAR but instead just as JAR.

Error: app:transformClassesWithDexBuilderForDebug

I have a class HillfortStore in this package:
package org.wit.hillforts.models
Messed up the package name in the class (missing the 's'):
package org.wit.hillforts.model
Imported class into other classes with wrong package name, it works just fine:
import org.wit.hillforts.model.HillfortStore
To clean things up I fix the name in the class and all classes its imported into. Now I'm getting this error.
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
com.android.build.api.transform.TransformException: java.lang.IllegalStateException: Dex archives: setting .DEX extension only for .CLASS files
just do this :
in main project folder ,in terminal type
cd android
then type this
./gradlew clean
then build your app again
I needed to complete a rebuild of the app.
This is all it took to fix the issue.
It is working now.
Delete .gradle file from your project folder then clean the project and Rebuild
I had a similar problem because Lombok plugin didn't work with new gradle. Just removed these lines:
compileOnly 'org.projectlombok:lombok:1.18.4'
annotationProcessor 'org.projectlombok:lombok:1.18.4'
and the problem disappeared.
Maybe you also have some kind of "troubled" plugin that doesn't get along with new gradle)
run this in npm
$cd android
than run
$gradlew clean
than run
$cd ..
and finally, run
$npx react-native run-android

Error: Program type already present: org.openqa.selenium.WebDriver$ImeHandler

I'm trying to set up Appium with Android Studio and encounter loads of errors. I'm using the open source app Omni-Notes and if I include the necessary dependencies via the maven repository, I get the following error:
Execution failed for task ':omniNotes:transformDexArchiveWithExternalLibsDexMergerForFossDebug'.
Program type already present: org.openqa.selenium.WebDriver$ImeHandler
Sometimes it's the ImeHandler, but other times WebDriver$Options.
These are the versions I'm using:
compile group: 'io.appium', name: 'java-client', version: '6.0.0-BETA1'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.8.1'
I've tried things like cleaning the project, deleting .gradle, adding multidexenabled etc.
Would really appreciate any help.
When I add the "Appium Jar files for Java" plugin (java-client-7.0.0.jar) I checked that it already contains the classes contained in the "Latest Appium Client Library" (selenium-java-3.141.59) as described in some tutorials on the internet.
To solve the problem do:
Delete the java-client-7.0.0.jar file from your project
Open java-client-7.0.0.jar with 7zip and delete the "org /" folder and all subfolders.
Include the updated java-client-7.0.0.jar in your project. Rebuild project

"Could not initialize class" error running lint target from gradle

I'm working on an Android project with two projects inside it. When trying to run a build with gradlew (./gradlew build), I see the following error:
Execution failed for task ':example:lint'.
Could not initialize class
com.android.build.gradle.tasks.Lint$LintGradleIssueRegistry
With stacktrace enabled, this is listed as a java.lang.NoClassDefFoundError.
Oddly, the first time I ran this (which downloaded dependencies), the build failed with a different error:
Execution failed for task ':example:lint'.
lombok/ast/Node
The gradle wrapper that Android SDK created for the project is using Gradle 2.8.
Could this be a configuration issue with the project or my dev machine? I'm trying to avoid using the Android SDK lint tool as this complains about the projects using Gradle (and I hear it may miss some parts of these projects).
Turned out this was a configuration issue in our build.gradle. The following line had been added for testing and never removed:
configurations.classpath.exclude group: 'com.android.tools.external.lombok'
As such, the classes needed for linting were missing.
The following discussion pointed us in the right direction, in case it's useful to anyone else:
https://github.com/evant/gradle-retrolambda/issues/96

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