My project was working and everything was fine but have no idea what happened suddenly that I'm getting error when I want to build my project. This is Gradle output:
/Users/admin/Desktop/android/MY-Project/build/intermediates/res/project/debug/values/values.xml:265: error: Resource entry com.crashlytics.android.build_id is already defined.
/Users/admin/Desktop/android/MY-Project/build/intermediates/res/project/debug/values/com_crashlytics_build_id.xml:9: Originally defined here.
Since both of these files are auto generated I cannot do anything :(
I tried to clean project by Build>"Clean project" but nothing happened.
I tried to clean project by ./gradlew clean assembleDebug but nothing happened.
I tried to invalidate cache of Android Studio by File>"Invalidate caches / Restart" but nothing happened.
I even restarted my f.laptop but still same problem displays when I build the project.
I have this classpath in my build script but as mentioned it was working...
dependencies {
classpath 'com.android.tools.build:gradle:1.0.1'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
Any suggestion would be appreciated. Thanks.
I have an app of two flavors: Debug and Release, with two manifests and two distinct packages com.myapp.release and com.myapp.debug for each flavor, respectively.
After migration from Fabric.io to Firebase Crashalytics, a Gradle warning
appeared about duplicate com_crashlytics_build_id.xml:
/home/.../app/build/generated/fabric/res/flavor1/debug/values/com_crashlytics_build_id.xml [string/com.crashlytics.android.build_id] /home/.../app/build/generated/crashlytics/res/flavor2/debug/values/com_crashlytics_build_id.xml: Error: Duplicate resources
Fix:
in build.gradle
remove
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
remove
apply plugin: 'io.fabric'
I had the same problem.
My mistake is I add fabric plugin and firebaseCrashlytics plugin on my gradle.
(reason : plugin build id duplicate crash)
You must fix select A and B plugin.
A : apply plugin: 'com.google.firebase.crashlytics
B : apply plugin: 'io.fabric
I had the same problem, one of my dependencies had mistakenly added the com.crashlytics.android.build_id via craslytics's auto genereted xml file.
It was a library project and deleting :
library/src/main/assets/crashlytics-build.properties
library/src/main/res/values/com_crashlytics_export_strings.xml
fixed it for me.
Fix different io.fabric.tools:gradle versions
Different io.fabric.tools:gradle versions in the app and library caused this for me.
I'd the following in the app's build.gradle:
classpath 'io.fabric.tools:gradle:1.19.2'
And the following in the library's build.gradle:
classpath 'io.fabric.tools:gradle:1+'
I changed both to following to fix it:
classpath 'io.fabric.tools:gradle:1.19.2'
PS: We need better error messages. As programmers we waste of lot of time when the error messages are not only bad, but as in this case, downright misleading.
remove this also besides fabric
crashlytics {
enableNdk true
}
Related
While learning android studio from udacity they asked me to download a project; I did so but while I was importing it to android studio I got an error message:
The project uses Gradle 2.10 which is incompatible with Android Studio 2020.3.
Why did I get this error?
If you did not figure this out yet, I am just starting the same project too. I changed the classpath like above. I then found a website to use the latest version of gradle and the plugin. It says "You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or by editing the Gradle distribution reference in the gradle/wrapper/gradle-wrapper.properties file." I did the first one.
Then, I got errors for both build.gradle files in the project and app version. I get this error: Could not find com.android.tools.build:gradle:7.0.3
If you get this error, click the link "Add google Maven repository and sync project". Then you have to click "Do refactor".
Now you come across another error in one of the build.grade files. This stackoverflow link will tell you: Gradle - Error Could not find method implementation() for arguments [com.android.support:appcompat-v7:26.0.0]
Finally, replace testCompile with testImplementation and then you should get BUILD SUCCESSFUL.
The project's Gradle version you're trying to clone is outdated. Change it based on your android studio version.
on your build.gradle(Project) change the version and sync
classpath "com.android.tools.build:gradle:4.1.2"
Got the solution :)
In gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
In build.gradle project level:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
In build.gradle module level:
Replace all "compile" with "Implementation" and do other suggested version updated and you are done here :)
Hope this works for you, if yes just press that up button :)
If not getting any solution, the best you can do is copy the "app" folder of your project(using file explorer) and paste it in a newly created project(should be of same name as of your project), in that way you'll get already synced gradle and newly created version of your app.
Because, every important thing in your project is present in its app folder and when you create a new project with same name and copy app folder from your older version of your project, you will have a newer version of your project with all same resources.
Note: You can't move through branches and other commits
I saw this issue several times with Android studio. Below trick worked me the best.
Android Studio suggests to upgrade to newer version, please upgrade it and let it sync
Mostly you would see error message again
Now, Go to File -> Invalidate Caches/Restart
It should work now
If it shows same error then I don't know what to do.
If it shows different error then repeat from step 1 to 3 for new error.
Hope, it helps some..
I have done nothing with the codebase, and I'm surprised to see the below error.
And I have tried upgrading or downgrading the Gradle wrapper and Gradle build tools.
I'm using Gradle build tools v3.2.1 with Gradle wrapper4.6-all.zip.
Note: Other projects are working fine and even I tried deleted the complete code and cloned a fresh one
Can anyone please help me
update your gradle file.
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.2.0'
I'm creating an instant version of my Android game. I have followed the instructions on this example:
https://codelabs.developers.google.com/codelabs/android-instant-apps/index.html?index=..%2F..%2Findex#0
The problem is that in the feature module I need to access services implemented by the com.google.gms.google-services plugin, so I put it at the bottom of my dependencies in the gradle file for such module, but as the package name of my game is (say) com.me.mygame while the one for the feature module would be com.me.mygame.base, the aforementioned plugin fails because there's no com.me.mygame.base package defined in my app google-services.json file.
So I tried by setting the name of the feature module to com.me.mygame too and that made the trick for that and gradle would successfully build the project, but it will fail when trying to build the APKs due
com.android.dex.DexException: Multiple dex files define Lcom/me/mygame/BuildConfig
I tried to workaround this by adding this option to my gradle modules, as suggested in an answer to a related question here:
android {
dexOptions {
preDexLibraries = false
}
}
But to no avail. The problem persist.
It seems the logical thing would be that the feature module has a different package name, but as told before this will fail due the com.google.gms.google-services plugin not founding a configuration for such package.
So... I'm stuck at this and have run out of ideas, so any help will be welcomed.
Thanks a million in advance!
UPDATE: I have published a minimal example in github at the following URL:
https://github.com/fmmarzoa/IssuesWithFirebaseCrashlytics
I've took that example directly from Google Guides. The master branch is empty, those with the workarounds I've tried so far are all named 'firebase/...'. The last one is this 'firebase/updating-plugins':
https://github.com/fmmarzoa/IssuesWithFirebaseCrashlytics/tree/firebase/updating-plugins
What I have done in that one is to update several things as suggested by dchai, and it seems to do the trick for the Google Services plugin (at least it does build now) but the Firebase Crashlytics plugin which depends on the aforementioned one continues failing with the error message:
Crashlytics could not find the manifest. Not found at
/Users/fran/Desktop/Idea/android-topeka/base/build/intermediates/merged_manifests/debug/AndroidManifest.xml
Older versions of plugins don't correctly pick up applicationId for the purposes of checking against google-services.json.
If you upgrade to com.android.tools.build:gradle:3.3.0-alpha08 and com.google.gms:google-services:4.1.0, your original project structure should build fine.
Is there a way to configure Gradle to shorten the folder names of its cached dependencies?
From the Gradle user guide it does not appear its possible, but figured to check with others.
My use case is because using the 'idea' Gradle plugin it helps with settings up Module dependencies. A problem arises when the Module classpath becomes 'too long' for cmd.exe (I'm not trying to discuss these limitations). Idea loads the project just fine, but its unable to run my program since it states the classpath is too long.
Since this is not an Idea problem, I figured it would be lovely if there was a way Gradle could cache deps using shorter folder names.
Example
from: C:\.gradle\caches\modules-2\files-2\com.google.application\application\2.0\SVABNSAVSASAMNVSMAVSASN\application.jar
Options 1 To: C:\.gradle\caches\modules-2\files-2\c.g.a\a\2.0\SVABNSAVSASAMNVSMAVSASN\application.jar
Options 2 To: C:\.gradle\caches\modules-2\files-2\co.go.ap\ap\2.0\[tinyurl-equivalent]\application.jar
Options 3 To: C:\.g\c\m-2\f-2\c.g.a\a\2.0\[tinyurl-equivalent]\application.jar
Options 4 To: C:\.g\[tinyurl-equivalent]\application.jar
I do know that Idea does recognize the long classpath and prompts to enabled Dynamic Classpaths, but this has been known to cause other problems (some invoked apps cannot see the full classpath) and therefore I'd like to avoid this Idea option.
As of Gradle 2.1, shortening dependency cache paths isn't supported. There are ideas around symlinking or copying dependencies into the project, but nothing concrete has materialized.
This isn't intended to be a question. Rather, an observation which is a common problem found in Android when you use external APIs for development and android.jar isn't duplicated into your project!
After searching through various forums, Google and stackoverflow, I seem to get a solution by myself and thought of sharing it.
Whenever you are linking external libraries, better link it by creating a /lib folder and dump those .jars there(means to COPY the files and NOT linking them). Link them using Eclipse -> Build Properties -> Configure Build path -> Library tab -> Add external Jars. Add the required .jars saved in /lib folder in this. (Note that, the jar included as a "Referenced Library" in Eclipse will disappear in /lib folder! But, not to worry as proper linking has happened. Another note is to check that the /lib jar that was referenced should NOT be visible in Libraries tab of Build Properties as it will be inherited.)
Another major problem was when Google APIs are being used. Specially the ones, which use some core library functions of java/javax. Be very careful of this. The error is that, the DalvikVM tries to link these but fails as there is a duplication found and is unable to decide which one to refer to. Below is the error.
Dx trouble processing "javax/xml/namespace/QName.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library.
In such cases, what I have observed is that, this class is used in xpp3-1.1.4c.jar. If you've copied this into your /lib folder, PLEASE REMOVE IT. Then clean the project, and give a fresh build. And the ship sails smoothly thereafter.
Do this for other referenced .jars if such duplication exists.
Cheers!
This worked for me. I'm using maven, and the xpp3-1.1.4c dependency shows up under "Maven Dependencies"; I had to exclude it using (right click the dependency) Maven-> "Exclude Maven Artifact...". Thanks a bunch -- this was really obscure.
This error show only when you trying to generate signed APK.
There are 2 ways to fix this.
1. As commented Amira Elsayed Ismail in this post this
we should revert to gradle 2.3.3.
To do this you should also download Android Studio 2.3.3 because studio 3.0.1 require gradle plugin 3.0+
This was the first solution. But reverting Android Studio and gradle plugins is a painful solution.
2. Resolve all dependency conflicts.
When i revert gradle, Studio 2.3.3 showed we interested warnings(i do not know why studio 3.0.1 don't show dependency conflict warnings)
Warning:WARNING: Dependency xpp3:xpp3:1.1.4c is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.3 is ignored for debug as it may be conflicting with the internal version provided by Android.
So these dependencies are ignored for debug but NOT FOR RELEASE.
I fixed this by excluding these dependencies.
configurations {
all*.exclude group: 'xpp3', module: ['xpp3' ,'httpclient']
}
After this, i successfully generated signed APK using gradle 3.0.1.(without reverting).