Gradle - Couldn't expand zip cardview-v7-23.3.0.aar - java

I try to implement firebase into my app. But there is an interference between firebase and google play service.
Here is my build.gradle for the module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.nefrin.client"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.github.tajchert:nammu:1.1.3'
compile 'gun0912.ted:tedpermission:1.0.3'
compile 'com.github.jksiezni.permissive:permissive:0.2'
compile 'com.github.arimorty:floatingsearchview:2.0.3'
//compile 'net.sf.sprockets:sprockets-android:4.0.0'
compile 'com.github.michael-rapp:android-material-dialog:4.0.2'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.google.firebase:firebase-auth:11.2.0'
}
apply plugin: 'com.google.gms.google-services'
And here is 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.1.2'
classpath 'com.google.gms:google-services:3.1.0' // google-services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When I try to run the app I get eventhough I didn't use cardview in my app:
Error:Execution failed for task ':app:prepareComAndroidSupportCardviewV72330Library'.
> Could not expand ZIP 'C:\Users\Nefrin\.gradle\caches\modules-2\files-2.1\com.android.support\cardview-v7\23.3.0\abdf83a0192c03ff190f941c6c885af18d257a2c\cardview-v7-23.3.0.aar'.
Android Studio is underlining the compile 'com.google.android.gms:play-services:11.0.4' and says:
All com.google.android.gms libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.2.0, 11.0.4. Examples include com.google.android.gms:play-services-basement:11.2.0 and com.google.android.gms:play-services:11.0.4 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

As the error says all the google libraries should use the same version.
So you should update the play-services library and use the same version as firebase:
compile 'com.google.android.gms:play-services:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0'

You need to change this line of code:
compile 'com.google.android.gms:play-services:11.0.4'
with
compile 'com.google.android.gms:play-services:11.2.0'
Hope it helps.

Related

Cannot build the app on Android Studio, google services conflicts

I am developing an app using react native and would like to use react native fcm library but for some reason I am having difficulties building the app!
My app gradle looks as below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "fi.x.y"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
manifestPlaceholders = [
'appAuthRedirectScheme': 'fi.x.y'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "8g"
}
lintOptions {
abortOnError false
}
}
task exponentPrebuildStep(type: Exec) {
workingDir '../../'
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine 'cmd', '/c', '.\\.expo-source\\android\\detach-scripts\\prepare-detached-build.bat'
} else {
commandLine './.expo-source/android/detach-scripts/prepare-detached-build.sh'
}
}
preBuild.dependsOn exponentPrebuildStep
repositories{
flatDir{
dirs "../../node_modules/react-native-background-geolocation/android/libs"
}
mavenLocal()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile(project(':react-native-firebase')) {
transitive = false
}
compile project(':react-native-vector-icons')
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.2'
compile 'com.google.android.gms:play-services:11.6.2'
compile 'com.google.android.gms:play-services-location:11.6.2'
compile 'com.google.android.gms:play-services-places:11.6.2'
compile 'com.google.android.gms:play-services-maps:11.6.2'
compile 'com.google.android.gms:play-services-ads:11.6.2'
compile project(':react-native-fcm')
compile 'com.google.firebase:firebase-core:11.6.2' //this decides your firebase SDK version
compile('host.exp.exponent:expoview:22.0.0#aar') {
exclude group: 'com.facebook.android', module: 'facebook-android-sdk'
exclude group: 'com.facebook.android', module: 'audience-network-sdk'
exclude group: 'io.nlopez.smartlocation', module: 'library'
transitive = true
}
compile ('com.facebook.android:facebook-android-sdk:4.+')
compile('com.facebook.android:audience-network-sdk:4.+') {
exclude module: 'play-services-ads'
}
compile('io.nlopez.smartlocation:library:3.2.11') {
transitive = false
}
compile(project(':react-native-background-geolocation')) {
exclude group: 'com.google.android.gms', module: 'play-services-location'
}
compile(name: 'tslocationmanager', ext: 'aar') {
exclude group: 'com.google.android.gms'
}
compile "com.google.firebase:firebase-messaging:11.6.2"
}
apply plugin: 'com.google.gms.google-services'
Error I am getting in Android Studio:
All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.8.0, 11.6.2, 11.6.0. Examples include com.google.android.gms:play-services-basement:11.8.0 and com.google.android.gms:play-services-ads:11.6.2 more...
With this warning it seems that the building succeed but when I try to run the app I get error saying as: Error:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
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 {
mavenLocal()
jcenter()
maven {
// Point to local maven repository
url "$rootDir/../.expo-source/android/maven"
}
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
In Facebook ads dependency exclude -> gms
compile ('com.facebook.android:audience-network-sdk:4.+'){
exclude group: 'com.google.android.gms'
}
And also remove following line project level build.gradle
classpath 'com.google.gms:google-services:3.1.1'
By updating everything to 11.8.0 seemed to solve the problem the build succeeded and the app is running.
Well, I do face now Package is not running at http:192.168.168.244:19901 idk how why, eventhou it seemd to worked once! I is now complaining about the debug folder cannot delete when gradle is building!
firebase-messaging and facebook have the same dependency com.google.android.gms. They have to use the same version of gms or might lead to build fail. You should exclude them as #Ranjith Kumar said. If problem still exist (like me) then upgrade/downgrade some of them.
In my case, the latest facebook sdk TODAY is ver 4.31.0
which includes gms:11.8.0, so I've to use firebase:11.8.0 for consistent.
BUT firebase-messaging:11.8.0 has a bug about notification icon.
I've to upgrade it to firebase-messaging:12.0.0. But I can't because facebook-sdk is still using gms:11.8.0.
and I finally found a stable version of them, FYI
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
api 'com.facebook.android:facebook-android-sdk:4.11.0'
api 'com.facebook.android:account-kit-sdk:4.11.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.android.gms:play-services-analytics:12.0.1'
}
Won't recommend use this if new FacebookSDK(after 4.31.0) use gms:12.0.1.

