I am facing an error caused by Firebase Api.
Here is error log:
Firebase API initialization failure.
java.lang.reflect.InvocationTargetException
Caused by: java.lang.IllegalAccessError: tried to access method android.support.v4.content.ContextCompat.<init>:(Ljava/lang/String;)V from class com.google.firebase.iid.zzg
And here is my gradle:
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.google.gms:google-services:3.0.0'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.google.android.gms:play-services-appindexing:9.0.0'
compile 'com.google.android.gms:play-services-analytics:9.0.0'
}
What can it be the problem?
So it looks like the Firebase dependencies themselves depend on a specific version of the com.android.support libraries. I changed all of mine to 25.1.1 (found by Android Studio complaining about different versions) and that has fixed problem for me!
So for your build.gradle:
dependencies {
...
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
...
}
Edit: This is what Android Studio is complains about when I added Firebase
After I added firebase dependency and updated gms library versions this error is fixed.
My build.gradle:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.android.support:support-v4:25.3.0'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.google.firebase:firebase-appindexing:10.2.1'
compile 'com.google.android.gms:play-services-analytics:10.2.1'
}
apply plugin: 'com.google.gms.google-services'
Related
I just install from zero Android Studio 3 and clone my project which doesn't use Android Studio 3 before. I tried to compile but gradle couldn't sync correctly.
I'm using gradle 4.3 because I search my problem on other post, but couldn't find how to fix. This is my gradle file :
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath "io.realm:realm-gradle-plugin:2.1.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And app/gradle file :
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
lintOptions {
disable 'InnerclassSeparator'
}
defaultConfig {
applicationId "fr.laway.dev.laway"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(path: ':laway_data', configuration: 'default')
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.github.clans:fab:1.6.4'
compile 'com.aurelhubert:ahbottomnavigation:1.5.1'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.android.support:multidex:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.27.0'
compile 'com.google.android.gms:play-services-auth:11.4.2'
compile 'com.google.gms:google-services:3.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Finally, my errors :
Is something missing in my gradle file?
I don't know why it's related but I just update my realm library :
classpath "io.realm:realm-gradle-plugin:4.1.1"
This was enough for finish to compile and remove all errors. Gradle still is very mysterious for me x)
From the error, gradle complaining this:
android-apt plugin is incompatible with the Android plugin. Please use
'annotationProcessor' configuration instead.
From the documentation:
Use the annotation processor dependency configuration
In previous versions of the plugin, dependencies on the compile classpath were automatically added to the processor classpath. That is, you could add an annotation processor to the compile classpath and it would work as expected. However, this causes a significant impact to performance by adding a large number of unnecessary dependencies to the processor.
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>'
}
You need to using annotationProcessor in your laway_data module build.gradle.
app level gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
//compile 'com.android.support:support-v4:23.1.1'
//compile 'com.android.support:mediarouter-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-drive:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.0'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.android.support:design:23.4.0'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.google.android.gms:play-services-ads:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
when I remove apply ( plugin: 'com.google.gms.google-services' )there is no problem but after adding it I get (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 10.0.1.)
root level gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
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
}
In my app I have these dependencies:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.package_app.name"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.android.support:design:23.2.1'
compile "com.android.support:recyclerview-v7:23.2.1"
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.google.android.gms:play-services-maps:9.4.0'
}
Below these dependencise I put
apply plugin: 'com.google.gms.google-services'
But I can't build app because return this error.
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.
So I tried to put
compile 'com.google.android.gms:play-services-maps:9.2.0'
And the app build, so my question is:
Why I can't use the last versione of services-map?
Add this line to end of build.gradle
apply plugin: 'com.google.gms.google-services'
And add this classpath (other build.gradle)
classpath 'com.google.gms:google-services:3.0.0'
I faced the same issue yesterday and solved it by doing the follows :
Firstly, make sure that you project/top level gradle file has the latest version for google services inside dependencies
classpath 'com.google.gms:google-services:3.0.0'
Secondly, make sure to put the plugin at the bottom of the gradle app file
apply plugin: 'com.google.gms.google-services'
And make sure all google services dependencies including firebase are of the same version i.e. 9.4.0
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
This is what i currently have in my app.gradle dependencies.
It happens because you are using
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
As you can find in the pom file of these dependencies:
<artifactId>firebase-analytics</artifactId>
<version>9.4.0</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>com.google.android.gms</groupId>
<artifactId>play-services-basement</artifactId>
<version>9.2.0</version>
<scope>compile</scope>
<type>aar</type>
</dependency>
they are using the com.google.android.gms libraries with 9.2.0.
Use
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
Make sure in the root build.gradle you have the latest plugin reference.
Also if you recently updated the play services and all references are good - try to clean the gradle cache by calling rm -rf ~/.gradle/cache, sometimes it helps
buildscript {
repositories {
jcenter()
}
dependencies {
//...
classpath 'com.google.gms:google-services:3.0.0'
}
}
Change this :
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
by
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
I followed this link to add Analytics to my project:
https://developers.google.com/analytics/devguides/collection/android/v4/
This is my project level build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
}
}
and this is my module build.gradle (I put the plugin at the bottom of the file):
dependencies {
compile 'com.google.android.gms:play-services-analytics:9.2.0'
compile 'com.android.support:support-v4:18.0.0'
compile 'com.android.support:appcompat-v7:18.0.0'
compile 'org.quanqi:android-view-pager-indicator:0.9.0'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
}
apply plugin: 'com.google.gms.google-services'
I followed the link step by step but I got this error:
(I'm using gralde plugin v 2.10)
What is wrong?!!!
I'm working in an Android App and a few days ago I updated my Kotlin version from 1.0.0-beta-1103 to the release candidate 1.0.0-rc-1036 and now I can't run my app for something related to Kotlin Android Extensions.
I use the apply plugin: 'kotlin-android-extensions' just like the official blog says http://blog.jetbrains.com/kotlin/2016/02/kotlin-1-0-release-candidate-is-out/ but my app doesn't recognize any view from any layout.
This is what appears on the console:
Error:(20, 8) Unresolved reference: kotlinx
Error:Execution failed for task ':app:compileDebugKotlin'.
Compilation error. See log for more details
Please help me, I'm losing my mind!
Update:
This is my buildScript in globalbuild.gradle
buildscript {
ext {
kotlin_version = "1.0.0-rc-1036"
}
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
}
The dependencies listed in the app build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// Google
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
// Kotlin
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// Square
compile 'com.squareup.okio:okio:1.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
// ReactiveX
compile 'io.reactivex:rxjava:1.0.14'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.jakewharton.rxbinding:rxbinding:0.3.0'
compile 'com.jakewharton.rxbinding:rxbinding-support-v4:0.2.0'
// DBFlow
kapt 'com.raizlabs.android:DBFlow-Compiler:2.2.1'
compile "com.raizlabs.android:DBFlow-Core:2.2.1"
compile "com.raizlabs.android:DBFlow:2.2.1"
// Otros
compile 'de.hdodenhof:circleimageview:1.3.0'
// SQLite Assets Helper
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
// Crashlytics Kit
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true
}
}
This is an import that I'm using:
import kotlinx.android.synthetic.main.activity_all_quizzes.*
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
should be defined in the project-local build.gradle file for now.
Your kotlin stdlib compile dependency should (at least while not stable) be the same as the kotlin android studio plugin version
...
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
...
buildscript {
ext.kotlin_version = '1.0.0-rc-1036'
...