Error due to same jars in sub-modules - android

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.]

Related

unable to find project exploded aar

We have simple composite gradle build with android project and a library project. We are getting the following error from the build
> Task :kds-android-studio:lintAnalyzeDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':kds-android-studio:lintAnalyzeDebug'.
> unable to find project exploded aar for /Users/dean/workspace/tray/monorepo/android/libraries/tray-lib-android-studio :
In the build file, we have this line to pull in the artifact(per composite builds)
implementation 'com.tray.android.lib:tray-lib-android-studio'
In the settings.gradle file, we have this(per composite builds)
includeBuild '../../libraries/tray-lib-android-studio'
I have no idea what an aar file is. Any direction on debugging this further would be great? (I am mostly guessing right now and google doesn't seem to have any results on lintAnalyzeDebug and "unable to find project exploded aar".
I see an aar file fro debug and release in the tray-lib-android-studio project. Where is the main gradle project searching for 'exploded aar' and I wonder if I can just hack a target before the one that fails to explode the library aar in a good location to get this passing?

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

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.

"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

Categories

Resources