android studio gradle can't resolve appcompat-v7:27.0.2 - android

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!

Related

Failed to load AppCompat ActionBar with unknown error android studio 3.0

After updating android studio to version 3.0, I can't preview layout of my app, I get the error like:
'Failed to load AppCompat ActionBar with unknown error'.
How can I fix this? but if I run the app on my device phone, its run normally.
This is my Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '26.0.2'
defaultConfig {
applicationId 'com.halloo'
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
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'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
testCompile 'junit:junit:4.12'
}
dependencies {
compile 'com.squareup.okhttp3:okhttp:3.5.0'
}
dependencies {
compile 'com.android.support:support-v4:24.+'
}
dependencies {
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
}
dependencies {
compile 'com.android.support:support-v4:24.+'
compile 'junit:junit:4.12'
}
dependencies {
compile 'com.android.support:support-v4:24.+'
compile 'com.mikhaellopez:hfrecyclerview:1.0.0'
}
Thank you very much for your time and assistance in this matter.
First, you need to use the same version of compileSdkVersion, buildToolsVersion, targetSdkVersion, and support library version. I see that you want to use buildToolsVersion '26.0.2'. So, change all of them to version 26.
Second, you need to clean up your build.gradle. There is no need for duplicate dependencies.
Third, try clean and build your project. As the last resort, try File -> Invalidate Caches/Restart...
Your app build.gradle should be something like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId 'com.halloo'
minSdkVersion 16
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'
}
}
productFlavors {
}
}
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'
})
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.squareup.okhttp3:okhttp:3.5.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.mikhaellopez:hfrecyclerview:1.0.0'
testCompile 'junit:junit:4.12'
}
You also need to check for your project build.gradle. It should contain build:gradle:3.0.0 (as #dheeraj-joshi has pointing out), something like this:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
// maven { url "https://maven.google.com" }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Then, you need to check your gradle version. It should at least using gradle-4.1.
I had similar problem (maybe not exactly the same one).
I was able to run the starter code on the phone and the menu was there. However, preview pane in Android Studio didn't show actual layout.
I have fixed it by changing Theme.AppCompat.Light.DarkActionBar to Base.Theme.AppCompat.Light.DarkActionBar in styles.xml.
This is a bug in android support library version "26.0.0-beta2'
use:
compile 'com.android.support:appcompat-v7:24.2.1'
with:
buildToolsVersion '26.0.0'
and
classpath
'com.android.tools.build:gradle:3.0.0-alpha8'
everything should work fine.

Gradle dependecies are failed to resolve

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.

Mapbox navigation package when added shows error in gradle build.

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()
}
}

Android Studio Gradle Sync Failure

I've been trying to run just a simple app with some in-built views, but on startup of Android Studio, Gradle sync completes with few errors. I've tried multiple methods I saw on the Internet, but nothing works. I also replaced the gradle-2.14.1 folder from Android Studio files, by downloading the zip file and extracting, but that doesn't work too.
Here is the code for build.gradle(Project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Code for build.gradle(app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.heenamehta.myapplication"
minSdkVersion 15
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.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
testCompile 'junit:junit:4.12'
}
Gradle-wrapper-properties:
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
I have also attached the image showing errors in Messages section. Here is the image
Also for the extra info, I am using:
Android Studio 2.2.3 with
SDK API level 23 and
Build tools 25.0.2
In your build.gradle [app-level] import all of those libraries, which are listed in error list and also update your android studio-
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:23.4.0'
compile 'com.android.support:design:23.4.0'
//Here - add all of those libraries dependencies
testCompile 'junit:junit:4.12'
}

Android Gradle project Sync Failed.Basic functionality will not work properly

I updated my android studio and my gradle will not sync
issues it gives me these errors. Im also using firebase as for authorization and database.I have tried deleting the gradle files and rebuilding but that didnt work. any suggestions would be appreciated.
Failed to resolve .com.android.support:support-v4:25.2.0
Failed to resolve com.android.support.test.espresso:espresso-core:2.2.2
Failed to resolve com.android.support:appcompat-v4:25.3.1
Failed to resolve com.android.support:mediarouter-V7:25.2.0
here is the build gradle for the project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
here is my app gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.example.dude.sportspicks518"
minSdkVersion 19
targetSdkVersion 24
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(include: ['*.jar'], dir: 'libs')
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
}
compile 'com.android.support:appcompat-v4:25.3.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services:10.2.6'
}
apply plugin: 'com.google.gms.google-services'
several way to try
Invalidate Cache/Restart AS
Clean Project and Rebuild
Update "Google Repository" and "Android Support repository" in the Android SDK Manager.
if not working, then If you are trying to get the support repository, this is the correct import:
compile "com.android.support:support-v4:25.3.1"
If your compile api isn't 25, change the version to the latest with your compile api.
Android Studio should give you a yellow warning if you are using incompatible version. just hover it and use the suggestion given
P/s: Please please dont use com.google.android.gms:play-services.. it very heavy dex method count

Categories

Resources