I dont know where I went wrong, but this keeps me saying
All com.android.support libraries must use the same exact version specification (mixing versions can lead to runtime crashes.) Found versions 24.0.0,23.2.0 Examples include com.android.support:animated-vector-drawable:24.0.0 and com.android.support:cardview-v7:23.2.0
my build.gradle is
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.example.project"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mani:ThinDownloadManager:1.2.2'
compile 'net.rdrei.android.dirchooser:library:3.2#aar'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.onesignal:OneSignal:3.+#aar'
}
apply plugin: 'com.google.gms.google-services'
It shows error in this line too
compile 'com.android.support:appcompat-v7:23.2.0'
I tried changing compileSdkVersion to 24 too, but nothing seems to work as of now. Actually everything was working fine before I introduced the play services library.
This dependency is using version 24.0.0 of com.android.support:animated-vector-drawable:
compile 'com.google.android.gms:play-services:10.2.0'
which will cause android studio to complain that it could lead to bugs/crashes because versions of all your google libraries don't match.
So you have 2 options: (that I know of off the top of my head)
Change your compileSdkVersion to 24 and change all your support library dependencies to version 24 as well to match the play-services dependencies:
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
Downgrade com.google.android.gms:play-services to 9.4 or 9.2.1 so that it doesn't use version 24 of anything. This still requires a minor change to your support libraries from 23.2.0 to simply 23.0.0
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.google.android.gms:play-services:9.4.0'
Related
I am trying to implement firebase into my project. But when the program run for the first time it shows this error :
java.lang.NoSuchMethodError: No static method isDeviceProtectedStorage(Landroid/content/Context;)Z in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/com.example.project-1/base.apk)
and below is my gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.project"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildToolsVersion "25.0.1"
sourceSets {
main {
aidl.srcDirs = ['src/aidl']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'src/main/jnilibs', include: ['.jar','.so'])
compile files('libs/gcm.jar')
compile files('libs/android-support-v7-recyclerview.jar')
compile files('libs/gson-2.7.jar')
compile files('libs/httpclientandroidlib-1.2.0.jar')
compile files('libs/logging-interceptor-3.0.1.jar')
compile files('libs/okhttp-3.0.1.jar')
compile files('libs/okhttp-urlconnection-3.0.1.jar')
compile files('libs/okio-1.10.0.jar')
compile files('libs/rollbar-android-0.1.3.jar')
compile files('libs/sherlocknavigationdrawer-1.0.jar')
compile files('libs/v7compat.jar')
compile files('libs/mpChart.jar')
compile files('libs/picasso-2.5.2.jar')
compile project(':actionbarsherlock')
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:support-v4:25.3.1'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
}
apply plugin: 'com.google.gms.google-services'
I've read somewhere else it may be due to lower version of v4 support library. so I had it changed to higher api level, but the problem still persist. Any solution to solve this problem??
Reason of this exception is AppCompatActivity derived from the v7 library. so we should provide proper library based on your gradle and SDK.
You should update the dependency Libraries also.
Right click on the project in the project structure -> select Open module settings and select dependencies tab -> Library module-> then type which library you want add to the project. It shows the latest libraries based on your gradle updated version, then select latest one and remove the existing one.
For example In my project "appcompat-v7" version was 23.4.0 then I was changed to 27.0.2 which is latest one
Or try to use
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.android.support:appcompat-v7:27.0.2'
i have the following error:
Build gradle file is following:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.bln.smc"
minSdkVersion 18
targetSdkVersion 23
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:23.4.0'
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.firebase:firebase-database:11.6.0'
compile 'com.google.firebase:firebase-storage:11.6.0'
compile 'com.google.firebase:firebase-crash:11.6.0'
compile 'com.google.firebase:firebase-auth:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
compile 'com.android.support:design:23.0.3'
compile 'com.firebaseui:firebase-ui:1.2.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:recyclerview-v7:23.0.1'
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
I researched a little bit and i think that the settings in the gradle file are ok.
So how can i solve this problem?
This is because you have conflicted dependencies in your build.gradle. Firebase UI need version 25 of support library but your dependencies is giving it version 23 instead.
If you want to use firebase-ui:1.2.0, you at least need to use support library version 25.1.1. Take a look at firebase-ui 1.2.0 build.gradle.
Then, you also need to use a compatible Firebase/Google Play Service version. For firebase-ui:1.2.0 you need to use Firebase/Google Play service version 10.2.0.
My suggestion is to use the latest configuration. Something like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.bln.smc"
minSdkVersion 18
targetSdkVersion 26
...
}
...
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
// This is needed for firebase UI
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:customtabs:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.google.firebase:firebase-core:11.4.2'
compile 'com.google.firebase:firebase-database:11.4.2'
compile 'com.google.firebase:firebase-storage:11.4.2'
compile 'com.google.firebase:firebase-crash:11.4.2'
compile 'com.google.firebase:firebase-auth:11.4.2'
compile 'com.google.firebase:firebase-messaging:11.4.2'
compile 'com.firebaseui:firebase-ui:3.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
I tried for many hours to find the solution but could not find. My problem is that when I build my Gradle I get two errors. I tried to look at this solution
Dependency conflict error in my Android app which has Android Tests but could still not solve the problem.
Error:Conflict with dependency 'junit:junit' in project ':app'. Resolved versions for app (4.10) and test app (4.12) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Conflict with dependency 'org.hamcrest:hamcrest-core' in project ':app'. Resolved versions for app (1.1) and test app (1.3) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Here's my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "voice.com.topsalai"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.3-
alpha', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'com.google.android.gms:play-services:10.2.4'
compile 'com.android.support:support-annotations:26.0.0-alpha1'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'com.android.support:support-v4:23.1.1'
}
How can I solve this?
dont use alpha..or beta.. just use the latest stable one..then please dont mix your android support version.. use same version for all android support
example
compile "com.android.support:appcompat-v7:25.3.1"
compile "com.android.support:cardview-v7:25.3.1"
compile "com.android.support:design:25.3.1"
compile "com.android.support:recyclerview-v7:25.3.1"
compile "com.android.support:support-annotations:25.3.1"
compile "com.android.support:support-v4:25.3.1"
compile "com.android.support:support-v13:25.3.1"
please remove this two dependency
testCompile 'com.android.support:support-annotations:26.0.0-alpha1'
androidTestCompile 'com.android.support:support-annotations:26.0.0-alpha1
I found the solution. By upgrading compileSdkVersion to
compileSdkVersion 25
And then Instead of this
compile 'com.android.support:appcompat-v7:23.1.1'
Only by updating appcompat-v7:23.1.1 did not solve it. I needed theese 3 lines of code.
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'
compile 'com.google.firebase:firebase-database:10.2.0'
After I added this dependency, the problem occurs. Before that, the GoogleApiClient works fine. I remove that dependency, the problem is solved. Do GoogleApiClient and Firebase have conflict about each other? Please help.
EDIT: Gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "application.id"
minSdkVersion 16
targetSdkVersion 22
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:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.firebase:firebase-database:10.2.0'
}
GoogleApiClient and firebase-database will work, if you add below dependencies,
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
firebase-database dependency will not affect GoogleApiClient
Please keep same versions for firebase & Google Play Services API(10.2.0)
Please re-check you have set up everything as below guidance,
https://firebase.google.com/docs/android/setup
this my problem over day, my log result is Error:(2) Attribute "titleTextStyle" has already been defined
my project use actionbarsherlock, google_play_service, and another lib, i want to move my old project to android studio. i already tried many link in this site but doesn't work. this my gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.ltvie.test"
minSdkVersion 9
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile project(':lib')
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.code.gson:gson:2.1'
compile 'com.google.guava:guava:11.0.1'
compile 'com.google.protobuf:protobuf-java:2.2.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:18.0.0'
compile files('libs/google-api-client-1.10.3-beta.jar')
compile files('libs/google-api-client-android2-1.10.3-beta.jar')
compile files('libs/google-http-client-1.10.3-beta.jar')
compile files('libs/google-http-client-android2-1.10.3-beta.jar')
compile files('libs/google-oauth-client-1.10.1-beta.jar')
compile files('libs/jackson-core-asl-1.9.4.jar')
compile files('libs/json-org.jar')
compile files('libs/jsr305-1.3.9.jar')
compile files('libs/universal-image-loader-1.9.3-SNAPSHOT.jar')
compile files('libs/WebSocket.jar')
}
i read some tutorial that my problem cause I use appcompat-v7 and actionbarsherlock in same time, but in my dependencies nothing appcompat-v7, i try to remove actionbarsherlock then the error disappear but appear more error. how to solve my problem, thanks.