Trying to build Google Maps Android API utility library, I have SDK 23 installed and all the right SDK tools. At first when i imported the project I wasn't able to run it, the run button was greyed out. I then added "apply plugin: 'com.android.application'" to the top of gradle file. Then when i try to compile, I get the Failed to resolve: com.google.maps.android:android-maps-utils:0.4+ error in my build gradle(module: library).
dependencies {
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4+'
}
dependencies section in original android-maps-utils-master/demo/build.gradle contains:
dependencies {
compile project(':library')
// Or, fetch from Maven:
// compile 'com.google.maps.android:android-maps-utils:0.3+'
compile 'com.google.android.gms:play-services-maps:8.4.0'
}
So:
You may use it as it is. Library android-maps-utils will be compiled from "compile project(':library')". It works for me. Or
You may comment "compile project(':library')", then uncomment "compile 'com.google.maps.android:android-maps-utils:0.3+'" and the library will be downloaded from maven repository. But )
Gradle has no idea where it is. So you should add the followilg code:
allprojects {
repositories {
mavenCentral()
}
}
into the file android-maps-utils-master/build.gradle
This actually works:
Comment out the other dependencies where any google Api is called.
Specifically, firebase ( compile 'com.google.firebase:firebase-ads:9.0.1' ) and gms( compile 'com.google.android.gms:play-services-maps:9.0.1' ).
Now go for 'Sync Now'.
You may encounter some other error, like some value is missing.
Ignore the errors, uncomment the commented dependencies and Voila! It all has been figured out by our dear Gradle!
Related
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 added the following line to my build.gradle(Module:app):
compile 'com.android.support:design:25.4.0'
But when executing Gradle I'm getting
Failed to resolve: com.android.support.design:25.4.0
I got that the support code from the android support design library and added it to a new project. I added it to the dependency section as such:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.4.0'
}
Any ideas on what I'm doing wrong?
Important: The support libraries are now available through Google's Maven repository. You do not need to download the support
repository from the SDK Manager. For more information, see Support
Library Setup.
Step 1: Open the build.gradle file for your application.
Step 2: Make sure that the repositories section includes a maven section with the "https://maven.google.com" endpoint. For example:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Step 3: Add the support library to the dependencies section. For example, to add the v4 core-utils library, add the following lines:
dependencies {
...
compile "com.android.support:support-core-utils:25.4.0"
}
A more updated version of the answer of "Bhavesh Patadiya" :
In your project build.gradle file, add google() into the repositories blocks:
repositories {
jcenter()
google()
}
Update the same file with a newer Gradle version:
classpath 'com.android.tools.build:gradle:2.3.3'
If the above cause you new issues or the same issue, exit Android-Studio, and delete the "gradle" folder/s (maybe also ".gradle" folder) and the "build" folder and sub-folders, and then open Android-Studio again.
Mr. Bhavesh Patadiya give us a good solution. However, I'd like to share something more, to make fix process more explicit.
There are two "build.gradle" files under the project directory. Their pathes are to be "Your-project-root-dir/build.gradle" and "Your-project-root-dir/app/build.gradle" respectively. When you see the error information in your android studio, and try to trace the file, you will probably open the second one.
You should add this statement in the first file ("Your-project-root-dir/build.gradle").
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
and add the statements in the second build.gradle ("Your-project-root-dir/app/build.gradle")
dependencies {
...
compile "com.android.support:support-core-utils:27.0.2"
}
Always keep appcompact version and support lib versionssame, so change com.android.support:design:25.4.0 to com.android.support:design:25.3.1
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
You need to update the android support Repository in the SDK manager . Also the Design Library depends on the Support v4 and AppCompat Support Libraries.
Same version android support must be the same with others..
compile 'com.android.support:appcompat-v7:25.3.1' <-- same
compile 'com.android.support:design:23.3.1' <-- same
after adding :
maven {
url "https://maven.google.com"
}
make sure your Gradle sync is on ONLINE mode
you can check it from:
Android studio -> Preferences -> Build, Execution, Deployment ->
Gradle -> Offline work (make sure this check box is not selected)
This problem occurs when there is andoridtestImplementation is added in app.build.
Remove testImplementation,androidTestImplementation from the app.build, that solves this issue.
Above answers did't resolve anything for me.
Tried syncing the project- Failed.
Tried building the project -Failed
Problem found :
Sdk Support Repository was corrupted
.
Fix:
Go to the SDK manager, click the "SDK Tools" tab. If the check-mark
for "Support Repository" is selected, unselect it and click OK. This
will delete all of the files in the repository. Then recheck the
check-mark, click GO and reinstall the repository.
If you still have the issue, check the project settings for offline mode. if offline mode is on, then off and sync the project. That fixed my issue.
There is no library by that name. There is com.android.support:recyclerview-v7:25.4.0.
Failed to resolve com.android.support:support-compat:25.4.0
Failed to resolve com.android.support:support-core-ui:25.4.0
I am trying to include this library to my project by adding
compile 'jp.wasabeef:recyclerview-animators:2.2.7'
so remove this line from gradle
my error just resolved
i have created an android library AAR in android studio 2.1.3 in which i use the following dependencies:
compile 'com.google.android.gms:play-services-vision:9.4.0+'
compile 'com.google.android.gms:play-services-wearable:9.4.0+'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
now i am using this aar in an application but those dependencies were failing unless i add them to the dependencies of the new app.
i search here and i found that i need to add the following line:
compile (project(':LIBNAME-release')) {transitive = true}
but this didn't work. is there something i missed? or is it related to the obfuscation i did to the aar file? or is it a must to add these dependencies to the app?
Try to compile you project first:
dependencies {
compile project(':Name-Of-Your-Project')
}
This is Ashton Engberg's suggestion from that post
I updated Android Studio 2.0 Preview from 4 to 5 this morning. If I continue to build with:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
}
this will still compile successfully. But if I move up to -alpha5 I get this error:
Error:Execution failed for task ':app:compileReleaseJavaWithJavac'.
java.io.FileNotFoundException: C:....\intermediates\exploded-aar\com.google.android.gms\play-services\8.4.0\jars\classes.jar (The system cannot find the path specified)
From now on, I think Google expects us to not use this:
'com.google.android.gms:play-services:8.4.0'
But rather add the services you need specifically. Find a list of them here
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-appinvite:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-drive:8.4.0'
Also, you need to apply play service plugin in last line of your application's gradle:
apply plugin: 'com.google.gms.google-services'
I posted a bug here. They came out with a fix very quickly. Now just use alpha6:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
}
I am following the Getting Started, Facebook Android SDK.
But when I am adding the repositories and the dependencies, I get the following error:
Error: Module version com.facebook.android:facebook-android-sdk:4.1.0 depends on libraries but is not a library itself.
I tried with several versions of the SDK but I can't make it work.
This is how my gradle looks:
dependencies{
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
repositories{
mavenCentral()
}
I am using the BuildTools 22.0.1
I hope someone can orient my with this issue.
Regards
compile 'com.facebool.android:facebook-android-sdk:4.1.0' Is the facebool correct or is that an error? If that's an error then that could be your issue. Also if you can't get it to compile from a maven source try downloading a jar and putting it in your local library. Then go into the project structure and go to the module you want to add this library to and click on the dependencies tab and there is a plus icon to add a library from file.
In you build.gradle(Project:Your-Project-Name) replace jCentral() with mavenCentral() in both (allproject/repos and buildscript/repos) then sync your gradle.
Hope this helps.