Android dependency conflict. No information provided by androidDependencies task - android

I am attempting to break a large project into sub-projects. Mostly its working despite the many bug related to dependency handling in grade, however Ive run across a conflict, that I can't get a graph to resolve.
What I expect is to be abel to get a graph of dependencies so I can track down which library has the two conflicting dependencies, but the command stops before the dependency graph is printed for me to review.
I am unsure if this is somehow by design or just another bug in gradle or the android plugin.
This is my output.
$ ./gradlew androidDependencies
Defining custom 'clean' task when using the standard Gradle lifecycle plugins has been deprecated and is scheduled to be removed in Gradle 3.0
Incremental java compilation is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':xlivestream'.
> Could not resolve all dependencies for configuration ':xlivestream:_debugCompile'.
> A conflict was found between the following modules:
- com.android.support:support-annotations:23.4.0
- com.android.support:support-annotations:23.1.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Can anyone tell me how I'm supposed to get a dependency graph, to resolve this problem?

The error occurs because the configuration parameter resolutionStrategy.failOnVersionConflict() is enabled.
However, there appears to be a bug in gradle that prevents the dependency task from listing dependencies, because that parameter fails the build before it can execute.

Related

flutter build apk results in "R8: Type [...] is defined multiple times"

I am developing a flutter app for Android. For that I am using a realm database and I am using the realm dependency for flutter https://realm.io/realm-flutter/ to read data from it. This realm database is generated by some android library com.my_realm_generating_library.
My problem is now, that com.my_realm_generating_library imports the realm library for kotlin https://realm.io/realm-kotlin/ and because I am importing the realm library for flutter, the kotlin library is included a second time.
When I run flutter build apk I get this result:
Running Gradle task 'assembleRelease'...
Realm binaries for realm#0.8.0+rc already downloaded
Realm install command finished.
ERROR:/home/user/.gradle/caches/transforms-3/c90739e9642326489e851a982778d55f/transformed/jetified-realm-android-library-10.6.1-runtime.jar: R8: Type io.realm.BuildConfig is defined multiple times: /home/user/.gradle/caches/transforms-3/c90739e9642326489e851a982778d55f/transformed/jetified-realm-android-library-10.6.1-runtime.jar:io/realm/BuildConfig.class, /home/user/projectname/build/realm/intermediates/runtime_library_classes_jar/release/classes.jar:io/realm/BuildConfig.class
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
> Compilation failed to complete, origin: /home/user/.gradle/caches/transforms-3/c90739e9642326489e851a982778d55f/transformed/jetified-realm-android-library-10.6.1-runtime.jar:io/realm/BuildConfig.class
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
Running Gradle task 'assembleRelease'... 9,2s
Gradle task assembleRelease failed with exit code 1
When I remove the realm library from my pubspec.yaml, everything compiles. But I need access to my realm file from my kotlin code and my dart/flutter code. Is there some way to fix such dependency conflicts, where flutter uses a library and kotlin the same and in the end none of them work?
What I tried so far:
I removed realm: ^0.8.0+rc from the dependencies section of my pubspec.yaml. Then everything compiles. This is not an option because I need this library in my dart code.
I could also remove implementation "com.my_realm_generating_library" from android/app/build.gradle. But I also need this library in my kotlin code to generate my realm database. Therefor this is also no option.
Amazingly I was able to find an answer for my question, although I was unable to find one anywhere online so far. Hopefully this helps some people who get into the same trouble as I have.
Firstly, I navigated into my projectname/android and ran ./gradlew app:dependencies --console=rich to find all the dependencies of com.my_realm_generating_library.
In my case, the only dependency of com.my_realm_generating_library was io.realm:realm-android-library:10.13.0. I knew that this package will be provided by the realm-flutter dependency. Therefor I knew, that I can just force disable all transitive dependencies of com.my_realm_generating_library.
The code I put in my build.gradle under the dependencies section was this:
implementation("com.my_realm_generating_library") {
transitive = false
}
Now everything works. Hope this helps!

Android Execution failed for task ':app:compileDebugJavaWithJavac'. - React Native

