Hello guys I desire to use lamba functions available on Java8, hence I had to apply new toolchain Jack. Unfortunatelly when I did some unexpected error arise. Namely:
Could not get unknown property 'classpath' for task ':app:transformJackWithJackForProdDebug' of type com.android.build.gradle.internal.pipeline.TransformTask.
I'm using in my project library like
In project I'm using lib like:
dagger
RxJava
I know that dagger causes error, however since july dagger2 has became available to use.
I use
Android Studio 2.1.2
Gradle Version 2.14.1
Android Plugin Version
2.2.0-alpha7
Please look at my gradle
project/buidl.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha7'
// classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// 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/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
defaultConfig {
applicationId "XXX"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
jackOptions{
enabled true
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
versionNameSuffix "_debug"
}
}
productFlavors{
dev{
minSdkVersion 21
}
prod {
minSdkVersion 19
}
}
compileOptions{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
ext {
JUNIT_VERSION = '4.12'
DAGGER_VERSION = '2.4'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile "junit:junit:$JUNIT_VERSION"
compile project(path: ':android_mvp')
// dependency injection
apt 'com.google.dagger:dagger-compiler:2.0' // 2.5 causes error
compile 'com.google.dagger:dagger:2.0'
provided 'javax.annotation:jsr250-api:1.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
// for new Jack and Jill gradle 2.2.+
// rx java
compile 'io.reactivex:rxjava:1.1.6'
compile 'io.reactivex:rxandroid:1.2.1'
// RxAndroid providing Android Scheduler
compile 'io.reactivex:rxjava-joins:0.22.0'
// view
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:recyclerview-v7:24.1.1'
compile 'com.android.support:cardview-v7:24.1.1'
// rest / stream
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.neovisionaries:nv-websocket-client:1.29'
// time
compile 'net.danlew:android.joda:2.9.3'
}
EDITED
Ok as I've read Lambdas are currenty not supported in project
module, so as you want to use lambdas in project modules - just
forget.
So I've removed my own module and copied whole code into main app module
I ended up with successfully gradle build by removing following code lines from app/build.gradle
apply plugin: 'com.neenbedankt.android-apt'
...
dependency{
apt 'com.google.dagger:dagger-compiler:2.0' // 2.5 causes error
}
However error related with dagger remains, its mean that sometimes project was able to rebuild sometimes its wrote very long stacktrace.
CONCLUSION
After 2,5 years after first j8 release lazy Android team is not able to integrate it. 2,5 year in IT is sooo long, so my programing skils became slowly deprecated! I hope they finish until j9 release!
Had the same issue. Solved by using built in "annotationProcessor" instead of "apt" plugin
https://stackoverflow.com/a/39086683/2282051
remove:
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
apply plugin: 'com.neenbedankt.android-apt'
apt 'com.google.dagger:dagger-compiler:2.0'
and you already have
dependencies {
annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
}
It does the same as the 'apt' plugin does.
Related
I'm new to Android development and got a legacy project. So I installed the newest version of Android Studio and opened it.
When I try to build it, I get this error:
Error:android-apt plugin is incompatible with the Android Gradle plugin. Please use 'annotationProcessor' configuration instead.
I've trying the solutions shown in these thread, but it did not work.
I don't have any android-apt reference on my grandle build script.
Many of compile packages are shown as outdated. But when I follow Android's studio suggestion to update reference, I get errors saying the package was not found.
As I said, I'm new to Android Studio World, so I'm a little lost with all these stuff.
This is my build.gradle (Module: app):
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "xxxxxxxxxxxx"
minSdkVersion 19
targetSdkVersion 24
versionCode 123
versionName "1.2.3"
manifestPlaceholders = [HOCKEYAPP_APP_ID: "xxxxxxxxxxxxxxxxxxxxx"]
//For Test
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.mikepenz:materialdrawer:4.6.4#aar') {
transitive = true
}
//For Test
androidTestCompile 'com.android.support:support-annotations:24.2.1'
//noinspection GradleCompatible
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:support-v13:24.2.1'
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.p_v:flexiblecalendar:1.1.4'
compile 'br.com.zbra:android-linq:1.0.1'
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
compile 'com.cardiomood.android:android-widgets:0.1.1'
compile 'com.github.thorbenprimke:realm-recyclerview:0.9.14'
compile 'net.hockeyapp.android:HockeySDK:4.0.0'
}
This is my build.gradle (Project: MyApp):
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath "io.realm:realm-gradle-plugin:0.88.3"
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The third party android-apt plugin is no longer supported. You should switch to the built-in annotation processor support, which has been improved to handle resolving dependencies lazily.
When using the Android plugin 3.0.0, you must add annotation processors to the processor classpath using the annotationProcessor dependency configuration, as shown below:
dependencies {
...
annotationProcessor 'com.google.dagger:dagger-compiler:<version-number>'
}
Please read the full migration guide to Android Gradle Plugin 3.0.0 at https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
Retrolambda is no longer needed. New Android Gradle Plugin supports Java 8 language features. Read more here.
Assuming you followed the migration guide the error is caused by old Realm plugin.
Realm plugin manages all Realm dependencies behind the scenes. This also means that its old version does not support new tools.
annotationProcessor configuration is first supported in Realm 2.2.0 as seen in the changelog:
Enhancements
Added support for the annotationProcessor configuration provided by Android Gradle Plugin 2.2.0 or later. Realm plugin adds its annotation processor to the annotationProcessor configuration instead of apt configuration if it is available and the com.neenbedankt.android-apt plugin is not used. In Kotlin projects, kapt is used instead of the annotationProcessor configuration (#3026).
Actually you have two options:
update your Realm to at least 2.2.0, or
go back to Android Gradle Plugin 2.3.3.
After update Android Studio to 3.0 version I have warning:
Error:android-apt plugin is incompatible with the Android Gradle plugin. Please use 'annotationProcessor' configuration instead.
I tried to rewrite my gradle source ,but I still have a warning.
Here is a source
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'io.realm:realm-gradle-plugin:0.89.+'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.syncapp"
minSdkVersion 21
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(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.11'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:support-v4:27.0.1'
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support:design:27.0.1'
compile 'org.greenrobot:eventbus:3.1.1'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp:okhttp:2.7.5'
compile 'com.squareup.okhttp:mockwebserver:2.7.5'
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.google.dagger:dagger:2.4'
annotationProcessor 'com.google.dagger:dagger-compiler:2.4'
}
apply plugin: 'realm-android'
As you can see,in my project I'm using butterknife,dagger,okhttp,retrofit2 and eventbus support libraries
Any solution? I can't run my app
Thanks
Remove apt plugin from your build.gradle file. And wherever in dependency you are using apt replace it with annotationProcessor. Moreover update your realm dependency version to 4.1.1 as well.
Did you have a look at this link?
Basically:
If you are experiencing issues migrating to the new dependency resolution >strategy, you can restore behavior to that of Android plugin 2.3.0 by setting >includeCompileClasspath true.
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
}
}
then you can opt to remove the Apt plugin to make the project cleaner but consider that should not affect according to the official documentation
android-apt plugin users: This behavior change currently does not affect the >android-apt plugin. However, the plugin will not be compatible with future >versions of the Android plugin for Gradle
Also when yuo migrate to Android Studio 3.0 you should not use compile but implementation for every dependency
What also you should do is to try to upgrade or downgrade the annotation processor dependecies you have with Dagger or Butterknife, if does not work try to remove Butterknife(but I am not sure about that if the Dagger one is enough, anyway you should not need).
Gradle Project Refresh Failed
After I added KenBurnsView Library to build.gradle on app level. When I try to sync the gradle it failed.
build.gradle (app level)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.sample.ac"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0_dev"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
jcenter()
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
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.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:cardview-v7:25.0.1'
//ButterKnife for view injector
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
// EventBus for passing data between activities and fragments
compile 'org.greenrobot:eventbus:3.0.0'
//Material Loading Circular Progress Bar with white background
compile 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
//GSON for parsing JSON into Java Object and vice versa
compile 'com.google.code.gson:gson:2.6.2'
//For Image Loading from network
compile 'com.github.bumptech.glide:glide:3.7.0'
//SLiding up Panel Layout for Music Player
compile 'com.sothree.slidinguppanel:library:3.3.0'
//For Network Calling
compile 'com.mcxiaoke.volley:library:1.0.19'
//ViewPagerIndicator
compile 'com.romandanylyk:pageindicatorview:0.0.7'
//Google Play Services
compile 'com.google.android.gms:play-services-auth:10.0.0'
compile 'com.google.android.gms:play-services-plus:10.0.0'
compile 'com.google.android.gms:play-services-identity:10.0.0'
compile 'com.google.android.gms:play-services-base:10.0.0'
compile 'com.google.android.gms:play-services-location:10.0.0'
compile 'com.google.android.gms:play-services-maps:10.0.0'
compile 'com.google.android.gms:play-services-gcm:10.0.0'
//Ken Burns Effect for Image Background
compile 'com.flaviofaria:kenburnsview:1.0.7'
//Material Search View
// compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile project(':searchlibrary')
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (project level)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
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()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I got it when trying to add a dependency to "com.android.support.constraint:constraint-layout:1.0.0-beta4" for an android training class.
I managed to get past it and it did involve Jack, as #Scott suspected.
Got past it by:
commenting out the added dependency, the jackOptions enable true block, and the compileOptions block, where I had it compatible with 1.8.
Sync/Clean/Rebuild Gradle (whichever it is, I'm still learning)
Uncomment the added dependency, sync/rebuild gradle again
Uncomment the jackOptions and compileOptions blocks, sync/rebuild gradle again
At that point, it worked for me.
Add it to app build.gradle or project build.module:
repositories {
maven {
url 'https://maven.google.com'
}
}
I get this problem when I add 'constraint-layout' dependency and I find out answer in ofical manual: https://developer.android.com/training/constraint-layout/index.html
I think it will help you!
After hours of trying everything, this worked for me -> Upgrade com.google.gms:google-services to latest version.
Case : added
dataBinding {
enabled = true
}
Solution : In project gradle classpath changed
'com.google.gms:google-services:3.3.1'
to
'com.google.gms:google-services:4.0.1' (latest version)
I upgraded gradle and a google-play-services lib and didn't realize that you are apparently required to remove apply plugin: 'com.google.gms.google-services' at the end of app module's build.gradle.
Removing it solved this for me.
The docs were a little misleading. Removing apply plugin: 'com.google.gms.google-services' did indeed solve this problem, but the line is still required for Firebase to work actually.
After some more playing around, I noticed that also removing the dataBinding{enabled true} made the error go away. But again, also this is not a solution.
In the end I had to downgrade to com.android.tools.build:gradle:3.0.0 - which again is obviously not a solution because you are missing out on e.g. InstantRun, but at least it builds.
The whole issue was introduced after an update to Android Studio 3.1.2, so I assume that downgrading again would solve it.
I come across this question too , i added maven in repositories{...} and a dependency in dependencies {...} of module's build.gradle .
I find the reason , because Android Studio can't load the dependency from maven repository . then instead compile, i copy the jar to module , sync ,the error is disappeared.
In summary , you can check out the dependency is loaded or not at "C:\Users\wjj.gradle\caches\modules-2\files-2.1".
I hope it can help you!
my project build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
classpath 'com.google.dagger:dagger-compiler:2.2'
classpath 'com.google.guava:guava:19.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
}
my module build.gradle
android {
compileSdkVersion 24
buildToolsVersion '24.0.0'
defaultConfig {
applicationId "com.aber.app.acgtalk"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
ext {
supportLibVersion = '24.0.0'
}
dependencies {
compile 'com.google.dagger:dagger:2.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.2'
debugAnnotationProcessor 'com.google.dagger:dagger-compiler:2.2'
provided 'javax.annotation:jsr250-api:1.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:${supportLibVersion}";
compile "com.android.support:recyclerview-v7:${supportLibVersion}";
compile "com.android.support:design:${supportLibVersion}";
compile "com.android.support:support-v13:${supportLibVersion}";
compile "com.android.support:support-annotations:${supportLibVersion}";
compile "com.android.support:gridlayout-v7:${supportLibVersion}";
compile "com.android.support:cardview-v7:${supportLibVersion}";
compile "com.android.support:preference-v14:${supportLibVersion}";
compile 'com.squareup.okhttp3:okhttp:3.2.0';
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
}
what's wrong with this,how to using the annotationProcessor function within the Android studio 2.2 ,how to conifg the dagger2 annotation processor correctly?
new Jack annotations processors
Yes, with android gradle plugin 2.2.0 release, the android-apt plugin is no longer needed for annotation processing. The apt function was included in the latest android gradle plugin. It's called annotationProcessor now which was what you had in your build script. However, there were a few misconfigured stuff in the script.
First of all, the dagger compiler should not be added to classpath. So remove this line: classpath 'com.google.dagger:dagger-compiler:2.2'.
And you are using android gradle plugin version alpha3. Try to use the latest version, so change to classpath 'com.android.tools.build:gradle:2.2.2'.
The dependency declaration block looks legit. So try to make the above changes to see if it would work.
You're incorretly insert plugin classpath. Remove the following line in your project build:
classpath 'com.google.dagger:dagger-compiler:2.2'
and insert:
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
Then in your module build.gradle, add the following code after apply plugin android application:
// add after applying plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
Add the following line to your dependencies:
// apt command comes from the android-apt plugin
apt 'com.google.dagger:dagger-compiler:2.2'
compile 'com.google.dagger:dagger:2.2'
provided 'javax.annotation:jsr250-api:1.0'
For more information read here:
https://github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2
and for sample project, visit here:
https://github.com/spirosoik/AndroidArchitecturePadawans
I am working on the Sample in the below blog
https://www.firebase.com/blog/2015-10-01-firebase-android-app-engine-tutorial.html
The projects fails to compile after adding the dependency
compile 'com.firebase:firebase-client-android:2.3.1'
Other dependencies compile without any issue.
'com.android.support:appcompat-v7:23.0.1'
'compile 'com.android.support:design:23.0.1'
Where am I going wrong ?
here is my module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.tri.todoapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
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(dir: 'libs', include: ['*.jar'])
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.firebase:firebase-client-android:2.4.0'
}
Top-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:1.3.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
}
The project fails to compile because version 2.3 doesn't exists. You should use 2.3.1:
compile 'com.firebase:firebase-client-android:2.3.1'
or the newest 2.4.0:
compile 'com.firebase:firebase-client-android:2.4.0'
You can find more information here:
https://www.firebase.com/docs/android/quickstart.html
We are talking about Google api versions without mentioning Google Repository version.
The actual problem here is that your Google Repository doesn't "know" about the firebase version you all were trying to use.
I got same error while following the official firebase documentation
My app-level build.gradle file looked like this:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
}
apply plugin: 'com.google.gms.google-services'
My Google Repository version was 44
You can check yours in
SDK Manager>Android SDK> SDK Tools (tab)
Latest version is 46 (at the time of writing this)
I updated to latest Google Repository version and the problem was solved!
You can update by checking "Google Repository" under SDK Tools tab and click "Apply" to update Google Repository to latest version
If you do not wish to update your Google Repository version, you can still resolve the issue by lowering your firebase api version slighlty.
For my case, changing app-level build.gradle file to the following also fixes my problem:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
}
apply plugin: 'com.google.gms.google-services'
firebase version has been lowered to version 10.2.0 from 10.2.1
This works because 10.2.0 is known to Google repository ver 44.
I hope this answer will help many in future.
There are two modules you need to add firebase to:
The android module: You should use the "Add Firebase" checkbox that appears in project structure that will add 2.3.1 to the android app.
The backend module requires 2.4 to run in app engine and those steps require you to add the dependency manually.
In that case, be sure you are adding the jvm client -- not the "android" client for app engine.
compile 'com.firebase:firebase-client-android:2.4.0'
It happens because this version
compile 'com.firebase:firebase-client-android:2.3'
doesn't exist.
You can use one of these:
compile 'com.firebase:firebase-client-android:2.4.0'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.firebase:firebase-client-android:2.3.0'
Pay attention.
compile 'com.firebase:firebase-client-android:2.3.0'
is different from
compile 'com.firebase:firebase-client-android:2.3'
You can find the full list in maven:
using
compile 'com.firebase:firebase-client-android:+'
worked for me.
I had the exact same problem today, but with version 2.4.1. I could however not open the link l jcenter.bintray.com/com/firebase/firebase-client-android/2.4.1/ as mentioned by Mattia Maestrini.
Solution for me: Deactivate my VPN, and then it worked.
it looks like it was a dex limit error. Adding the Firebase SDK must have put me over the limit, to fix this i had to add multiDexEnabled true in the defaultConfig section of my app:build.gradle file as well as compile 'com.android.support:multidex:1.0.0' in the dependencies
Here is my gradle
gradle for 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:1.5.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
}
gradle module app
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.tranetech.openspace.firebasedemo"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
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(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.firebase:firebase-client-android:2.5.2+'
compile 'com.firebaseui:firebase-ui:0.3.1'
compile 'com.android.support:multidex:1.0.0'
}
I not sure you still working with that project or not, but I also faced the same problem with you, my solution is
In your build.gradle (outside the app folder one), add
buildscript {
repositories {
jcenter()
}
dependencies {
////
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
}
}
and in your module build.gradle, add
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.+'
compile 'com.android.support:design:23.+'
compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.firebase:firebase-client-android:2.4.0'
}
apply plugin:
'com.google.gms.google-services'// <- this code
And the last, don't forget to download google-services.json put in your app folder, the path should look like \yourapplication\app, you also can refer to this link for download google-services.json file. Download a configuration file
compile is deprecated. You should use:
implementation 'com.firebase:firebase-client-android:2.5.2'