java.lang.NoSuchMethodError: No static method zzb(ZLjava/lang/Object;)V in class Lcom/google/android/gms/common/internal/zzaa; or its super classes

I've looked at Firebase documentation, then searched all github issues and also all stack overflow posts but still I'm getting this error again and again. I've been stuck for hours, please have a look. It says-
java.lang.NoSuchMethodError: No static method zzb(ZLjava/lang/Object;)V in class Lcom/google/android/gms/common/internal/zzaa; or its super classes (declaration of 'com.google.android.gms.common.internal.zzaa' appears in /data/app/com.masquerade.priyanshu.topcoder-2/split_lib_dependencies_apk.apk)
According to other stack overflow posts when i try to change firebase core and database version, i get another bunch of errors saying incompatible version.
This is build.gradle( Module: app)
apply plugin: 'com.android.application'
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.masquerade.priyanshu.topcoder"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
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'
//
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.android.support:design:26.1.0'
compile 'com.google.firebase:firebase-database:11.6.0'
compile 'com.firebaseui:firebase-ui-storage:1.0.0'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:cardview-v7:21.+'
}
apply plugin: 'com.google.gms.google-services'
This is build.gradle( Project:app ) -
// 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'
classpath 'com.google.gms:google-services:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenLocal()
maven {
url 'https://maven.fabric.io/public'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
EDIT -
Also I'm getting this warning on compile 'com.google.firebase:firebase-core:11.6.0'
The warning is -
All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.6.0, 11.4.2. Examples include com.google.android.gms:play-services-basement:11.6.0 and com.google.firebase:firebase-storage:11.4.
To solve this, please the change the following line of code from your build.gradle( Project:app ) file:
url 'https://maven.fabric.io/public'
with
url "https://maven.google.com" // Google's Maven repository
Change also this line of code:
compile 'com.firebaseui:firebase-ui-storage:1.0.0'
with
compile 'com.firebaseui:firebase-ui-storage:3.1.0'
Change also this lines of code:
compile 'com.google.firebase:firebase-core:11.6.0'
compile 'com.google.firebase:firebase-database:11.6.0'
with
compile 'com.google.firebase:firebase-core:11.4.2'
compile 'com.google.firebase:firebase-database:11.4.2'
Because Firebase/Play Services Version 11.4.2works with FirebaseUI Version 3.1.0 as seen here.
Also set multiDexEnabled to true in default config.

Getting error "package lombok doesn't exist" with Android Studio 3 RC2

I am getting the following error when trying to compile the project:
error: package lombok does not exist
And others stating that all the annotations from it can't be found.
I don't see errors in code before compiling and I didn't have this error while I was using Android Studio 3 RC1.
Here are my gradle scripts:
Project level:
// 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-rc2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App module level:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.mk.forum"
minSdkVersion 25
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
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'
compile project (':util')
compile project (':forum_core')
compileOnly 'org.projectlombok:lombok:1.16.18'
annotationProcessor 'org.projectlombok:lombok:1.16.18'
compile group: 'com.github.javafaker', name: 'javafaker', version: '0.13'
}
I've got modules too, but I think it isn't important.
I hope it is because of compileOnly annotation. Here is the doc:
blog.gradle.org/introducing-compile-only-dependencies
Dependencies required at compile time but never required at runtime, such as source-only annotations or annotation processors;
Dependencies required at compile time but required at runtime only when using certain features, a.k.a. optional dependencies;
Dependencies whose API is required at compile time but whose implementation is to be provided by a consuming library, application
or runtime environment.
It might be related to jdk9. I know that the combination of IntelliJ, lombok 1.16.18 and jdk9 currently doesn't work. But that does not explain your error message. We expect that we can release 1.16.20 within a few days (maybe tonight) that addresses this problem.
Disclosure: I am a lombok developer.

