I have following code in build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.myapp.myapplication"
minSdkVersion 14
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.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.thefinestartist:finestwebview:1.2.7'
testCompile 'junit:junit:4.12'
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
But i get error for the following line
compile 'com.android.support:appcompat-v7:26.0.0'
Can any one help me how to fix this issue ?
problem is with
compile 'com.thefinestartist:finestwebview:1.2.7' check below screen shot
Solution :
https://stackoverflow.com/a/25736483/793943
This means your build version is 26.0.1 but ur support gradle version is 26.0.0. Change the support appcompat version from 26.0.0 to 26.0.1 and build.
Try adding below code to your project level build.gradle file, it should work
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
Related
I get the error message Gradle sync failed. I already searched for solutions on stackoverflow and found similar problems but the solution there could not solve my problem:
Example-->
syncing android gradle appcompat 27.0.1
build Gradle//Project is like this-->:
buildscript {
repositories {
jcenter()
maven { url "http://jcenter.bintray.com"}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
mavenCentral()
jcenter{ url "http://jcenter.bintray.com/" }
maven {
//url "https://jitpack.io"
url "https://maven.google.com" // Google's Maven repository
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and the build gradle module is like this-->:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "hibo.testxml"
minSdkVersion 19
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(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:27.0.3'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.android.support:design:27.3.1'
// FireBase
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
testCompile 'junit:junit:4.12'
}//Add this line
apply plugin: 'com.google.gms.google-services'
I hope somone can help me solve this problem.
ps:thanks in advance :D
By The way your problem is that you are using different versions for build tools and in dependencies.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "hibo.test"
minSdkVersion 19
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(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:27.0.3'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.android.support:design:25.3.1'
// FireBase
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
testCompile 'junit:junit:4.12'
}//Add this line
apply plugin: 'com.google.gms.google-services'
Now use this in your gradle. May be you have not 27.0.3 install. Then an error will come in gradle Console. Then install these tools by clicking the error.
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.
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()
}
}
Hey I have a problem with Android Studio 3(Beta-2)
Every time I create new/open existing project it shows me following errors:
Clean, Rebuild, Restart Studio, Removing gradle files don't work.
In the studio 2.3, everything is fine.
My build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
dataBinding.enabled = true
defaultConfig {
applicationId "com.valentun.findgift"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
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'
})
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
compile 'com.jakewharton:butterknife:8.7.0'
compile 'com.google.dagger:dagger:2.11'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'com.google.firebase:firebase-storage:11.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.retrofit2:converter-jackson:2.3.0'
compile 'com.github.aakira:expandable-layout:1.6.0#aar'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Project's graddle file:
// 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:3.0.0-beta2'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://jitpack.io'
}
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Remove Gradle files (.gradle folder) from your project folder (C:\Users.....gradle) and try reopening the Android Studio.
Hope this will help.
Change version 25 to 26
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "seesaa.vn.testandroidstudio"
minSdkVersion 17
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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
}
Your compile SDK version must match the support library's major version.
Since you are using version 25 of the support library, you need to compile against version 25 of the Android SDK.
Try File -> invalidate caches / Restart. Hope this will help.
I am not able to find out what is the exact issue when I add the dependencies.
dependencies {
compile 'com.github.jetradarmobile:android-snowfall:1.1.2'
}
I get the above error
my Gradle(Project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
}
}
allprojects {
repositories {
jcenter() {
maven { url "https://jitpack.io" }
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My Gradle(App)
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.animationbook.animationbook"
minSdkVersion 15
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-v7:24.2.1'
debugCompile 'junit:junit:4.12'
compile 'com.github.moondroid.coverflow:library:1.0'
compile 'com.github.jetradarmobile:android-snowfall:1.1.2'
}
How can the error be solved?
It's happen because your dependency com.github.jetradarmobile:android-snowfall:1.1.2 has compileSdkVersion 25, buildToolsVersion "25.0.2" & com.android.support:support-compat:25.0.1.
So you need to change com.android.support:appcompat-v7:24.2.1 to com.android.support:appcompat-v7:25.1.0, buildToolsVersion to 25.0.1 and com.android.support:design:25.1.0.
If you don't want to change your buildToolsVersion than you can use module of it and change modules buildToolsVersion.
change the buildToolsVersion to 25.0.1 and add dependency compile 'com.android.support:design:25.1.0'
And also change compile 'com.android.support:appcompat-v7:24.2.1' to compile 'com.android.support:appcompat-v7:25.1.0'
I had the same problem and what I did to solve it was Update "Google Repository" and "Android Support repository" in the Android SDK Manager.
I hope it helps!
I was facing the same issue.
I just updated all the support lib versions and error was gone!!!