Adding Google Play Services to gradle (Android Studio) does not work - android

I have the following problem:
I installed the Google Play Services library v27.0.0 to my SDK in Android Studio.
After that I added the compile dependencie to build.gradle (app folder):
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.google.android.gms:play-services:27.0.0'
}
But when I try to sync the project with Gradle, i get this error message:
Error:(25, 13) Failed to resolve: com.google.android.gms:play-services:27.0.0
I don't know what to do...

I don't think version 27.0.0 exists the most recent version is 8.1.0

There is one trick you can use with any dependency.
You know the name of dependency, lets consider com.google.android.gms:play-services:
Firstly, you need to use this expression
compile 'com.google.android.gms:play-services:+'
Note the plus sign. Than you click Sync Now to sync gradle. After that you will see that IDE suggests you not to use + sign.
But now you can use combination Alt+Enter and select Replace with specific version.
Now + sign will be replaced with the latest available version of this library.
Profit.

Related

compile 'com.android.support:multidex:1.0.1' happened wrong: all com android support libraries must use the exact same version

Today, I update my Android studio to 2.3, and I update gradle to 3.4.1. But when I build my project, an error occurred:
This is the error
So I add " buildToolsVersion '25.0.0' "
My project can build successful, but another error occurred. I can't solve it. I hope to get some help. Thank you!
This is the error
When I add compile 'com.prolificinteractive:material-calendarview:1.4.2', this error will occur.
This is my androidDependencies
This is probably an issue with Android Studio 2.3. There's a new inspection that checks if all dependencies of com.android.support use the same version number. However, multidex doesn't have a matching version number. You can disable the inspection via the red light bulb icon next to it as a work-around for now
it's an unnecessary warning for the support:multidex, add this:
//noinspection AndroidLintGradleCompatible
compile 'com.android.support:multidex:1.0.1'
I'm also using updated Studio. You should use each library with the same version in order to avoid the Manifest Merger issue. Like this.
// To Support Design, CardView and RecyclerView Library
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:palette-v7:25.2.0'
// To Support MultiDex
compile 'com.android.support:multidex:1.0.1'
Here you will notice that each library have the same version.
Change version of com.android.support:recyclerview-v7 and com.android.support:support-core-utils to 25.2.0 (last version of support library: https://developer.android.com/topic/libraries/support-library/revisions.html)

How to resolve Theme.AppCompat.Light error

I am facing a issue after run existing android studio project. Please check error below and let me know how to resolve that.
Error:(54) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
Thanks in advance
Try to use accroding gradle plugin. I've got the problem with plugin 2.3-beta1 and Studio 2.2.3, when changed to plugin 2.2.3 - everything worked like a charm
Please change compileSdkVersion and buildToolsVersion in your gradle file according to your android studio existing running project.
Our compile SDK version must match the support library's major
version.
If you are using version 23 of the support library, you need to compile against version 23 of the Android SDK.
Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22.
You can either change it manually in your build.gradle, or you can use
the GUI by opening up the project properties and going to the
"dependencies" tab.
Or Press Ctrl + Shift + Alt + S to get to the project structure page. Go to the properties tab and change version to 23.0.0 or whatever latest in the build tool area and rebuild your project.
If that doesn't work, go to gradle:app and then
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
Edit version as shown above and sync gradle.
Ran into same issue as OP, March 2017 Android Studio 2.3.
My build was working fine for months, and this issue came up right after adding a new line to gradle build file. Ultimately making some changes in Gradle and re-sync'ing fixed the issue, but my Gradle ended up being exactly the same as when the issue first came up, strangely.
My original Gradle build dependencies:
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:gridlayout-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.google.android.gms:play-services-location:10.0.0'
compile 'com.google.android.gms:play-services-maps:10.0.0'
compile 'com.google.maps.android:android-maps-utils:0.5'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.4'
Then, I simply added a new line:
compile 'org.scribe:scribe:1.3.5'
This is when the issue appeared, same as OP.
I saw red errors in my styles.xml and wondered "wtf?".
Cleaning and re-building had no affect.
Going back to the Gradle build file, I commented-out that new line. ISSUE RESOLVED! So obviously there was something going on.
For fun, I put that line, uncommented, at the top of this compile list. NO ISSUE!
For fun yet again, I put that line back again to the bottom of the list (like how originally added it). NO ISSUE.... weird!
How Gradle sync'ing responds doesn't seem to be 100% consistent. I did no other changes to my project. All I can say is try toggling and re-ordering things in the compile list.

What version of recyclerview should I use in dependecies?

I want to include recyclerview in my application , I've updated the whole sdk . The android support repository is version 17 ,android support library is version 23 . I've recyclerview folder in sdk\extras\android\support\v7 directory .
For adding the library , I've put these in dependencies :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0.+'
}
when I rebuild the project ,it shows me this error :
Error:(24, 13) Failed to resolve: com.android.support:recyclerview-v7:21.0.0.+
Install Repository and sync project<br>Show in File<br>Show in Project Structure dialog
What version of recyclerview should I use in dependencies ? How to know it?
EDIT
I solve the last problem with the help of a friend , this is the new gradle :
dependencies {
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0'
}
Now I get this error :
F:\AndroidStudioProjects\recycleView\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.0\res\values-v17\values-v17.xml
Error:(6, 21) No resource found that matches the given name: attr 'android:textAlignment'.
Error:(10, 21) No resource found that matches the given name: attr 'android:paddingEnd'...............
How to solve this one ?
You have this issue becuase
compile 'com.android.support:recyclerview-v7:21.0.0.+'
is wrong.
You can use
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.+'
compile 'com.android.support:recyclerview-v7:+'
But you can't use
compile 'com.android.support:recyclerview-v7:21.0.0.+'
Of course I suggest you using the last support library, currently the 23.1.0
compile 'com.android.support:recyclerview-v7:23.1.0'
Pay attention. This requires to compile with API 23.
Also I suggest you avoiding the +. It is not a good choice because in this way you can't replicate your build in the future.
Better to use the latest dependency supported by android to get the latest feature and fixes provided by Android. To add a dependency follow the steps mentioned below :
Right click on your app module in project explorer.
Select "Module Settings" from the option menu.
Click on the "Dependency" tab.
Click the "+" or "-" button to add or remove dependency.
Click on + and search for dependency by giving it's name and click on the appropriate dependency.
This way you will get the latest dependecy supported by android.
use 23.0.0
compile 'com.android.support:recyclerview-v7:23.0.0'

How can I add BaseGameUtils to Chrome Cast project?

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)

add android-support-v13.jar in Android Studio

I have been trying to add android-support-v13 in Android Studio 1.0.2
I have followed the steps here but I still get a build fail. Has anyone successfully managed to add android-support-v13.jar into Android Studio 1.0.2?
Below is my code in my gradle file.
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile fileTree(dir: 'libs',include: '*.jar')
Edit: I have installed extra support library from SDK manager and I have placed the .jar in my libs folder.
according to docs at this time:
The Gradle build script dependency identifier for this library is as
follows:
com.android.support:support-v13:18.0.0
lets hope that the docs are updated.
for the latest you should use:
compile 'com.android.support:support-v13:21.0.+'
same problem android studio 1.0.2 i solve that below
compile 'com.android.support:appcompat-v7:21.0.1'
compile 'com.android.support:appcompat-v7:+'

Categories

Resources