I'm using Android Studio version 2.3.3. It has been updated recently. Whenever I try to add a new dependency for any use e.g. recyclerview, cardview, retrofit, etc, the gradle fails to resolve them.
I have mentioned the repositories in gradle file. But there is no solution.
this is my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.apurva.bargraph"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven {url "https://maven.google.com"}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.github.philjay:mpandroidchart:v3.0.2'
testCompile 'junit:junit:4.12'
}
for each of the dependency, gradle sync fails and I don't know what else to do.
Any kind of help would be great.
There may be number of problems for this
1. First check your buildToolVersion which you are using is installed in your sdk.
2. You have to add below code in project gradle file not in app gradle.
maven { url "https://jitpack.io" }
maven {url "https://maven.google.com"}
Just change the buildToolVersion to higher version which is installed in you studio.
It's May be help you out.
This is because you didn't have support library 25.3.1 installed in your system. So, you need to install the sdk from Android Studio via Tools->Android->SDK Manager for support library below 25.4.0. You only need to use google maven to use support library starting from revision 25.4.0.
Related
I was faced with a strange problem.
I'm using android studio 3.0.1 . the latest appcompat version that grade resolve is appcompat:v7:26.0.0_alpha1
build.gradle (module: app)
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "someID"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
sourceSets { main { java.srcDirs = ['src/main/java', 'src/main/helpers'] } }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// Support v7
//compile 'com.android.support:appcompat-v7:26.+'
compile "com.android.support:support-core-utils:27.0.2"
compile 'com.android.support:appcompat-v7:27.0.2'
// JSON Parsing
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
// Retrofit
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
//testCompile 'junit:junit:4.12'
}
and this is build.gradle(Project)
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
i got errors like
Error:Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.android.support:support-core-utils:27.0.2.
i'm using proxy and i can get previous releases till v:26.0.0_alpha1
ps:i tried compile 'com.android.support:appcompat-v7:27.+'" and clean project
OK i changed my vpn server and everything build ok
I think they block the other vpn service ips !
Here is how to fix it.
Go Tools > SDK Manager. If it is showing that Android 8.1 (Oreo) is partially installed, click on show package details in the bottom right corner.
Under Android 8.1 (Oreo) select Sources for Android 27 and click on the Download icon on its left margin.
Click Ok and Android studio will install sources for Android 27 and then try to build the project again.
Good Luck!
I am creating a blank project in which I add mapbox navigation package compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.3' in the gradle file. It shows error in appcompat file like this:-
Error:Failed to resolve: com.android.support:appcompat-v7:26.1.0
eventhough I use different version of Appcompat file. Before adding navigation package, everything was fine. Can someone please help me to find out this weird error.
Here is my app's gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.aadhilahmed.test7"
minSdkVersion 15
targetSdkVersion 25
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.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.3'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Specify:
compile ('com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.3') {
transitive = false;
}
Try this.Starting from version 26 of support libraries make sure that the repositories section includes a maven section
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
For Gradle build tools plugin version 3.0.0
allprojects {
repositories {
jcenter()
google()
}
}
I'm trying out Android Studio 3.0 Canary 9 with an existing project, and I'm getting this error trying to sync the build files:
Error:Failed to resolve: commons-logging:commons-logging:1.1.1
I am not adding commons-logging as a dependency, so it must be used by some other dependency but I don't know what. Here's the buildscript section of my top-level build file where I made changes for 3.0:
buildscript {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'de.felixschulze.gradle:gradle-hockeyapp-plugin:3.5'
}
}
In gradle-wrapper.properties I have this:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
The only change I made in the project build file was to the way I was renaming the APK file. Anybody know how to track down this dependency and what to do to fix it?
If you using Android Gradle 2.2 plugin or newer, then you should remove com.neenbedankt.gradle.plugins:android-apt from your Gradle plugins.
Also change all apt in dependencies to annotationProcessor
You can read more here
I don't know if this will fix, but it might help in locating the issue.
start a new empty project using AS 3.0, add the 3 dependencies 1 by 1 while testing in between each add. I have a suspicion one of them doesn't play nicely with AS 3.0, and that it has nothing to do with your code since you made no changes.
Another thing you can try is going back to an older version of AS and rechecking that it runs. This isolates the issue to AS 3.0 and not your code or dependencies.
Lastly if nothing works, create a brand new project with new package name and manually copy paste everything into the new project. I usually find lots of bugs doing this.
I followed moonpire00's suggestion and created a new project. I discovered that the problem was with the AWS imports:
implementation 'com.amazonaws:aws-android-sdk-core:2.2.0'
implementation 'com.amazonaws:aws-android-sdk-ses:2.2.0'
I changed them to this:
implementation 'com.amazonaws:aws-android-sdk-core:2.2.0', {
exclude module: 'commons-logging'
}
implementation 'com.amazonaws:aws-android-sdk-ses:2.2.0', {
exclude module: 'commons-logging'
}
And now the gradle sync works! If anyone has insight into why this error would appear with Android Studio / gradle 3.0, please post a comment.
Its Working
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.keshav.mraverification"
minSdkVersion 15
targetSdkVersion 26
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.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:cardview-v7:26.0.1'
compile 'com.android.support:design:26.0.1'
testCompile 'junit:junit:4.12'
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
I have already installed Android SDK Platform 26, Android SDK Tools 26.0.2
This is my app level build.gradle file.
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
...
}
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.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:support-v4:26.0.2'
testCompile 'junit:junit:4.12'
}
I can't sync the gradle. I am getting these errors:
Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:26.0.2
Error:(27, 13) Failed to resolve: com.android.support:support-v4:26.0.2
Are the appcompat and support library versions are wrong?
How can I solve this issue? Please help.
Thanks in advance.
There are two things to it
First
This is the page that announces recent releases of the support library, and I don't see 26.0.2 version. The latest is 26.0.0-beta2 and
Note that 26.0.0-beta2 is a pre-release version
Second
Make sure you have google's maven repository included in you project's gradle file. Something like :
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
appcompat version must to match with SdkVersion.
Try this one
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
Today I updated all my support libraries and buildtools to the latest version to support Android N. Once I updated everything and ran the app, I got an error in InstanceId generation method of GCM in my app. So, I searched and found solutions that suggested to update play-services too. After following all the SO questions and answers, I am stuck and can't move forward. Switching back to support libraries 23.x.x is not an option as I want to target Android N.
Here is how my project level build.gradle files look:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
App level build.gradle:
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
// maven { url 'http://hansel.io/maven' }
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
// classpath 'io.hansel.preprocessor:preprocessor:1.0.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
//apply plugin: 'io.hansel.preprocessor'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
signingConfigs {
}
defaultConfig {
applicationId 'com.example.android'
multiDexEnabled true
minSdkVersion 16
targetSdkVersion 24
versionCode 47
versionName "1.3.2"
renderscriptTargetApi 24
renderscriptSupportModeEnabled true
}
buildTypes {
debug {
applicationIdSuffix = ".dev"
resValue "string", "app_name", "example-debug"
}
release {
minifyEnabled false
shrinkResources false
resValue "string", "app_name", "example"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion 16
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
repositories {
mavenCentral()
mavenLocal()
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
// maven { url 'http://hansel.io/maven' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:support-annotations:24.2.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:design:24.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.3.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.github.clans:fab:1.6.1'
compile 'com.facebook.fresco:fresco:0.8.1+'
compile 'com.facebook.fresco:imagepipeline-okhttp:0.8.1+'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.google.android.gms:play-services-analytics:9.6.1'
compile 'com.google.android.gms:play-services-location:9.6.1'
compile 'com.google.android.gms:play-services-gcm:9.6.1'
compile 'com.google.android.gms:play-services-measurement:9.6.1'
compile 'com.github.liuguangqiang.swipeback:library:1.0.2#aar'
compile 'me.imid.swipebacklayout.lib:library:1.0.0'
compile 'com.github.2359media:EasyAndroidAnimations:0.8'
compile 'com.theartofdev.edmodo:android-image-cropper:2.0.+'
compile 'com.wang.avi:library:1.0.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.mixpanel.android:mixpanel-android:4.6.4'
compile 'com.github.ppamorim:dragger:1.2'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'io.reactivex:rxjava:1.1.3'
compile 'com.jakewharton.rxbinding:rxbinding:0.2.0'
// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
// releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
compile 'com.bignerdranch.android:expandablerecyclerview:2.1.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.birbit:android-priority-jobqueue:2.0.0'
compile 'com.squareup:otto:1.3.8'
compile 'com.mikhaellopez:circularprogressbar:1.1.1'
compile 'com.github.dotloop:aosp-exif:be25ae51ec'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
exclude group: 'com.squareup.okhttp', module: 'okhttp'
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'
And this is the error I am getting:
Any help would be highly appreciated. Thanks.
Edit
My google play services is also updated.
Today I had the same problem. This solved the problem for me:
Open the stand alone Android SDK Manager. In the Extras section the "Google Play Services" were at the latest version, but the "Google Repository" after updating the "Google Repository" from version 33 to 35, the problem was gone.
You don't have the latest google play services, just click the link and android studio will offer a dialog to install it.
Finally, I solved it myself. Here is what I did:
Removed compile 'com.google.android.gms:play-services-measurement:9.6.1' and then compiled the project
It gives missing api_key error because GCM got shifted to Firebase and so the google-services.json file does not work
To fix this, simply update the google-services.json file with the new generated file which uses Cloud messaging from Firebase
After this, I compiled and got another error that #drawable/powered_by_google_dark is missing from the project as I am using Places Autocomplete API. To fix this, add compile 'com.google.android.gms:play-services-places:9.6.0' to dependencies
Set all play service dependencies to 9.6.0. 9.6.1 hasn't released yet. If the problem still occurs, install latest google play service and repository in your android studio.
Well sometime it happens when you are not connected to the internet.
Connect to internet and rebuild your project and the error will be gone.
Worked for me this way.