I get the error com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzau; when i run my app
The gradle files are
app.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.google.android.gms:play-services:7.0.+'
compile 'com.android.support:mediarouter-v7:21.0.3'
compile 'com.squareup:otto:1.3.5'
compile 'com.squareup.picasso:picasso:2.3.4'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.4.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.edmodo:rangebar:1.0.0'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile project(':library_viewpager')
compile project(':androidHorizontalListView')
compile project(':CastCompanionLibrary')
compile project(':mobihelp_sdk_android_v1.4')
compile fileTree(include: 'Parse-*.jar', dir: 'libs')
compile files('libs/Parse-1.9.2.jar')
compile files('libs/GoogleConversionTrackingSdk-2.2.2.jar')
}
CastCompanionLibrary
dependencies {
compile 'com.android.support:appcompat-v7:22.+'
compile 'com.android.support:mediarouter-v7:22.+'
compile 'com.google.android.gms:play-services-cast:7.5.0'
}
How do i fix this? i guess the error occurs because i use google play services in both the module and the app. but the versions are different. is that causing an issue?
I had similar problem and your question helped me solve mine and probably will help you solve yours. Problem is that you have defined:
dependencies {
...
compile 'com.google.android.gms:play-services-cast:7.5.0'
}
and
dependencies {
...
compile 'com.google.android.gms:play-services:7.0.+'
...
}
Since google services 7.5.0, if you're using single modules from play services you can't use whole play services as dependency simultaneously. Solution is to select only those services that you need instead of whole package e.g.:
instead of
dependencies {
...
compile 'com.google.android.gms:play-services:7.0.+'
...
}
use
dependencies {
...
compile 'com.google.android.gms:play-services-maps:7.0.+'
compile 'com.google.android.gms:play-services-location:7.0.+'
compile 'com.google.android.gms:play-services-gcm:7.0.+'
...
}
Also I'm not sure but probably it would be good idea to use the same version of google services in both gradle configs.
I had a similar problem after building using phonegap/cordova:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzsk;
I fixed it by editing build.gradle(module Android), as I had 2 libraries that should have the exact same version with different version numbers (8.4.0 and 9.2.1 in my case)
dependencies{
....
//make sure are both same version (8.4.0 or 9.2.1 in my case)
compile 'com.google.android.gms:play-services-gcm:9.2.1'
// this is the one I changed: compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-location:9.2.1' // it was 8.4.0
....
}
Firebase Android SDKs now have independent version numbers, allowing
for more frequent, flexible updates.
Update all your Firebase dependencies to the latest version (as of 2 May 2018):
Firebase Core com.google.firebase:firebase-core:15.0.2
Ads com.google.firebase:firebase-ads:15.0.0
Analytics com.google.firebase:firebase-analytics:15.0.2
App Indexing com.google.firebase:firebase-appindexing:15.0.0
Authentication com.google.firebase:firebase-auth:15.1.0
Cloud Firestore com.google.firebase:firebase-firestore:16.0.0
Cloud Functions com.google.firebase:firebase-functions:15.0.0
Cloud Messaging com.google.firebase:firebase-messaging:15.0.2
Cloud Storage com.google.firebase:firebase-storage:15.0.2
Crash Reporting com.google.firebase:firebase-crash:15.0.2
Crashlytics com.crashlytics.sdk.android:crashlytics:2.9.1
Invites com.google.firebase:firebase-invites:15.0.2
Performance Monitoring com.google.firebase:firebase-perf:15.1.0
Realtime Database com.google.firebase:firebase-database:15.0.0
Remote Config com.google.firebase:firebase-config:15.0.2
Release note: https://firebase.google.com/support/release-notes/android
I encountered the same issue after manually adding Firebase to my app.
For me the solution was changing:
classpath 'com.google.gms:google-services:3.2.0'
to:
classpath 'com.google.gms:google-services:3.0.0'
in the root-level build.gradle file.
If this is happening with react-native-device-info, you can only change from:
compile(project(':react-native-device-info'))
to
compile(project(':react-native-device-info')) {
exclude group: 'com.google.android.gms'
}
As described here:
https://github.com/rebeccahughes/react-native-device-info/blob/81b0c20fab8a10ccf0341dbd6710d7a5915b06a6/README.md#troubleshooting
Had the same issue while integrating firebase. For my case, it was caused by version mismatch.
on the app gradle, i had:
ext {
PLAY_SERVICES_VERSION = '10.2.0'
}
dependencies {
compile "com.google.android.gms:play-services-maps:$PLAY_SERVICES_VERSION"
compile "com.google.android.gms:play-services-location:$PLAY_SERVICES_VERSION"
compile "com.google.android.gms:play-services-places:$PLAY_SERVICES_VERSION"
compile 'com.google.firebase:firebase-database:10.0.1'
}
the firebase dependancy was added through the integrated firebase plugin in Android studio. When i matched the versions, it worked.
I had this issue recently, the reason was the version difference:
'com.google.firebase:firebase-ads:9.0.6'
'com.google.firebase:firebase-crash:11.0.2'
so make sure you have the same version.
I had the same problem but mine was cause by firebase-ui newest version 2.0.0. So I downgraded to 1.2.0 and added the following line to Project level build.gradle file:
allprojects {
repositories {
jcenter()
// Add the following code
maven {
url 'https://maven.fabric.io/public'
}
}
}
My project is a cordova ionic1 project, I spent a full night and morning to solve this issue, this is what I did beacuse i was having firebase dependencies and google services:
Go to this file :
platforms\android\cordova-plugin-firebase\cordova-plugin-firebase\app-build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
// classpath 'com.google.gms:google-services:3.0.0'
// i changed the above line from 3.0.0 to 3.1.1
classpath 'com.google.gms:google-services:3.1.1'
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'me.leolin:ShortcutBadger:1.1.4#aar'
//compile 'com.google.firebase:firebase-crash:+'
// i changed the above line from + to 11.0.2
compile 'com.google.firebase:firebase-crash:11.0.2'
}
Then Go to this file:
platforms\android\project.properties
Originally i was having this
target=android-26
android.library.reference.1=CordovaLib
cordova.gradle.include.1=cordova-plugin-firebase/app-build.gradle
cordova.system.library.1=com.google.gms:google-services:+
cordova.system.library.2=com.google.firebase:firebase-core:+
cordova.system.library.3=com.google.firebase:firebase-messaging:+
cordova.system.library.4=com.google.firebase:firebase-crash:+
cordova.system.library.5=com.google.firebase:firebase-config:+
cordova.system.library.6=com.android.support:support-v4:24.1.1+
cordova.system.library.7=com.google.android.gms:play-services-auth:11.+
cordova.system.library.8=com.google.android.gms:play-services-identity:11.+
Then i commented out the google services as we need specific dependencies and I also put the versions for firebase and gms to the same version number of 11.0.2
so after my file looks like this
target=android-26
android.library.reference.1=CordovaLib
cordova.gradle.include.1=cordova-plugin-firebase/app-build.gradle
# cordova.system.library.1=com.google.gms:google-services:+
cordova.system.library.2=com.google.firebase:firebase-core:11.0.2
cordova.system.library.3=com.google.firebase:firebase-messaging:11.0.2
cordova.system.library.4=com.google.firebase:firebase-crash:11.0.2
cordova.system.library.5=com.google.firebase:firebase-config:11.0.2
cordova.system.library.6=com.android.support:support-v4:24.1.1+
cordova.system.library.7=com.google.android.gms:play-services-auth:11.0.2
cordova.system.library.8=com.google.android.gms:play-services-identity:11.0.2
If anyone had the same issues as mine, I removed the firebase-core dependency and it worked like a charm.
dependencies{
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.android.gms:play-services-ads:15.0.0'
implementation 'com.google.firebase:firebase-crash:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'
}
to
dependencies{
implementation 'com.google.android.gms:play-services-ads:15.0.0'
implementation 'com.google.firebase:firebase-crash:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'
}
I was having this issue and none of the solutions worked. What worked for me was adding this plugin
cordova plugin add cordova-android-play-services-gradle-release --save
and then in both /platforms/android/cordova-plugin-fcm/ and /platforms/android/cordova-plugin-open/ replace
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
with:
ext.postBuildExtras = {
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}
If anyone else comes across this issue in Ionic removing and re-adding the platform worked for me:
> ionic cordova rm platform android
> ionic cordova add platform android
For anyone wondering how to fix this for Apache Cordova plugins, I fixed this problem by ensuring all plugin.xml files include the same major and minor version, but latest revision, like this:
<framework src="com.google.firebase:firebase-auth:15.0.+" />
<framework src="com.google.firebase:firebase-messaging:15.0.+" />
When using 15.0.0 above, the com.android.dex.DexException error was raised for some reason. By using + for the revision number (which means, latest), everything worked perfectly with cordova 7.1.0 and cordova-android 6.3.0.
Remember to remove and re-add the android platform after editing plugin.xml from plugins, otherwise your changes won't be applied at all!
Also: Ensure only ONE gradle file is applying this, just in case:
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.0.0'
}
I was also having this issue, I tried many ways to solve this issue. What worked for me was removing following line from my gradle.
compile 'com.google.firebase:firebase-core:16.0.3'
At first I have both firebase-core and firebase-ml-vision (what I need was only firebase-ml-vision) like following.
compile 'com.google.firebase:firebase-ml-vision:17.0.0'
compile 'com.google.firebase:firebase-core:16.0.3'
After I remove the line I got following warning,
Warning: The app gradle file must have a dependency on
com.google.firebase:firebase-core for Firebase services to work as
intended.
But, according to official docs the core dependency can be absent (https://firebase.google.com/docs/ml-kit/android/detect-faces), so it can be ignored.
i am implementing Admob mediation in my application details are here
when i trying to add inmobi in cause the below error for adding compile 'com.google.ads.mediation:inmobi:6.2.0.0'in gradle dependencies
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.google.ads.mediation:inmobi:6.2.0.0.
Could not resolve com.google.ads.mediation:inmobi:6.2.0.0.
Required by:
project :app
> No cached version of com.google.ads.mediation:inmobi:6.2.0.0 available for offline mode.
gradle file look like below
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v13:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.google.android.gms:play-services-ads:11.4.2'
compile 'com.google.android.gms:play-services-location:11.4.2'
compile 'com.google.android.gms:play-services-gcm:11.4.2'
compile('com.vungle:publisher-sdk-android:5.3.0#aar') {
transitive=true
}
compile 'com.google.ads.mediation:vungle:5.3.0.0'
compile 'com.inmobi.monetization:inmobi-ads:6.2.0'
compile 'com.google.ads.mediation:inmobi:6.2.0.0'
}
there is also option for manual integration link for get the adapter file but there is no such adapter with same version
can any one explain how to resolve this.
Go to Preferences in Android Studio
Go to Gradle tab and uncheck "Offline work" if it is checked
Check if your PC has active internet connectivity
Sync your project again & you are good to go!
The min version of InMobi adapter is 6.2.3 : Link
Replace the gradle dependency to look something like this :
compile 'com.google.ads.mediation:inmobi:6.2.4.0'
PS: 6.2.4 is backward compatible with 6.2.0
Try updating the adapter and you can find the dependencies here
Also, try adding inmobi alone and take out vungle dependencies.
I found the following question: Failed to resolve: com.android.support:customtabs:[26.0.0,26.1.0]
People marked it as duplicate (which is wrong ! see next sentence) or wrote something about Maven or cleaning project etc.
I have exactly the same problem for two days (failed to resolve customtabs and support-v4) and I did not change anything in my project which has been previously working. So I started looking for possible solutions and I found the problem - it is the OneSignal dependency - when I remove it, everything works fine. But I have already implemented notifications in my app - and don't know what to do now. I tried to compile the newest one (mentioned on OneSignal page)
compile 'com.onesignal:OneSignal:[3.6.0,3.99.99)'
But the result is same. Can anyone help?
UPDATE:
The problem can be very easy reproduced - please create a simple project and add this dependency mentioned below (it is from official OneSignal website https://documentation.onesignal.com/v3.0/docs/android-sdk-setup):
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
UPDATE 2:
These are my dependencies:
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.firebaseui:firebase-ui-database:1.1.0'
compile 'com.android.support:design:25.3.1'
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
Adding
maven {
url "https://maven.google.com"
}
to the build.gradle solved the problem with OneSignal, but now I have a problem with Firebase:
java.lang.NoSuchMethodError: No static method zzdD(Ljava/lang/String;)Z in class Lcom/google/android/gms/common/util/zzv; or its super classes (declaration of 'com.google.android.gms.common.util.zzv'
The error happens because you have some conflicted library in your dependency.
As in the documentation, it says:
Automatic Dependencies
OneSignal automatically adds the following dependencies;
com.google.android.gms - Version 11
com.android.support - Version 26
Please makes sure your project matches these versions if you run into
a mismatch version error.
For more details see the All gms/firesbase libraries must use the
exact same version specification section.
So, you need to remove or use the same dependencies in your project, something like this:
compile 'com.android.support:appcompat-v7:26.0.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-auth:11.0.+'
compile 'com.google.firebase:firebase-database:11.0.+'
compile 'com.firebaseui:firebase-ui-database:1.1.0'
compile 'com.android.support:design:26.0.+'
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
Remove 'f' from dependency. also, use [ brackets instead of ). its a typo.
dependencies {
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
}
and this code in your root gradle file
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
I was working my Android app for sending push notifications using Firebase cloud messaging. I was setting up my server referring the guide https://firebase.google.com/docs/server/setup#prerequisites.
My project level build.gradle is like :
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
}
App level build.grade :
dependencies {
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.firebase:geofire:1.1.0'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.firebase:firebase-server-sdk:[3.0.0,)'
compile 'com.google.firebase:firebase-core:9.0.0'
}
I have created the service account credentials on the console as well but while I am initializing the SDK referring https://firebase.google.com/docs/server/setup#add_the_sdk
FirebaseOptions options = new FirebaseOptions.Builder()
.setServiceAccount
(new FileInputStream("path/to/serviceAccountCredentials.json"))
.setDatabaseUrl("https://databaseName.firebaseio.com/")
.build();
I am getting compile Error:(116, 21) error: cannot find symbol method setServiceAccount(FileInputStream)
I have checked many places but I am unable to find what I am doing wrong. Any help would be highly appreciated.
In your server project you need to use only the dependency:
com.google.firebase:firebase-server-sdk:[3.0.0,) and remove:
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.firebase:firebase-core:9.0.0'
The first is a server sdk while the others are client sdk and they will have conflicts if you try to use them together.
You're including a different version of the Firebase Database SDK than what you have for the other Firebase features:
compile 'com.firebase:firebase-client-android:2.5.2'
If you change it to:
compile 'com.google.firebase:firebase-database:9.0.0'
It will work better.
For more information, see the Firebase documentation for Android developers, from where I copied the line above.
I am using ormlite in an Android project from Android Studio. I have configured Gradle to use it from Maven, like so:
dependencies {
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
However, when I launch the app it's giving NoClassDefFoundError for all ormlite classes. The same works if it is done by copying the jars to "libs/" folder.
Any idea why adding them from Maven doesn't work?
Try this on build.gradle:
dependencies {
compile 'com.j256.ormlite:ormlite-android:4.48'
...
}
The ormlite-core is a dependency that gradle will resolve by it's self. After editing, sync and rebuild you app, it should work.
If you want to put jar files in you libs folder, than your dependecies line from build.gradle will look like this:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
...
}