I am getting Task 'jar' is ambiguous in root project 'ProjectName'.
Candidates are: 'jarDebugClasses', 'jarReleaseClasses'.
while i run ./gradlew clean jar
can anybody help me out.
The error information basically says what is wrong: gradle cannot determine which task you are trying to run as jar is short for both jarDebugClasses as well as jarReleaseClasses. Replacing jar with jarR will solve the ambiguity (if you want to trigger the jarReleaseClasses task - use jarD for jarDebugClasses).
Related
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!
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.
I'm trying to create automatic tests for my flutter project and I'm using codemagic for this. https://codemagic.io Anyways, everything works fine on my local machine; however, when I try to run it on codemagic it fails on installing dependencies. Here's part of the output for where it's failing:
FAILURE: Build failed with an exception.
* Where:
Script '/Users/builder/programs/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 200
* What went wrong:
A problem occurred configuring project ':path_provider'.
> Failed to notify project evaluation listener.
> Could not get unknown property 'android' for project ':path_provider' of type org.gradle.api.Project.
> Could not find method debugProvided() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I've done some searching related to these errors. I'm seeing a few possible solutions such as upgrading gradle version and make a few adjustments in my files. However, none of the problems pertain to my problem (codemagic) and the solutions generally aren't working. The solutions I was following was they were running on their local machine and they get the error. Mine works locally, but not on the cloud testing environment. Any ideas? (Let me know if there are certain files I should post) Thanks!
I am trying to run a Gradle Android task generated by libGDX utility (the desktop task runs fine) in IntelliJ IDEA, but I'm only getting this nonspecific error message. What is the issue, or where are the logs, or how to enabled logs?
Information:Gradle: Executing tasks: [:core:assemble, :android:assembleDebug]
Information:24. 10. 2015 16:58 - Compilation completed with 1 error and 0 warnings in 9s 415ms
Error:Gradle: Execution failed for task ':android:proguardDebug'.
> java.io.IOException: Please correct the above warnings first.
PS: Not sure if it is relevant, but I have modified build files and ProGuard file to support Scala as described there.
I did not find a way of getting any useful logs from IntelliJ IDEA. I solved the problem by running Gradle from console.
gradlew assemble --stacktrace --info
Problem was Gradle could not find tools.jar. Adding system environment variable JAVA_HOME pointing to Java SDK directory fixed the issue.
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]