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.
Related
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 can't import the "import com.google.firebase.auth.FirebaseAuth;" for my Android Studio.
I checked everything already. All build gradle are setted with the latest Firebase version.
The only import that allows me to do is "FirebaseAuthException" and "FirebaseUser"
Someone help me. thank you.
Project Build.Gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
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
}
Build.gradle(Module:app)
repositories {
maven {
url "https://maven.google.com"
}
maven { url "https://jitpack.io" }
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.rick.teddyfy"
minSdkVersion 23
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(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.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
//Design layout
compile 'com.android.support:design:26.1.0'
compile 'com.github.ittianyu:BottomNavigationViewEx:1.2.3'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
//firebase authentication
'com.google.firebase:firebase-auth:10.2.6'
}
apply plugin: 'com.google.gms.google-services'
The dependency has syntax errors, it should be like this:
compile 'com.google.firebase:firebase-auth:10.2.6'
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'
}
}
}
Trying to run app the following error occurs:
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 9.2.0.
I changed different versions but it didn't work again
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.mher.loginregister"
minSdkVersion 25
targetSdkVersion 19
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.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.google.firebase:firebase-database:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
2)
// 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.3.3'
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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You need to use the same version of all the Firebase and Google dependencies.
Use this:
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.google.firebase:firebase-database:9.2.0'
Note the difference in the version number for firebase-database.
This is how your build.gradle should look like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.mher.loginregister"
minSdkVersion 25
targetSdkVersion 19
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.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.google.firebase:firebase-database:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
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!!!