I tried to add a CardView in my app so I added the following dependency in my gradle
compile 'com.android.support:cardview-v7:22.2.1'
I realised that an error is caused because I have given the wrong version number. After taking a look at the official google docs I came to know that Android Support Repository is used to hold appcompat libraries.
As you can see the Support repository that I have installed is version 33. But if I change my gradle to version 33 it is still showing error.
How can I check what version of AppCompatLibrary I have in android studio?
EDIT:
build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 22
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.spintum.preexam"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
// compile fileTree (dir:'libs',include:'achartengine-*.jar')
//compile fileTree('libs/achartengine-1.1.0.jar')
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:percent:22.2.0'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:cardview-v7:+'
//compile 'com.android.support:recyclerview-v7:22.2.+'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.github.markushi:circlebutton:1.1'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32#aar'
}
Check your SDK folder and see which is the highest existing number:
e.g
B:\android-sdk\extras\android\m2repository\com\android\support\appcompat-v7
There will be a folder for each installed version. At the time of writing, 24 is the latest version.
Update:
Now Google use their own Maven repository, this no longer works.
Instead, check this site for the available versions.
https://maven.google.com/
It is not about the installed version of the Android Support Repository.
The version that should be in the Gradle Build Files should be the number highest version corresponding to your
compileSdkVersion
in your AppLevel Gradle Build File.(by default it is the app module).
Example:
If you are using compileSdkVersion 23 , then you should check your following directory for the highest 23.x.x folder.
\ YOUR-SDK-PATH
\extras\android\m2repository\com\android\support\cardview-v7
Suppose that your highest number starting from 23 is 23.4.0 , then you should use this version number(23.4.0 replacing the 33.0.0) for your Gradle Build File(Not the verison of Android Support Repository Installed).
It means you have to use the Android Support Repository Libraries according to your compileSdkVersion.
The easist way is to use + which means the newest one (of the API level) on your machine, then you do not need to check the SDK folder anymore. e.g.,
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.android.support:support-v4:21.+'
However, there is an warning void using 21.+ ....".
Related
I am integrating Firebase Database and Authentication to my Android Project. I get the following error:
Error:org.gradle.api.GradleException: Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.4.0.
My app build.gradle file is below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.antoinecampbell.firebase.demo"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:cardview-v7:24.1.1'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.google.android.gms:play-services-auth:9.2.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
I know that I am mixing old and new version of dependencies, but can't figure out how to solve it.
I will try to make this question as helpful as I can by editing it later.
You need to add a dependency to Google-services to your root build.gradle. This file is different from your app/build.gradle one. Follow the Official Documentation to see exactly how your build.gradle and app/build.gradle file should look like.
Also Firebase and Play-services need to be on the same version number. So change the dependencies to have at least the same version number.
I'm trying to make an app using the android support library, so if I start a new project with a basic activity, then add the android support library using the dependencies menu, I get this error:
This support library should not use a different version (24) than the `compileSdkVersion` (23)
This is what my gradle file looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.example.moore.criminalintent"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:24.0.0'
}
I've not touched any other settings apart from creating the project and adding the dependency. Any help in resolving this would be greatly appreciated.
Since you are using the support libraries v24.
compile 'com.android.support:support-v4:24.0.0'
You have to compile with API 24. Use:
compileSdkVersion 24
Change compile 'com.android.support:support-v4:24.0.0' to compile 'com.android.support:support-v4:23+' (and optionally provide a sub version. The plus means the latest version of 23.something will be used).
This error is caused because you are compiling against API version 23 (android M), so you cannot use the support library version 24. Version 24 of the support library is for the recently released Android N developer preview, from my understanding.
Alternatively, you could of coarse increase your compile SDK version to 24.
If your using compile SDK version 24 than you should use it as
compile 'com.android.support:support-v4:24.0.0'
I just installed Android Studio for a new class and I can't even run a HelloWorld program. There are no third party dependencies as I literally just installed Android Studio, SDK version 16, the latest support repository, latest build tools, and created a Nexus 5 AVD running 4.1.2 (16). I keep getting
"Error:(24,13) Failed to resolve: com.android.support.appcompat-v7:16.+"
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 16
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "edu.usna.mobileos.hellooooworld"
minSdkVersion 16
targetSdkVersion 16
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:16.+' // line giving me the error
}
I've tried many other solutions I've found online, but none have worked so far. I need to work with API version 16 (Android 4.1.2) in this class, so using a newer API isn't an option.
It happens because the 'com.android.support:appcompat-v7:16.+' doesn't exist.
Use the latest version and pay attention using the + because it is not a good option.In this way you will not be able to replicate the build in the future.
I need to work with API version 16 (Android 4.1.2) in this class, so using a newer API isn't an option.
Don't confuse minSdk and the compileSdk.
The compileSdkVersion is your way to tell Gradle what version of the Android SDK to compile your app with.
If compileSdkVersion sets the newest APIs available to you, minSdkVersion is the lower bound for your app. The minSdkVersion is one of the signals the Google Play Store uses to determine which of a user’s devices an app can be installed on.
More info here.
You can use one of these versions.
Check your sdk for updated version:
//it requires compileSdkVersion 23
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.0'
//it requires compileSdkVersion 22
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:appcompat-v7:22.0.0'
//it requires compileSdkVersion 21
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:appcompat-v7:21.0.0'
Also there are very old version:
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.0'
compile 'com.android.support:appcompat-v7:18.0.0'
Inside Android Studio click the icon below to open the SDK Manager:
From there you should see something like this:
You want to update and/or install Android Support Library. You also may need to update the version your build.gradle file is pointing to. For example, the version I have is 23.1.0, so my reference would look like this:
compile 'com.android.support:appcompat-v7:23.1.+' // line giving me the error
I use Android Studio to build my android application. But my laptop take 5 mins to build app. I don't know why. It's always load to build gradle too slow. Here is my code Build Gradle :
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
repositories { mavenCentral() }
defaultConfig {
applicationId "thsoft.com.sosme"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.wang.avi:library:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.jakewharton:disklrucache:2.0.2'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.crittercism:crittercism-android-agent:5.5.0-rc-1'
}
Could you help me to solved it? Thank you!
There is nothing wrong with the gradle code, but way too many dependencies. It depends on your processor's speed and memory. Try getting 8gb of memory and you'll be just fine. According to official site, minimum requirement is 4gb!!
Try enable offline mode to ignore up-to-date checks:
http://tools.android.com/recent/androidstudio040released
Or change build type to Debug :
Build Variants - > Debug ( Bottom Left corner AS)
Gluck!
Install the latest Android Studio 2.0 preview release. Its just awesome and it will reduce the gradle build time for sure. Let's try
to increase your build time you just need to increase your RAM
and in your gradle file remove those dependencies which are not required.
You have used play services which is huge. If you are using Google Cloud Messaging use com.google.android.gms:play-services-gcm:8.3.0. definitely it will reduce your build time. Don't put whole play services. Be specific which play service you are using.
this Link may help you https://developers.google.com/android/guides/setup
Good Luck
I'm hoping someone might shed some light on this issue. I am trying to change the support library versions from:
compile 'com.android.support:support-annotations:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:support-v13:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
to
compile 'com.android.support:support-annotations:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:support-v13:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
What usually seems like a simple minor upgrade has caused me the entire day. Basically upon updating the gradle.build file, I sync -> clean, and there appears a bunch of Cannot Resolve Symbol errors appearing on the IDE for classes from the support library.
What's further interesting about this is that if I try to run the code on my phone through adb, despite AS showing up as "Cannot resolve symbol", it runs perfectly fine on my phone.
Among the things I've tried:
Clean / Rebuild
Invalidate cache / restart
Delete all the .iml files and the .idea folder
Reinstalling of Android Studio, reimport of project
Rebooting
Digging further into the build directory, they are similar in the sense that both
build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.0\jars\classes.jar
and
build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\jars\classes.jar
were generated respectively. What's different is that in AS, for the previous version, the "classes.jar" can be opened in AS where as with the new version, they cannot be opened in AS.
I feel that I have pretty much exhausted all available options so if anyone can shed some light on how to resolve this, I would really much appreciate it.
My full gradle.build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.XXX"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.1.1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(path: ':XXX', configuration: 'android-endpoints')
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.4'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.balysv:material-ripple:1.0.2'
compile 'net.sf.flexjson:flexjson:3.3'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.google.android.gms:play-services-ads:8.1.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile 'com.android.support:support-annotations:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:support-v13:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
}
I have finally solved:
First of all, I updated the gradle plugin.
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
Then just Build->Clean project and everything works again.
I think I have solved this problem guys. Go to the main module in your project, it's usually have the name app.
Then go to > Open Module Settings > in Properties change the Build Tools Version to 23.0.1.
Then to make sure open the build.gradle file, and change compileSDKVersion & buildToolsVersion to 23 and 23.0.1 respectively.
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "id.web.twoh"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
You should also make sure that all modules in your project have the compileSdkVersion and buildToolsVersion begin with 23, as you will use the 23th version of the support library.
I know it's late but I had a similar issue. It turned out that the issue was caused by the Data binding library. I had an error in the code that referenced in an invalid reference in the generated binding class. My layout file defined a webview with id webview but in the code I referenced it as webView. After correcting the error and cleaning and doing full rebuild Android Studio started recogninsing all the packages and seeing support libraries.
I had exactly the same problem, and to solve it I have just changed the BuildDebug Configuration spinner to MainActivity :
I solved my problem by changing the Run/Debug Configuration spinner to MainActivity (instead of app[androidDepedencies]) in the ToolBar...