I am facing this issue from 2 days, still not found any solution.
I tried changing versions of libraries, clean and build project, and invalidate cache etc.
Below is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.root.ambulancetracking"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//noinspection GradleCompatible
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.support:support-v4:27.1.1'
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.google.firebase:firebase-messaging:17.0.0'
compile 'com.google.firebase:firebase-core:16.0.0'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.github.ar-android:DrawRouteMaps:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.1'
}
}
}
}
And below is build.gradle (project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is what i am getting in message window.
Information:Gradle tasks [:app:assembleDebug]
Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/location/places/zza;
Information:BUILD FAILED in 1m 22s
Information:4 errors
Information:0 warnings
Information:See complete output in console
I tried my level best
Please, any help would be appreciated.
Thank you very much for your time and assistance in this matter.
please add this lib to resolve this issue
implementation 'com.android.support:multidex:1.0.3'
also, enable multidex in your application class
#Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
}
your version are conflict
compile 'com.google.firebase:firebase-messaging:17.0.0'
compile 'com.google.firebase:firebase-core:16.0.0'
compile 'com.google.android.gms:play-services-location:15.0.1'
covert to this lines :
compile 'com.google.firebase:firebase-messaging:17.0.0'
compile 'com.google.firebase:firebase-core:17.0.0'
compile 'com.google.android.gms:play-services-location:17.0.0'
You need to use the same version of Firebase and Google Play Service if you're using google play service plugin below 3.3.0.
If you want to use multiple version of Firebase and Google Play Service (starting from version 15), you need to use google play service plugin 3.3.0. So, change your project build.gradle to:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
...
Last, don't forget to always add the following line:
apply plugin: 'com.google.gms.google-services'
to the bottom of your app build.gradle.
Related
please how can I solve this error ?
ERROR: The Android Gradle plugin supports only Kotlin Gradle plugin
version 1.3.0 and higher. The following dependencies do not satisfy
the required version: root project 'android' ->
org.jetbrains.kotlin:kotlin-gradle-plugin:1.0.6 Affected Modules:
android-app
WARNING: Configuration 'compile' is obsolete and has been replaced
with 'implementation' and 'api'. It will be removed at the end of
2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: android-app
WARNING: Configuration 'testCompile' is obsolete and has been replaced
with 'testImplementation'. It will be removed at the end of 2018. For
more information see:
http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: android-app
WARNING: Configuration 'androidTestCompile' is obsolete and has been
replaced with 'androidTestImplementation'. It will be removed at the
end of 2018. For more information see:
http://d.android.com/r/tools/update-dependency-configurations.html
Affected Modules: android-app
WARNING: The specified Android SDK Build Tools version (26.0.2) is
ignored, as it is below the minimum supported version (28.0.3) for
Android Gradle Plugin 3.3.1. Android SDK Build Tools 28.0.3 will be
used. To suppress this warning, remove "buildToolsVersion '26.0.2'"
from your build.gradle file, as each version of the Android Gradle
Plugin now has a default version of the build tools. Remove Build
Tools version and sync project Affected Modules: android-app
my android-app file :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "fr.curie.jonquille.jonquille_curie"
minSdkVersion 18
targetSdkVersion 26
versionCode 203000
versionName "2.3.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
dexOptions {
javaMaxHeapSize "4g"
}
}
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 "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:design:26.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.2.4'
compile 'io.reactivex:rxkotlin:0.60.0'
compile 'com.jakewharton.rxbinding:rxbinding-kotlin:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-support-v4-kotlin:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-appcompat-v7-kotlin:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-design-kotlin:1.0.0'
compile 'com.jakewharton.rxbinding:rxbinding-recyclerview-v7-kotlin:1.0.0'
compile 'com.tbruyelle.rxpermissions:rxpermissions:0.9.1#aar'
compile 'pl.charmas.android:android-reactive-location:0.10#aar'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.sdoward:rxgooglemaps:1.1.1#aar'
compile 'com.github.kittinunf.fuel:fuel:1.3.1'
compile 'com.github.kittinunf.fuel:fuel-android:1.3.1'
compile 'com.github.kittinunf.fuel:fuel-rxjava:1.3.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-wallet:10.0.1'
compile 'com.stripe:stripe-android:2.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.twitter.sdk.android:twitter-core:3.1.1'
compile 'com.twitter.sdk.android:tweet-composer:3.1.1'
testCompile 'junit:junit:4.12'
}
repositories {
mavenCentral()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
my android file :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.0.6'
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 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
}
The error is caused by the old version of Kotlin in your project level file, you can update it to the latest version like so:
ext.kotlin_version = '1.3.21'
As for your warnings:
You should remove the explicit build tools version (buildToolsVersion "26.0.2") from your module level file, as the new Android Gradle plugins already pick the correct build tools to use automatically.
You should check out the link in the warnings and update your dependency configuration, e.g. replace compile with implementation or api, and so on.
Today, I opened Android Studio, then I get this error. Yesterday, there was a no problem such that!
Error:Execution failed for task ':app:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms.license'
com.google.android.gms:play-services-xxx libraries was
11.8.0
Onesignal library was
'com.onesignal:OneSignal:[3.6.2, 3.99.99]'
Then I changed them to latest version.
Now App/Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "xxx.xxx.xxx"
minSdkVersion 15
targetSdkVersion 24
versionCode 10
versionName 'x.x.x'
manifestPlaceholders = [onesignal_app_id: "xxxxx-xx-xxx",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "XXX"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
maven { url 'https://maven.google.com' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.github.chrisbanes.photoview:library:1.2.3'
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
compile 'com.google.android.gms:play-services-ads:12.0.0'
//compile 'com.google.android.gms:play-services-ads:11.2.2'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
//compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
compile 'com.balysv:material-ripple:1.0.2'
compile "com.google.firebase:firebase-messaging:12.0.0"
compile 'com.github.hotchemi:android-rate:1.0.1'
compile 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
compile 'com.google.android.gms:play-services-analytics:12.0.0'
}
apply plugin: 'com.google.gms.google-services'
Project/Gradle:
// 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'
classpath 'com.google.gms:google-services:3.1.1'
// classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
But I am still getting same error that stated above. How can I solve this problem? Why did this problem occur Today when there was no problem, yesterday?
This probably because the play services version is not in the range defined for
OneSignal:[3.7.1, 3.99.99] which is (you can see it at this commit):
// Limit upper number (exclusive) to prevent untested versions
static def versionGroupOverrides = [
'com.google.android.gms': '[10.2.1, 11.7.0)',
'com.android.support': '[26.0.0, 27.1.0)'
]
So, try changing the play services version to 11.7.0.
You should try using OneSignal Gradle Plugin which helps make the OneSignal Android SDK compatible with your Android Studio project. Use OneSignal-Gradle-Plugin 0.8.0 for OneSignal:[3.7.1, 3.99.99]
I'm a beginner with Android Studio.
Every time I try running my app on my Google Tango tablet, the following error emerges:
Execution failed for task:':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchibeMergerException: Unable to merge dex
This is my app Module build.gradle file...
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.cs15yyo.myfyp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
//multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.tango:sdk-base:1.55'
compile 'com.google.tango:support-base:1.54'
compile 'com.google.tango:sdk-depth-interpolation:1.55'
compile 'com.google.tango:sdk-transform-helpers:1.55'
compile 'org.rajawali3d:rajawali:1.1.668#aar'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation project(':tango_support_java_lib')
implementation project(':tango_ux_support_library')
}
This is my Project build.gradle file...
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my tango_support_java_lib Module build.gradle file...
configurations.maybeCreate("default")
artifacts.add("default", file('tango_support_java_lib.aar'))
This is my tango_ux_support_library Module build.gradle file...
configurations.maybeCreate("default")
artifacts.add("default", file('tango_ux_support_library.aar'))
Attempted Solutions
Looking at existing solutions in StackOverFlow, I've tried the following....
Writing multiDexEnabled true in the buildConfig block of code within the module build.gradle file
Build > Clean Project and afterwards, Build > Rebuild Project
Deleting the .gradle folder, and then running the app
Changing each compile word to compileOnly in the dependencies of my Module build.gradle file.
All have failed me, annoyingly so.
This is for my work on my final year Computer Science project.
I've solved the issue, as it turns out, the cause of the problem was importing JAR/AAR files as libraries AFTER writing the necessary dependencies (in the module build.gradle file) to get the same libraries; therefore, after removing the JAR/AAR files, my app was able to run
This question already has answers here:
Failed to resolve: com.google.firebase:firebase-core:11.2.0
(6 answers)
Closed 5 years ago.
This is my project's gradle files, I'm trying to get it to sync. I have included error logs, and code . Below you will find the files in order.
I got most of my code from the firebase docs, and still keep getting a fail, when I try syncing my project
Error:(40, 13) Failed to resolve: com.google.firebase:firebase-auth:11.2.0
Show in File<br>Show in Project Structure dialog
Error:(39, 13) Failed to resolve: com.google.firebase:firebase-storage:11.2.0
Show in File<br>Show in Project Structure dialog
Error:Failed to resolve: com.google.firebase:firebase-core:11.2.0
Open File<br>Show in Project Structure dialog
Error:(42, 13) Failed to resolve: com.google.firebase:firebase-database:11.2.0
Show in File<br>Show in Project Structure dialog
Error:Failed to resolve: annotationProcessor
Open File
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
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
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.karanvir.chat"
minSdkVersion 16
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:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
compile('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.google.firebase:firebase-storage:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0'
compile 'com.google.firebase:firebase-messaging:11.2.0'
compile 'com.google.firebase:firebase-database:11.2.0'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'com.google.gms.google-services'
I think that you have to add the libraries of Firebase to your project, fo example if you need to use the storage you need to add the:
compile 'com.google.firebase:firebase-storage:10.2.1'
in your gradle dependencies, but before of that you need to registrer your project in the Firebase page, get your key and downlowad the
google-services.json
for your project.
Check the tutorials in their page.
https://firebase.google.com/docs/android/setup?hl=es-419
In your application build.grade, try removing:
compile 'com.google.firebase:firebase-storage:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0'
compile 'com.google.firebase:firebase-messaging:11.2.0'
compile 'com.google.firebase:firebase-database:11.2.0'
and replacing them with this dependency:
compile 'com.google.android.gms:play-services-gcm:8.4.0'
project gradle
// 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-alpha3'
classpath 'com.google.gms:google-services:3.0.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
}
App Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.arun4fms.efix"
minSdkVersion 17
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'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
}
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.google.firebase:firebase-database:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.chabbal:slidingdotsplash:1.0.2'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.firebase:firebase-client-android:2.5.2'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Error:A problem occurred configuring root project 'webapp'.
Could not resolve all dependencies for configuration ':classpath'.
Could not find com.android.tools.build:gradle:3.0.0-alpha3.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha3/gradle-3.0.0-alpha3.jar
Required by:
project :
As already answered here:
Google have new maven repo, so it could be the reason.
https://android-developers.googleblog.com/2017/05/android-studio-3-0-canary1.html
section Google's Maven Repository
https://developer.android.com/studio/preview/features/new-android-plugin-migration.html
https://developer.android.com/studio/build/dependencies.html#google-maven
Add Google’s Maven Repository to the buildscript repositories section to fix it like #KG87 did here.
buildscript {
repositories {
jcenter()
maven { url "https://maven.google.com" } // Add this line to fix it
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
...
}
}
As explained here:
The repositories in the buildScript block are used to fetch the
dependencies of your buildScript dependencies. These are the
dependencies that are put on the classpath of your build and that you
can refer to from your build file. For instance, extra plugins that
exist on the internet.
The repositories on the root level are used to fetch the dependencies
that your project depends on. So all the dependencies you need to
compile your project.
And here:
The buildScript block determines which plugins, task classes, and
other classes are available for use in the rest of the build script.
Without a buildScript block, you can use everything that ships with
Gradle out-of-the-box. If you additionally want to use third-party
plugins, task classes, or other classes (in the build script!), you
have to specify the corresponding dependencies in the buildScript
block.
As announced here:
The Android Gradle Plugin 3.0.0-alpha3 was also released through
maven.google.com.
So, try to fix it by adding Google’s Maven Repository.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Also add the repository here for other dependencies like the support libraries like this:
Make sure that the repositories section includes a maven section with
the "https://maven.google.com" endpoint. For example:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
The difference is explained here
The "buildscript" block only controls dependencies for the buildscript
process itself, not for the application code, which the top-level
"dependencies" block controls.
For instance, you could define dependencies in "buildscript/classpath"
that represent Gradle plugins used in the build process. Those plugins
would not be referenced as dependencies for the application code.
As commented here by #lugegege, this version doesn't exist in Bintray JCenter:
com.android.tools.build.gradle
latest version is 2.5.0-alpha-preview-02, there is no 3.0.0-alpha3
com.android.tools.build.gradle latest version is 2.5.0-alpha-preview-02, there is no 3.0.0-alpha3
Use this.. This may work because this worked in my case:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
}
and put this at the end of the app-level build.gradle file (after the dependencies).
apply plugin: 'com.google.gms.google-services'
I have no clue why putting this at the end (and not at the beginning ) solves the error.
Ok… So trying to put an end to all problems you guys have faced with my solution
This is my final app level gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "your-app-name"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:design:23.1.1'
compile 'com.mcxiaoke.volley:library:1.0.6#aar'
}
apply plugin: 'com.google.gms.google-services'
and this is my final project level gradle
// 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.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Compare this with your own gradle files, and add or modify any values which are different from what I've written.
I had the same problem this morning !
As Vishal said, there is no gradle-3.0.0-alpha3..
I am sure that, since I downloaded "Android studio 3.0 Canary (Alpha3)", I was on on the same version of gradle (3.0.0 alpha3), and it worked ! (Since today).
So I've put : classpath 'com.android.tools.build:gradle:2.3.2' to compile.
EDIT : I have two versions of Android studio, When I used Android Studio 3.0, it changes gradle to gradle 3.0.0-alpha3 !
write these gradles..
compile 'com.android.support:appcompat-v7:25.0.2'
compile 'com.android.support:design:25.0.2'
classpath 'com.android.tools.build:gradle:2.2.3'