Im having a problems when trying to implement gcm. When I try to sync gradle files this error appears:
Warning:Gradle version 2.8 is required. Current version is 2.4. If using the gradle wrapper, try editing the distributionUrl in D:\MyProjects\Android\Enjoy\gradle\wrapper\gradle-wrapper.properties to gradle-2.8-all.zip
Tried to go to wrapper and change it to 2.8, but its still not working.
Here is my app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "enjoy.enjoyprague_restaurants_bars"
minSdkVersion 17
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.txt'
exclude 'META-INF/NOTICE.txt'
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
// android libraries activity, design
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
// application
compile 'com.android.support:multidex:1.0.1'
// volley for handlers
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.4'
// picasso
compile 'com.squareup.picasso:picasso:2.5.2'
// simple xml
compile('org.simpleframework:simple-xml:2.7.1') {
exclude group: 'stax', module: 'stax-api'
exclude group: 'xpp3', module: 'xpp3'
}
// floating action menu
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
// Google Map api
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4'
}
//google gcm sender
apply plugin: 'com.google.gms.google-services'
and top level build 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 {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Open gradle folder in your project directory, and change gradle wrapper properties file. (you can find that last line indicating the path to gradle used in build). You may find it incorrect (e.g. http\://) fix it to (http://)
Ok, so, Android Studio is very buggy. Now, what you need to do is go to this question and do exactly as they said there. Take it to offline and that stuff. It will work, guaranteed.
https://stackoverflow.com/a/21996772/4458300
Use Graddle Wrapper
1)
Check distributionUrl and see if it is specified as gradle-2.8.zip at the Gradle-wrapper properties file within the Android project.
Project/gradle/wrapper/gradle-wrapper.properties
Run Gradle Wrapper at the top level of the project
Unix:
./gradlew wrapper
Windows:
gradlew.bat wrapper
Build with Gradle Wrapper.
Unix:
./gradlew build
Windows:
gradlew.bat build
Find in your project's structure in Android Studio this file
Open gradle-wrapper.properties and change this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
It should work
Related
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
I had this problem after updating com.android.tools.build:gradle from project to 2.3.0-beta1.
If I set back to 2.2.3, the Theme.AppCompat style recognizes.
I don't want to set it to 2.2.3 because the project can't be out of time.
Here is the error's print:
My project's build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
My app's build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.xxxxxxx.xxxxxxx"
minSdkVersion 19
targetSdkVersion 25
versionCode 76
versionName "1.18.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
useLibrary 'org.apache.http.legacy'
}
buildscript {
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
repositories {
maven {
url 'https://maven.fabric.io/public'
}
}
}
repositories {
maven {
url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/"
}
maven {
url 'https://maven.fabric.io/public'
}
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('de.keyboardsurfer.android.widget:crouton:1.8.5#aar') {
exclude group: 'com.google.android', module: 'support-v4'
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile(name: 'libctfclient-sdk', ext: 'aar')
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:support-v13:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.github.gabrielemariotti.cards:library:1.8.0'
compile 'com.github.gabrielemariotti.cards:library-extra:1.8.0'
compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:0.9.9'
compile 'com.embarkmobile:zxing-android-minimal:2.0.0#aar'
compile 'com.embarkmobile:zxing-android-integration:2.0.0#aar'
compile 'com.google.zxing:core:3.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.android.gms:play-services-analytics:9.8.0'
compile 'com.github.nkzawa:socket.io-client:0.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
}
In order of that error, I have this problem:
I already tried:
Invalidate Caches\Restart;
Update android support library to the last version;
Clean and Rebuild the project;
Does anyone know how to solve this problem without setting project's build.gradle to 2.2.3?
As said in this answer https://stackoverflow.com/a/42765120/3825764,
"build cache" is enabled by default in build Android Plugin since 2.3.0. It creates files in build cache outside of project folder (e.g. in \Users\%username%.android\build-cache). Theese files are intended to be common between your projects.
And then Android Studio is unable to navigate in theese files.
You can disable Build Cache in gradle.properties file. just add android.enableBuildCache=false
I used android.tools.build:gradle:2.3.0-beta3 and had the same problem. I've upgraded Android Studio 2.2.3 to 2.3 beta 2 and everything had worked.
File -> Invalidate Caches / Restart did not resolve the issue.
Preferences -> Build, Execution, Deployment -> Gradle showed Use local gradle distribution selected with Gradle home: /Applications/Android Studio.app/Contents/gradle/gradle-2.14.1 and a warning displayed saying the gradle location was incorrect.
Resolved issue by selecting Use default gradle wrapper (recommended).
Probably just pointing to the new local distribution location would also work.
Try: File -> "Invalidate Cashes\Restart"
Can be just problem of android studio
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!
I am getting these two error messages when trying to compile:
/Users/dericw/coding/myApplication/lfdate/android/app/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.2.1/res/values-v23/values-v23.xml
Error:(3, 5) No resource found that matches the given name (at 'cardBackgroundColor' with value '?android:attr/colorBackgroundFloating').
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/dericw/Library/Android/sdk/build-tools/23.0.2/aapt'' finished with non-zero exit value 1
Android Studio then opens up v23/values-23.xml with this style:
<style name="CardView" parent="Base.CardView">
<item name="cardBackgroundColor">?android:attr/colorBackgroundFloating</item>
</style>
But I don't have that defined anywhere in my app. It is a generated file that is giving me the error. I am pretty stumped on how to fix this issue? Has anyone every encountered this before? How do I fix this?
Project Build File
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
}
}
allprojects {
repositories {
jcenter()
}
}
App Build File
buildscript {
repositories {
mavenCentral()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 22
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.something.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 200
versionName "1.7.1"
}
buildTypes {
debug {
versionNameSuffix '-debug'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
zipAlignEnabled true
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
sourceSets {
androidTest.setRoot('src/test')
}
}
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.crashlytics.sdk.android:crashlytics:2.4.0#aar') {
transitive = true;
}
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile project(':viewPagerIndicator')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.mcxiaoke.volley:library:1.+'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'joda-time:joda-time:2.+'
compile 'com.koushikdutta.async:androidasync:2.+'
compile 'com.edmodo:rangebar:1.+'
compile 'org.lucasr.twowayview:twowayview:0.+'
compile 'com.github.amlcurran.showcaseview:library:5.4.+'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.+'
compile 'com.getbase:floatingactionbutton:1.+'
compile 'com.mixpanel.android:mixpanel-android:4.+'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile 'com.wefika:flowlayout:0.+'
compile 'com.hudomju:swipe-to-dismiss-undo:1.+'
compile 'com.soundcloud.android:android-crop:1.0.1#aar'
compile 'com.squareup.picasso:picasso:2.+'
}
apply plugin: 'com.google.gms.google-services'
compile 'com.facebook.android:facebook-android-sdk:4.+' needs V-23
Change the facebook version SDK to 4.8.0 then it won't use that resource file. Then your code will be up & running/
I also had this issue. I solved by forcing an older version of the card view library as the issue is with that.
compile('com.android.support:cardview-v7:23.2.0') {
force = true
}
The issue was with 23.2.1 of card view, the Facebook SDK uses this library.
If you are using the "cordova-plugin-facebook4" plugin, please remove the plugin from your project and pull it again (the latest version), then add it back to your project.
At the same time, please check the xml file, which is locate at yourCordovaProject/plugin/cordova-plugin-facebook4/plugin.xml around line No. 64, it must be 4.8.+ :
<framework src="com.facebook.android:facebook-android-sdk:4.8.+"/>
For a temporary fix I solved my issue changing the project.properties:
vi platforms/android/project.properties
and changed from target=android-22 to target=android-23
For a permanent fix you just need to update the android platform:
cordova platform update android --save
For Phonegap Build users, try this. It worked for me.
<plugin spec="https://github.com/jeduan/cordova-plugin-facebook4#aff9a08a86cc6c6a18019f7adc2896ddf97c11cd" source="git" >
my system already had 23 installed. from project panel, Application -> Open module setting (F4) -> application -> Properties tab. I had Compile Sdk Version Android 5.50 (lollipop). So I changed to API 23+ and it worked.
So I checked Application build.gradle changed
from compileSdkVersion 21
buildToolsVersion "23.0.3"
to
compileSdkVersion 'android-N'
buildToolsVersion "23.0.3"
so I"m guessing you can simply change compoileSdkVersion to your buildTollVersion.
I've fixed it removing the plugin:
cordova plugin remove cordova-plugin-facebook4
And installing it again from this commit:
cordova plugin add https://github.com/jeduan/cordova-plugin-facebook4\#aff9a08a86cc6c6a18019f7adc2896ddf97c11cd --save --variable APP_ID="YOUR_FB_APP_ID" --variable APP_NAME="YOUR_FB_APP_NAME"
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'