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.
Related
So I have been facing these issues in so many JavaFX Gradle based projects in Intelli J Idea IDE. This has pushed me to the point where I had to manually download library files and make them part of my projects as a workaround.
The gradle projects I have they keeping failing when ever i run the > Task :compileJava in the IDE, for example in this particular that made me create the issue is that i have successfully imported the socket io lib from maven implementation 'io.socket:socket.io-client:2.0.1' , i have managed to import it and write a bit of sample code for it and i have added
requires engine.io.client;
requires socket.io.client;
in the module info file . So when its time to run this fails stating that
error: module not found: socket.io.client
requires socket.io.client;
error: module not found: engine.io.client
requires engine.io.client;
I have tried on JDK 13,16,17 to see if I am missing something but keeps on failing to run , so I have noticed now as a trend in my previous JavaFX project in which i managed to get away with.
So if there is anyone who understands what's wrong with Gradle set up please help.
This answer outlines an approach rather than a concrete solution.
socket.io.client and engine.io.client are not module names.
The socket.io-client library is not Java platform modularized (as far as I can tell), so it will be an automatic module.
The name of the module will be derived from the jar name. I don't know the exact translation as the jar name has . and - characters which may be remapped (or not) to make the module name valid. Try first the exact jar file name. There can be only one module per jar.
Additionally to requiring the right name, the jar needs to be on the module path. Maven will do this automatically for automatic modules, Gradle will not. I am not a Gradle expert, so will not provide advice on how to do that for Gradle.
If you use the right name in module-info and ensure the jar is on the module path, then it may work, or it may be incompatible with the Java module system in ways that are not easily fixable by you (i.e. the broken module must be fixed by the module maintainers).
You can raise an issue for the library maintainer for them to create module-info.java files for the modules and update their documentation on how to use their libraries in a Java module environment.
If the library you are trying to use is incompatible with the Java module system when used as a module, then you could try making your project non-modular by deleting module-info.java from your project and adding appropriate command-line switches. To understand how to do this, refer to documentation on non-modular projects at openjfx.io.
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
}
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.
I got this message while trying to build a maven-based open-ide application:
Some tokens required by included modules are not provided by included modules. The application will fail starting up. The missing tokens are:
org.netbeans.modules.java.source.queries.spi.QueriesController ref: [org.netbeans.modules.java.source.queries]
org.netbeans.api.editor.guards.Java ref: [org.netbeans.modules.form]
org.netbeans.modules.editor.actions ref: [org.netbeans.modules.editor.lib2]
I tried Googling for the first line to see if I could find the answer there, but all I got was the source code where the error was being raised. Can any-one clearly interpret this error and/or tell me how to fix it?
Note: it does not specify which of my modules is causing it, but it is dying on the "app" project.
tokens are a type of netbeans dependency that cannot be expressed by maven dependencies. Typically an API module requires an implementation that way while the implementation module has regular compilation dependency. For modules system defaults, see http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/api.html#how-vers
Typically you would have to look into the module jar's manifest to find which module provides which token.
The easiest way to setup a maven based application is to include enough cluster dependencies in your nbm-application packaging project. (org.netbeans.cluster groupId). Then if you don't need some features, slowly start excluding modules to see if it didn't break anything.
By default the nbm-application project depends on 'platform' cluster, you apparently need also 'ide' and 'java'
It appears that it means that certain tokens (on the left) are not provided to the, modules that need them (on the right). I found the needed modules by grep-ing the NetBeans source for the token and looked for a line that started with OpenIDE-Module-Provides: and then adding that module to the project that had issues.
I found the project that had issues by cleaning everything and then building the projects from the least dependent to the most until I got the error again.
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).