I keep receiving a gradle sync error when trying to add Firebase UI 2.3.0

Update on Question : after speaking to the creator of the Tutorial I was following trying to create Live Chat using Firebase. He told me to Change in your Gradle compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
If this is the case, what do I need to change in my dependencies in order to use this 9.4.0 version?
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' } // <= ADD THIS
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Below is the Module:app Gradle
Here is where I am trying to compile the Firebase UI in order to make a chat application within my app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.aids.a09application"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.google.firebase:firebase-core:11.2.0'
compile 'com.google.firebase:firebase-messaging:11.2.0'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.google.android.gms:play-services-maps:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0' // ADDED
compile 'com.google.android.gms:play-services-auth:11.2.0' // ADDED
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
}
apply plugin: 'com.google.gms.google-services'
This is the Error that I am getting now:
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 11.2.0.
To use version 11.2.0 of the Firebase libraries with FirebaseUI 2.3.0, you must update your dependencies as follows:
compile 'com.google.firebase:firebase-core:11.2.0'
compile 'com.google.firebase:firebase-messaging:11.2.0'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.google.android.gms:play-services-maps:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0' // ADDED
compile 'com.google.android.gms:play-services-auth:11.2.0' // ADDED
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
The addition of firebase-auth and play-services-auth is required because a version of FirebaseUI that is built with 11.2.0 is not yet available. This is explained in the FirebaseUI documentation.
You should also make these changes:
compileSdkVersion 26
buildToolsVersion "26.0.1"
The requirement for compileSdkVersion 26 is in the Google Play Services Release Notes:
When you upgrade your app’s Play services dependencies to 11.2.0 or
later, your app’s build.gradle must also be updated to specify a
compileSdkVersion of at least 26 (Android O)
Since you are using com.android.support:customtabs:26.0.1 you have to add in the repositories the "https://maven.google.com" endpoint.
All the support libraries since 25.4.0 are in the google maven repo as described here.
In your case something like;
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' } // <= ADD THIS
maven {
url "https://maven.google.com"
}
}
}
Also if you want to add the latest Firebase libraries v. 11.2.0 you have to add the same repo as described here.
You have to go to SDK Manager and download SDK Platform files for API 26 (Android 8.0) if not already installed. Then update all the support library files to version 26.0.1 like compile 'com.android.support:design:25.3.1' to compile 'com.android.support:design:26.0.1' and so on. You also need to change compileSdkVersion 25 to 26, buildToolsVersion "25.0.2" to "26.0.1" and targetSdkVersion 25 to 26. And add maven "https://maven.google.com" to repositories
Firebase is looking for support libraries of version 26.0.1. And since that is either not installed or your buildToolsVersion and compileSdkVersion are not pointing to it, gradle is unable to resolve them.

Error:(29, 17) Failed to resolve: junit:junit:4.12 Android Studio 2.1.2

I'm using Android Studio 2.1.2 and it is giving error "Error:(29, 17) Failed to resolve: junit:junit:4.12" Similar error for any third party library. I have tried removing and adding the junit library from Project Settings but still it giving same error. I'm not sure whether this proxy issue? I have checked connection from Studio for maven link and it is showing successful. Following is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
defaultConfig {
applicationId "com.example.administrator.myapplication"
minSdkVersion 17
targetSdkVersion 24
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:24.0.0'
}
Project Level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
repositories {
jcenter()
mavenCentral()
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Please let me know if I'm missing something and how to resolve this.
After lot of efforts I was able to resolve this issue. Issue lies with the proxy settings, I have added following lines in gradle.properties file and gradle synced successfully with dependencies resolved
systemProp.http.proxyHost=x.x.x.x
systemProp.https.proxyPort=xxxx
systemProp.https.proxyHost=x.x.x.x
systemProp.http.proxyPort=xxxx

Categories