I am working on a react native application. when I try to build the applications using react-native run-android the build fails. Here is the output of the error that occurs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 8s
253 actionable tasks: 5 executed, 248 up-to-date
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug
debug Error: Command failed: ./gradlew app:installDebug
at checkExecSyncError (child_process.js:607:13)
at execFileSync (child_process.js:627:13)
at runOnAllDevices (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runOnAllDevices.js:58:39)
at buildAndRun (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runAndroid.js:142:41)
at then.result (/Users/FaisalHussain/mobile/node_modules/#react-native-community/cli/build/commands/runAndroid/runAndroid.js:104:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
The application was on a old version of react native (0.48.x) I have updated it to 0.59.10.
What I have done so far:
used jetifier to resolve issues with the plugins.
checked that the build tools version matches the compile sdk version
checked if the emulator is running.
Hence I have tried everything I could to resolve this but had no luck. Please do guide me on how to resolve this issue. Looking forward to your answers.
make sure you have followed all the necessary steps from the upgrade helper https://react-native-community.github.io/upgrade-helper/?from=0.48.0&to=0.59.10
also i would suggest you to upgrade to v0.60+ because there are breaking changes after v0.59.10.
having said that
before you run the app make sure your gradle is clean
run the following command to clean your gradle cd android && ./gradle clean
then later you can navigate back to your app folder cd .. and try and run again react-native run-android
Looks like your packages not working stable with Android side. It's better be update all packages and react native version to their last stable versions.
If you face with too much error while update, you can create fresh new react native project (with same package name with your current project), install all packages (and their dependencies) and copy your current project's source code to your new project.
Android in React Native does not allow similar packages to reside in the project.
In my case I had react-native-cookies and #react-native-cookies/cookies packages that add similar code to the Kotlin file upon build. This causes issue of similar imports in java JDK.
I removed one and it worked.
SOLVED at the same issue:
My solution was at /android/build.gradle file.
Somehow, the buildscript versions were wrong.
Follow the exact same step of RN documentation and make a totally new & clean project.
And compate the /android/build.gradle file > buildscript & dependencies part.
There should be some version differences.
It matters by your own local env settings.
After changing buildToolsVersion, ndkVersion, classpath, it worked fine again!!
also, remove duplicated libraries, as #Nimantha said.

Update to Gradle 5.1.1 gives "The ProjectLayout.fileProperty() method has been deprecated"

I am working on a project that previously used Gradle 4.6 and it worked fine. I just updated to Gradle 5.1.1 and I am now receiving the following warnings (Not sure they are warnings or errors, though):
> Configure project :app
Warning: Please apply google-services plugin at the bottom of the build file.
The ProjectLayout.fileProperty() method has been deprecated. This is scheduled to be removed in Gradle 6.0. Please use the ObjectFactory.fileProperty() method instead.
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
FAILURE: Build failed with an exception.
* What went wrong:
Failed to notify build listener.
> org.jetbrains.plugins.gradle.tooling.util.ModuleComponentIdentifierImpl.getModuleIdentifier()Lorg/gradle/api/artifacts/ModuleIdentifier;
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
CONFIGURE FAILED in 0s
Cause: org.jetbrains.plugins.gradle.tooling.util.ModuleComponentIdentifierImpl.getModuleIdentifier()Lorg/gradle/api/artifacts/ModuleIdentifier;
I searched for ProjectLayout.fileProperty inside the whole project and didn't find a single string like that. Where is fileProperty used then causing the compiler to complain? How can I fix these deprecation warnings rather than suppressing them? Is there a part of my code I need to change? Or does the usage pointed to by compiler occur inside one of the libraries I have added?
These are warnings, not errors, and can come either from your own build scripts, or as it seems to be the case here, from a plugin.
These warnings, as they indicate, can become errors only when moving to the next Gradle major version.
In the case the source of the warning is inside your build script, you should try to make them go away as fast as possible. That way upgrading to the next Gradle major version will not be a problem.
When coming from a plugin, if you can identify the right plugin, upgrade to a more recent version and file an issue if the warning persists. This way you have a better chance that the plugin keeps working with the next Gradle major version.

Lyft Android SDK integration issue

I added Lyft android SDK dependency in my app in dependency section of build.gradle file as below
implementation "com.lyft:lyft-android-sdk:1.0.3
But I am getting below error while running app on mobile device:-
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDevDebug'.
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 3m 33s
I try to solve above issue by adding multiDexEnabled true in default config of app gradle, but it doesn't work.
I am using Android Studio 3.0.1 and gradle 4.1 version.
I investigated issue more by enabling stack trace in gradle build process and looking out stack trace log.
In stack trace I found there is a duplicate class from org.jetbrains.annotations package which is coming from two different dependency module. one dependency module was from kotlin dependency and one was from lyft sdk dependency module. So I added Lyft sdk dependency as like below in build.gradle and it works for me.
implementation ("com.lyft:lyft-android-sdk:1.0.3"){
exclude group: 'org.jetbrains', module:'annotations-java5'
}

Android Signed APK java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.typehandling.ShortTypeHandling

I am trying to build a signed APK with Android Studio.
I am getting the following error:
java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.typehandling.ShortTypeHandling
My research leads me to understand that this is caused by one of my dependencies being compiled with an old version of Groovy. My only dependency is the Google Maps API, so that must be it.
(this is a thread that talks some on the issue)
However, I am unable to find a solution to this problem. I have tried several ways of adding the Groovy backports compat 2.3.5:
- adding it to gradle dependencies and syncing the project
- manually adding it to m2
- downloading the jar and adding it as a library
None of these have been successful. It is possible however, that one of these solutions may work, but that I am missing some key piece of information necessary.
If you know what that might be, or if you have another way to solve this, I'd like to hear from you.
Thanks.
[Edit]Here is some additional information
C:\Users\Donald\AndroidStudioProjects\ReuseAndRepairAndroid>gradle dependencies --info
Starting Build
Starting file lock listener thread.
Settings evaluated using settings file 'C:\Users\Donald\AndroidStudioProjects\ReuseAndRepairAndroid\settings.gradle'.
Projects loaded. Root project using build file 'C:\Users\Donald\AndroidStudioProjects\ReuseAndRepairAndroid\build.gradle'.
Included projects: [root project 'ReuseAndRepairAndroid', project ':app']
Evaluating root project 'ReuseAndRepairAndroid' using build file 'C:\Users\Donald\AndroidStudioProjects\ReuseAndRepairAndroid\build.gradle'.
Evaluating project ':app' using build file 'C:\Users\Donald\AndroidStudioProjects\ReuseAndRepairAndroid\app\build.gradle'.
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Donald\AndroidStudioProjects\ReuseAndRepairAndroid\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not create plugin of type 'AppPlugin'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
Total time: 2.982 secs
[/Edit]

Categories

Resources