I have an existing app which I have unfortunately haven't had time to update it in quite a long time. I am now trying to do some work on it but it won't compile.
It was originally an Eclipse project so I've now imported it into Android Studio, my build.gradle has the following:
dependencies {
/*compile 'com.google.android.gms:play-services-ads:7.0.0'
compile 'com.google.android.gms:play-services-drive:7.0.0'
compile 'com.google.android.gms:play-services-identity:7.0.0'*/
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/android-support-v4.jar')
compile files('libs/commons-codec-1.4-javadoc.jar')
compile files('libs/commons-codec-1.4-sources.jar')
compile files('libs/commons-codec-1.4.jar')
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.BoardiesITSolutions:CritiMon:1.0'
compile 'com.BoardiesITSolutions:Library:1.1'
compile 'com.google.android.gms:play-services:4.1.+'
compile('com.google.api-client:google-api-client-xml:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.http-client:google-http-client-gson:1.17.0-rc'
compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.apis:google-api-services-drive:v2+'
}
I am trying to point it at the old versions of Google Play Services, the bit of code below which was originally working but now it no longer is.
Drive service = getDriveService(credential);
String fileId = null;
FileList file = service.files().list().execute();
The problem is services.files() cannot be resolved.
I am assuming this is because of the Drive API being updated so is there a way that I can use the previous version that supports the above code.
At the moment I don't have time to update the Drive API but I need to fix a bug that someone's reported.
Update
I've found the following https://developers.google.com/drive/web/migration page which says that there aren't any real changes apart from a variable name for the file id but everything is the same so I don't understand why the service.files() function wouldn't be found.
To consolidate the comments (esp #kroikie) into an answer, you have confused the Java library for the REST API (which can run on Java/Android and is represented by com.google.api.services.drive.Drive) with the Google Drive API for Android ("GDAA" - which simply reads and writes to the Drive storage area on Android and lets the Android Drive app do the syncing, and is represented by com.google.android.gms.drive.Drive).
This guy The method permissions() is undefined for the type Drive has done the same thing, which suggests that the Google documentation is failing to make it clear that there are two different ways that Android-Drive integration can be achieved. I've seen people refer to the REST API as the "old api", which is a complete misnomer and suggests that some people have drawn the false conclusion that GDAA replaces the REST API which it most certainly doesn't.
So in your case, expunge com.google.android.gms.* from your app and you'll be fine.
Related
I am upgrading an App, and in my build.gradle file, I have this:
dependencies {
..........
compile 'com.google.android.gms:play-services:9.8.0'
..........
}
In the Android SDK Setup Quickstart Guide Urban Airship provides, they offer this as a sample code:
dependencies {
..........
// Recommended for location services
compile 'com.google.android.gms:play-services-location:9.8.0'
..........
}
If I use "play-services:9.8.0" I would assume it would also include "play-services-location:9.8.0" because "play-services-location:9.8.0" should be a subset of "play-services:9.8.0", but I wanted to confirm. Do you know if this is a correct assumption? Thank you.
From Google Api Documentation
you can use the latest Google play service api:
dependencies {
compile 'com.google.android.gms:play-services:10.2.1'
}
If the number of method references in your app exceeds the 65K limit, your app may fail to compile. You may be able to mitigate this problem when compiling your app by specifying only the specific Google Play services APIs your app uses, instead of all of them.
To Selectively compiling APIs into your executable:
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.android.gms:play-services-plus:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-games:10.2.1'
compile 'com.google.android.gms:play-services-gcm:10.2.1'
the detail lists are provided in the documentation.
Yes, play-services is the full bundle. They were broken apart to reduce the method count of your app so you don't hit the dex limit. More information can be found here.
I'm trying to use the new Awareness API in an app but the only way that I can include it in my code is by using
compile 'com.google.android.gms:play-services:9.2.0'
in my gradle file.
I tried using
compile 'com.google.android.gms:play-services-awareness:9.2.0'
but it doesn't seem to exist.
Does anyone know what the correct compile path for selective compile of the awareness API is?
Thanks in advance.
It actually does exist.
//Awareness API
compile 'com.google.android.gms:play-services-contextmanager:9.2.0'
Today you have to include:
compile 'com.google.android.gms:play-services-awareness:10.2.4'
If you want to know the latest Dependency you can use my web tool called DependencyLookup.
I'm new to Gradle and I need to make sure that my Android project has the latest dependencies with regards to RxAndroid and RxJava. Forgive me for my ignorance but could someone explain how I go about to make sure that the libraries I include in my project are the latest ones? Where does Gradle downloads these libraries from? Is there a central repository? Is GitHub the source? It's not clear from the code shown below:
build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'io.reactivex:rxjava:1.0.14'
}
I would really appreciate if someone could shed some light with regards to this topic.
Gradle downloads them from Maven or other repos. I don't believe GitHub hosts the libraries themselves, but the link to download the libraries could be found on GitHub.
To ensure they are the latest version, you will have to go the library's web page(Git hub page usually) and check if a latest version has been released.
If I am not wrong, you could add a + sign at the end and when you sync Gradle with work in offline mode turned off, it should fetch the latest version of the library.
Eg:
compile 'com.android.support:appcompat-v7:23.3.0+'
compile 'io.reactivex:rxandroid:1.0.1+'
The above line will ensure that 1.0.1 is the min version that you will download and if there are any higher version, it will download that instead.
WARNING : this is not a safe thing to do, because the latest version of library will be automatically downloaded and the changes in the newer version of the library might have breaking changes, and break your app. For instance the methods you use from a library might be removed in the new library or even worse things could happen and it has to me. I suggest you set some time apart once every few weeks and see if there are new updates and consider if it is safe to update.
Deciding to add a library to your project must be carefully thought through, as you are making the project dependent on it and if that library dies out or is buggy, your project too will be screwed. Incase you didn't, I suggest you read this on how being careless with adding dependencies literally broke the internet.
You can just add a plus to the end of each, although it's not recommended as sometimes new libs will break your code.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0+'
compile 'io.reactivex:rxandroid:1.0.1+'
compile 'io.reactivex:rxjava:1.0.14+'
}
Here are the latest:
dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'io.reactivex:rxandroid:1.2.0' // Upgraded
compile 'io.reactivex:rxjava:1.1.5' // Upgraded
testCompile 'junit:junit:4.12'
}
check here
This question already has answers here:
Google Play: We found Ad SDKs in your application
(5 answers)
Closed 7 years ago.
I've got an Android application that is being submitted to the Play Store. That application is built using the same Gradle build script but has several different product flavors being built which just set properties for different application ID's and names for each different flavor.
The problem we have is that AdMob is 'not' included in the build script, but some of the build flavors that are being submitted the Play Store is reporting that AdMob was found in the application. But other flavors (built from same build script) are accepted fine without any AdMob notification.
Has anyone seen this issue and possibly know what might be triggering it? Besides our own internal libraries, this is what's being included in the dependencies of the build script:
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile group: 'com.android.support', name: 'support-v4', version: '21.0.3'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.google.android.gms:play-services:6.5.87'
// ViewPagerIndicator Library
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile fileTree(dir: 'libs', include: '*.jar')
}
I've checked the 'libs' directory but we only have 3 jar files in it that have just some included class files so there isn't any SDK's in that directory.
This is what the Play Store is reporting:
In your gradle build script you have:
compile 'com.google.android.gms:play-services:6.5.87'
This means that all Google play services are included into your project (including AdMob as well).
Instead, you should include only play services that you need. For example:
compile 'com.google.android.gms:play-services-fitness:8.3.0'
compile 'com.google.android.gms:play-services-wearable:8.3.0'
Take a look at this guidelines.
You are using Google Play Services which includes Admob.
You can exclude Admob by only referencing the Google Play Services libraries you actually require instead of the complete set.
More details here on how to do that:
More Permissions in uploaded apk than in manifest file
I'm trying to add a Leader Board to a Chrome cast project and am getting errors. Android project in Android Studio. In my gradle build - Error: more than one library with package name 'com.google.android.gms'
I understand why you don't want to use two different libraries with the same name, but not sure how to use the same library throughout the project. Here are the two uses of gms:
1) Main activity has dependency on 'CastCompanionLibrary-android-master' which then uses google-play-services_lib. I'm not sure which version of gms this uses, but the version number is referenced in the manifest. Is this just grabbing the version # of play services that they have installed on their phone?
2) BaseGameUtils - has dependency on com.google.android.gms:play-services:+ (I think this is grabbing the most recent version of play-services, but doesn't match the other one.
MainActivity gradle file
dependencies {
compile project(':BaseGameUtils')
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':CastCompanionLibrary-android-master')
}
CastCompanionLibrary-android-master dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':android-support-v7-appcompat')
compile project(':android-support-v7-mediarouter')
compile project(':google-play-services_lib')
}
BaseGameUtils dependencies {
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services:+'
}
So, the problem (I think) is these two versions of com.google.android.gms, but how do I rectify it so that they all use the same version. I've had almost 2 years of working with Android, but this is my first question on stack overflow. Help is appreciated - Is there a guru out there that has the answer to this?
Seems like you have modified the gradle file for CCL since what you have there does not match with what CCL has in GitHub. The best approach is to only use the piece of play services that you need; for example CCL only needs the play-services-cast (besides the base, which will be pulled in automatically) so if you follow that pattern, things would look smaller (less possibility of running into the 64K dex limit) and less collisions.CCL, in Github, lists its dependency as:
compile 'com.google.android.gms:play-services-cast:6.5+' so you might want to start using versions and also follow the recomendation I just made (same applies for any other code that you have and uses play services; just pull in what you really need)