I'm getting this during gradle builds after the upgrade to Android Studio 3.0:
Execution failed for task
':lf-android-myproject:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug'.
java.lang.RuntimeException: java.util.zip.ZipException: duplicate entry: com/my/package/name/SomeCustomView.class
The class in question comes from my code, it's not from a library.
It happens only with my classes that have custom attributes declared:
<declare-styleable name="SomeCustomView">
<attr name="someCustomViewText" format="reference|string" />
</declare-styleable>
I can fix it by cleaning and then building from the console, but it pops up again eventually.
I can fix it also by renaming the class or the styleable, but I really don't want to mess with our code just to go around an AS (or gradle?) bug that can be fixed in the future probably.
Is it an Android Studio bug? Are there any workarounds?
Gradle version is: gradle-4.1-all
Android Gradle plugin version is: 3.0.1
This issue can be found for different reason. However, Here is a way to fix Gradle build error: “java.util.zip.ZipException: duplicate entry”
If you’ve updated some libraries in your android project and then encountered the following error while assembling it (or something similar):
The reason is that some libraries have similar dependencies, therefore the compiler can not choose the appropriate one.
According to the logs, the problem in the duplicated class
org/intellij/lang/annotations/Identifier.class
To find this class usages, you should filter the detailed gradle log:
Fix it!
Remove one of the dependencies:
Follow this for your case and I guess you will find your solution.
I solved this by deleting Android Studio files from the project and re-importing the project.
Related
I just updated Android studio 3.6.1 and while building my app I got following warning:
Configure project :app
WARNING: The following project options are deprecated and have been removed:
android.enableUnitTestBinaryResources
The raw resource for unit test functionality is removed.
What is this warning about and how to remove this?
The robolectric instructions say that this configuration is not necessary with Android Studio 3.3+
So, please check your gradle.properties file and remove this line:
android.enableUnitTestBinaryResources=true
In my case, I just cleared my gradle cache files and that seemed to have resolved the problem
My problem solved by removing configuration at gradle.properties. see below:
#android.enableBuildCache=true
We updated Android Gradle plugin from 3.4.2 to 3.5.0 (and Gradle from 5.1.1 to 5.4.1).
After that, the build started failing in a few submodules. Trying to assemble any build variant yields this (same error on the command line and in Android Studio):
> Failed to transform artifact 'bottom-navigation.aar (project :bottom-navigation)' to match attributes {artifactType=jar}.
> Execution failed for JetifyTransform: <project_root>/bottom-navigation/build/outputs/aar/bottom-navigation-release.aar.
> Failed to transform '<project_root>/bottom-navigation/build/outputs/aar/bottom-navigation-release.aar' using Jetifier.
Reason: Cannot open a library at 'FileMapping(from=<project_root>/bottom-navigation/build/outputs/aar/bottom-navigation-release.aar, to=<project_root>/bottom-navigation/build/.transforms/9b2af95a5f0e0055110660c22ff05ab5/jetified-bottom-navigation-release.aar)'. (Run with --stacktrace for more details.)
Any ideas how to fix this?
What I've tried
"Invalidate caches" in AS and also clearing all Gradle caches in ~/.gradle/caches as suggested in this answer
All the advice in this somewhat similar question
I checked that the problematic modules use apply plugin:
'com.android.library' (instead of com.android.application)
I tried updating appcompat dependency to androidx.appcompat:appcompat:1.1.0 in affected modules and also removing that dependency
Update
It starts to look like something is wrong in Gradle plugin 3.5.0; builds behave erratically for me locally and on our CI machine.
For example, clean builds are failing: ./gradlew clean assembleBetaRelease fails while ./gradlew assembleBetaRelease works!
Also, sometimes I get AAPT: error: attribute ... not found instead of the above Failed to transform artifact error.
Reverting to Gradle plugin 3.4.2, all these problems disappear.
Edit Oct 2019: Still seeing this weird behaviour with Gradle plugin 3.5.1. Edit Nov 2019 And 3.5.2. Upgrading to Gradle 5.6 didn't help either.
A bit weird, but I got it working again. Apparently just a temporary glitch in Android Gradle plugin related to caching.
This answer helped me:
The simple way to solve this is to switch between your build variants. This refreshes the cached copies and resolves the issue.
I couldn't do that in Android Studio since the project sync was failing, but on the command line I tried another variant (in my case ./gradlew assembleBetaDebug having used ./gradlew assembleBetaRelease earlier). The build passed, and after that it worked for all all other variants too, and Gradle sync in Android Studio started working as well!
Edit: actually this is not completely solved; see updated question.
Update 12/2019: bundle* commands work fine, it's only assemble* that fails—still failing with Android Gradle plugin 3.5.3. Building in Android Studio works fine. Obviously this is not a common issue, and I don't know what exactly in the particular project I'm working on is causing this.
Update 04/2020: now with Android Gradle plugin 3.6.2 (and Gradle 5.6.4) builds work for me locally and I was able to update the project. On CircleCI, the build still occasionally fails with "Failed to transform artifact" but re-running fixes it. Go figure 🤔
I was working on old android studio with gradle plugin 3.2.0 with KOIN and Room in MVVM Design Pattern.
Yesterday I had Updated my Android Studio to New Version 3.2.1, And after that when i am trying to compile my project I am getting Following Error.
error: cannot find symbol
protected TimeLineBind(DataBindingComponent _bindingComponent, View _root, int _localFieldCount,
I tried resolving by my Side and I have applied many solutions and also better one from Here
but still i am unable to figure out the issue. I have tried migrating back to old Gradle 3.2.0 - i was working on, But still facing the same error.
I have also tried android.databinding.enableV2 = true solution,
but it didn't worked. I am wondering if anyone can help. I can update anything you want.
i have found resolution myself. The room Annotations was causing the problem and I was getting the error Regarding Data binding.
So, Every-time when you spawn with an error, Not necessary that you are having an error with Data Binding thing, But There is something else causing this error or Warning, And it is stopping Data binding Classes to be Generated.
=> All Data Binding Classes are generated at the End When Compilation get Completed Successfully without Errors & Warnings.
==> Try Lint Check and Fix all possible errors and Warnings that you think may Cause a Problem, And after that try Compiling again.
===> Since Gradle 3.2.1 - Stable i confirm that there is no need to add any kapt-compiler dependency in gradle tor annotation processing, it is added automatically by gradle when Gradle is on Stable Version.
For Ex. -> kapt 'com.android.databinding:compiler:x.x.x' - Remove all this
====> add android.databinding.enableV2=true in gradle.properties file
I'm using Android Studio 3.2 Canary 14 and am trying to migrate an existing project to use AndroidX. It sounds from https://developer.android.com/topic/libraries/support-library/androidx-rn that I have to have set android.enableJetifier=true (this was done automatically for me when selecting "Refactor to AndroidX.." option). I've also updated target API level to 28. Anyone else seeing this issue?
Failed to transform
'/Users/jooreill/.gradle/caches/modules-2/files-2.1/com.google.firebase/firebase-perf/15.0.0/6e68f6e44b0c9d91756f903547ee3853349ae666/firebase-perf-15.0.0.aar' using Jetifier. Reason: null. (Run with --stacktrace for more
details.) To disable Jetifier, set android.enableJetifier=false in
your gradle.properties file.
The above error occurs when I run "Clean". In general am getting multiple errors like following if a do gradle sync:
Unable to resolve dependency for
':app-instant#debug/compileClasspath': Failed to transform file
'play-services-measurement-base-15.0.2.aar' to match attributes
{artifactType=jetified-aar} using transform JetifyTransform
For those experiencing the same issue with Android Studio 3.2 Canary 15 (or later) after using "Refactor to AndroidX...":
I had to update some dependencies manually, i.e. change
classpath 'io.fabric.tools:gradle:1.25.1'
to
classpath 'io.fabric.tools:gradle:1.27.0'
in my project's build.gradle file.
If you're using dagger you have to upgrade to version 2.20 or later.
This is because some libraries are not yet compatible with the AndroidX refactor as mentioned under Known issues in the AndroidX release notes.
I had been experiencing this problem while running assembleAndroidTest on Jenkins.
The weirdest part was that this task ran sans any issues on my mac's terminal without any issues, but failed on Jenkins with-
Failed to transform file 'cucumber-java-1.2.5.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
Had been looking for solutions for a couple of days now, having worked though different suggestions - none of which worked.
Finally, disabling Jetifier in gradle.properties resolved it for me.
android.enableJetifier=false
I was able to work around a similar problem by excluding a certain library from being jetified, which can be done by adding to gradle.properties:
android.jetifier.blacklist = ...
Note that this option was added in Android Gradle plugin 3.3.0-rc01 as a temporary workaround.
See https://issuetracker.google.com/issues/119135578#comment5 for more details.
As per a statement on the AndroidX refactor made by a Google Engineer (Support Library) during the I/O session "What's New in Support Library?", Google already discovered bugs related to Jetifier in Android Studio 3.2 Canary 14.
Thus, it is advised to wait until Canary 15 (to be released the coming week) before starting the AndroidX migration process.
I had this same error after adding JDK 11 to my machine. It set itself as default JDK and this error started happening.
After setting JDK 8 as default, it was fixed.
When inserting a new activity (more specifically, navigation drawer activity) my gradle sync breaks and throws the following error:
Failed to find: com.firebase:firebase-client-android:1.1.0.0
I could undo the changes, but I would like to understand why gradle breaks while adding new activities.
Looking over the IDEA LOG, I came by the following Warning:
2014-11-20 15:53:26,547 [ 788010] WARN - ea.stats.LegacySdkStatsService - AndroidSdk.SendPing failed
java.net.UnknownHostException: tools.google.com
I figure it has something to do with the Gradle build file, but I'm not entirely sure why it would compile the Firebase library before adding an activity and after, not.
I'm running on a MacBook Air, OS X Yosemite.
build.gradle: https://gist.github.com/markbratanov/82fe78f7bc2c9064986b
Idea log: https://gist.github.com/markbratanov/d38949010198ec950acd
Any help or suggestions would be appreciated, thanks.
This was solved by deleting the library from gradle dependencies, and searching for the library in Maven Central (in this case, Firebase) and adding the latest version.