Error in adding dependency in android - android

When I have following code gradle is build successfully.
ext {
supportLibVersion = '23.2.1' // variable that can be referenced to keep support libs consistent
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile 'pl.pawelkleczkowski.customgauge:CustomGauge:1.0.1'
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
}
But when I added below dependency it stated giving me error.
compile 'com.afollestad.material-dialogs:core:0.8.5.9'
error
Error:Failed to resolve: com.android.support:appcompat-v7:23.4.0
Install Repository and sync project<br>Open File<br>Show in Project Structure dialog
Any suggestions.
Thanks
complete gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.zriton.udhaar"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
ext {
supportLibVersion = '23.2.1' // variable that can be referenced to keep support libs consistent
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile 'pl.pawelkleczkowski.customgauge:CustomGauge:1.0.1'
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.afollestad.material-dialogs:core:0.8.5.9'
}

You don't have the latest version of Google's libs installed. 23.2.1 should be 23.4.0.
The solution is at the bottom, "Install Repository"

Sounds like you need to install the "Android Support Repository" in the Android SDK Manager.
If you have the android tools on your path, just go to the Terminal and run:
$ android
You can also access it via Android Studio > Tools > Android > SDK Manager.

The support library that you are using is 23.2.1, but in error it is showing 23.4.0, replace your current version to 23.4.0 and try to sync project

Related

all android support libraries must use exact same version not working

Edit : i also this post
All com.android.support libraries must use the exact same version specification
i upgrade downgrade multiple version of android support libraries . but i am constantly getting this error . specially on these lines
compile 'com.android.support:cardview-v7:21.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
i clean and rebuild multiple times , but that is not solution
there is no specifically any solution which i got except changing library version .
this is app gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.2'
defaultConfig {
applicationId "com.codepath.the_town_kitchen"
minSdkVersion 27
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
}
signingConfigs {
debug {
storeFile file("keystore/debug.keystore")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories { mavenCentral() }
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
//compile 'com.android.support:appcompat-v7:21.0.3'
//compile 'com.android.support:support-v4:21.0.3'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.google.android.gms:play-services:6.5.87'
// ActiveAndroid for simple persistence with an ORM
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.github.johnkil.android-robototextview:robototextview:2.3.0'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
//compile 'com.stripe:stripe-android:+'
// compile 'com.android.support:cardview-v7:21.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
//compile 'com.android.support:design:26.0.2'
compile 'com.makeramen:roundedimageview:1.5.0'
//compile 'com.stripe:stripe-android:2.0.2'
}
is there any particular by whoch android studio can automatically set version of all existing libraries ?
i need some suggestions
is there any particular by whoch android studio can automatically set
version of all existing libraries ?
Yes, android studio will automatically set version of all existing libraries by this code.
Put this at the end of your app module in build.gradle.
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
details.useVersion '27.0.2'
}
}
}
This will find all support dependencies and force their versions to be 27.0.2. This will solve your problem.
To avoid this you need to update your libs too.
Your libs like Picasso also contain 'com.android.support' library which need to be compatible with you app 'com.android.support' library, And I can see you used old versions of library which contain old version of 'com.android.support'.
You need to use libs that contain the compatible 'com.android.support' version, In your case it's 27.0.2
For example Picasso needed to upgrade to 2.5.2 instead.

java.lang.NoSuchMethodError: No static method isDeviceProtectedStorage

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'

Android Studio - Execution failed for task ':app:processDebugGoogleServices'

In my app level build.gradle file, I have the following dependencies declared
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile "com.google.android.gms:play-services-gcm:10.2.1"
compile 'com.microsoft.azure:notification-hubs-android-sdk:0.4#aar'
compile 'com.microsoft.azure:azure-notifications-handler:1.0.1#aar'
}
...which causes me to get warnings on all of the 10.2.1 versions stating that there is a newer version (11.0.1) available and I should use that instead. So, I update each one to point to the 11.0.1 version. The warning goes away, however when I try to perform the Project Sync after I make the changes, I get the error below, which basically tells me to go back to version 10.2.1.
Error:Execution failed for task ':app:processDebugGoogleServices'.
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 10.2.1.
Anyone have any ideas as to WHY this is happening? My Android Studio is completely up-to-date and I'm not sure what to try.
In other similar posts, the solution has been to add apply plugin: 'com.google.gms.google-services' to the bottom of the app build.gradle file, however it's already there.
FULL app level build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.MYAPPIDHERE.android"
minSdkVersion 19
targetSdkVersion 25
versionCode 104
versionName = "1.4"
multiDexEnabled true
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles 'proguard-project.txt'
}
}
dexOptions {
preDexLibraries = false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile "com.google.android.gms:play-services-gcm:10.2.1"
compile 'com.microsoft.azure:notification-hubs-android-sdk:0.4#aar'
compile 'com.microsoft.azure:azure-notifications-handler:1.0.1#aar'
compile 'me.leolin:ShortcutBadger:1.1.4#aar'
}
repositories {
maven {
url "http://dl.bintray.com/microsoftazuremobile/SDK"
}
mavenCentral()
}
apply plugin: 'com.google.gms.google-services'
Make sure dependencies from group com.google.android.gms and group com.google.firebase have the same version.
For example, current latest version is 11.0.1:
compile 'com.google.firebase:firebase-core:11.0.1' // <- This dependency must also have latest version
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.google.android.gms:play-services-gcm:11.0.1'
Update to the latest version, in both the gradle files
// project lavel build gradle
dependencies {
classpath 'com.google.gms:google-services:3.3.1'
}
//app lavel build gradle
dependencies {
implementation 'com.google.firebase:firebase-messaging:15.0.2'}
apply plugin: 'com.google.gms.google-services'

All android support libraries must use the same version specification

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'

material-dialogs library:Failed to find: com.android.support:appcompat-v7:21.0.3

I am going to add material-dialogs library to my project but I get this error Error:Failed to find: com.android.support:appcompat-v7:21.0.3 This is build.gradle..Where is my mistake?Is sth wrong with my project?
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.peomtime.tosca.peomtime"
minSdkVersion 15
targetSdkVersion 21
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:support-v4:21.0.2'
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'de.hdodenhof:circleimageview:1.2.0'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
//Core
compile 'com.github.gabrielemariotti.cards:cardslib-core:2.0.1'
compile 'com.github.machinarius:preferencefragment:0.1.1'
//compile 'com.github.nirhart:parallaxscroll:1.0'
compile project(':Parallax')
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.afollestad:material-dialogs:0.6.3.1'
}
thank you so much for your help
Check that you have latest libraries installed in Android SDK Manager. For appcompat-v7:21.0.3, the packages need to be checked/updated are:
Android Support Repository
Android Support Library
Also, it's recommended to fix your dependencies version rather than using + to get latest version:
compile 'com.android.support:appcompat-v7:21.0.3'
Not sure why, but I added this repo from Afollestad to my build.gradle (project, not model) and everything was resolved.
repositories {
maven { url "https://jitpack.io" }
}
link

Categories

Resources