I have added these line to integrate firebase notification to my app
build.gradle(module:app)
apply plugin: 'com.android.appname'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs')
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.facebook.android:audience-network-sdk:4.21.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
build.gradle(project:appName)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
If I try to run app after adding those dependencies then it shows the following error:
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzcn$zza.class
A dependency report shows that audience-network-sdk has a transitive dependency on com.google.android.gms:play-services-ads:8.4.0. This is the source of the conflict.
I don't use the Facebook libs and am not sure of the best solution. These two options will both allow you to build. I don't know if each will support your code. You'll have to experiment:
Option 1:
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile ('com.facebook.android:audience-network-sdk:4.21.1', {
exclude group: 'com.google.android.gms', module: 'play-services-ads'
})
compile 'com.google.firebase:firebase-messaging:10.0.1'
Option 2:
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.facebook.android:audience-network-sdk:4.21.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
Try adding packagingOptions in build.gradle after buildTypes
Code For packagingOptions
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
Edited Code
apply plugin: 'com.android.appname'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
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')
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.facebook.android:audience-network-sdk:4.21.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
Related
I was working on an older version of firebase and everything was working fine, then i updated it to 11.8.0 but i got errors all over the project
'Cannot resolve symbol R' in the java classes
errors from v26\values-v26.xml file in the screenshoot:
here is my gradle files:
build.gradle
apply plugin: 'com.android.application'
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.google.firebase.udacity.friendlychat"
minSdkVersion 16
targetSdkVersion 25
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:design:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
//firebase
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.firebaseui:firebase-ui-auth:3.2.1'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (Module:app)
apply plugin: 'com.android.application'
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.google.firebase.udacity.friendlychat"
minSdkVersion 16
targetSdkVersion 25
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:design:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
//firebase
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.firebaseui:firebase-ui-auth:3.2.1'
}
apply plugin: 'com.google.gms.google-services'
I rebuild the project and cleaned it but nothing was solved.
Update your gradle from version 25 to 26
compileSdkVersion 25
buildToolsVersion "25.0.2"
to
compileSdkVersion 26
buildToolsVersion "26.0.1"
And dependencies
compile 'com.android.support:design:26.0.0'
compile 'com.android.support:appcompat-v7:26.0.0'
While building APK for my android app the following error is shown:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzb;
I couldn't find what the error was. My module:app gradle file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "27.0.0"
defaultConfig {
applicationId "//my application"
minSdkVersion 15
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 {
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.android.support:design:26.+'
compile 'com.android.support:support-v4:26.+'
compile 'com.google.android.gms:play-services-fitness:11.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.6.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
I read somewhere that Unless you have an absolute need to enable multiDex in your build.gradle DO NOT DO IT!
But when i removed the line from gradle file,
compile 'com.google.firebase:firebase-messaging:9.0.1'
then building apk was successful.
Since i need firebase in my application, this wouldn't be a solution for me.
can anyone help me?
You need to use same version of dependencies
Use this
compile 'com.google.android.gms:play-services-fitness:11.0.0'
compile 'com.google.firebase:firebase-messaging:11.0.0'
Instead of this
compile 'com.google.android.gms:play-services-fitness:11.0.0'
compile 'com.google.firebase:firebase-messaging:9.0.1'
Build gradle file
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.imageditor.Image"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
Trying to run app the following error occurs:
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.
I changed different versions but it didn't work again
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.mher.loginregister"
minSdkVersion 25
targetSdkVersion 19
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(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.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.google.firebase:firebase-database:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
2)
// 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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You need to use the same version of all the Firebase and Google dependencies.
Use this:
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.google.firebase:firebase-database:9.2.0'
Note the difference in the version number for firebase-database.
This is how your build.gradle should look like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.mher.loginregister"
minSdkVersion 25
targetSdkVersion 19
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(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.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.google.firebase:firebase-database:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
I am Importing my project from Eclipse , while building an APK i found following Error.
Error:Execution failed for task
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/plus/PlusOneButton$OnPlusOneClickListener.class
Error:Execution failed for task ':gruhini:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/games/Game.class
Error:Execution failed for task ':gruhini:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/GoogleAuthException.class
Error:Execution failed for task ':gruhini: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.0.0.
my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
useLibrary 'org.apache.http.legacy'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/**'
}
defaultConfig {
applicationId "com.gruhini"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
incremental true
preDexLibraries false
//javaMaxHeapSize "1G" // 2g should be also OK
}
}
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 project(':eclipseProject')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/google-play-services.jar')
compile files('libs/httpclient-4.1.jar')
compile files('libs/httpcore-4.1.jar')
compile files('libs/httpmime-4.1.jar')
compile files('libs/itextpdf-5.2.1.jar')
compile files('libs/mail.jar')
compile files('libs/mpandroidchartlibrary-1-7-4.jar')
compile 'com.android.support:support-v4:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
}
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/google/android/gms/plus/
Problem
compile files('libs/google-play-services.jar') // Remove this line
compile 'com.google.android.gms:play-services:10.2.0' //10.0.1 or 9.6.0
Both are same .Call one of them .
Then Clean-Rebuild and Run .
Try with this App Level build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "com.gruhini"
minSdkVersion 15
targetSdkVersion 25
versionCode 12
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
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'
})
testCompile 'junit:junit:4.12'
compile project(':eclipseProject')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/httpclient-4.1.jar')
compile files('libs/httpcore-4.1.jar')
compile files('libs/httpmime-4.1.jar')
compile files('libs/itextpdf-5.2.1.jar')
compile files('libs/mail.jar')
compile files('libs/mpandroidchartlibrary-1-7-4.jar')
compile 'com.android.support:support-v4:25.1.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
}
Project 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.2.2' //2.2.3
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Do inside Android in your gradle file like this.
android{
configurations {
all*.exclude group: 'com.android.support', module:'support-annotations'
}
}
instead of you write inside dex option.
your gradle file will looks like..
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
useLibrary 'org.apache.http.legacy'
configurations {
all*.exclude group: 'com.android.support', module:'support-annotations'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/**'
}
defaultConfig {
applicationId "com.gruhini"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
incremental true
preDexLibraries false
//javaMaxHeapSize "1G" // 2g should be also OK
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
})
compile project(':eclipseProject')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/google-play-services.jar')
compile files('libs/httpclient-4.1.jar')
compile files('libs/httpcore-4.1.jar')
compile files('libs/httpmime-4.1.jar')
compile files('libs/itextpdf-5.2.1.jar')
compile files('libs/mail.jar')
compile files('libs/mpandroidchartlibrary-1-7-4.jar')
compile 'com.android.support:support-v4:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
}
It works Properly by Removing Following Lines from Gradle . compile fileTree(dir: 'libs', include: '*.jar')
There is a mismatch between the play-services versions being used in your packages (i.e. a package using version x, another package using version y).
None of the other answers explain why you should use play-services version x.y.z or how to check which one is applicable. You can check that with ./gradlew :app:dependencies
You will get an output similar to
| \--- com.google.android.gms:play-services-tasks:10.2.6 --> (11.0.1)(*)
+--- com.google.android.gms:play-services-basement:11.0.1 (*)
```
From this output you can see the latest version of play-services being used in your project (in the above example it's 11.0.1).
In your build.gradle file, you should specify this version for all play-services (they all must be the same version).
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: rx/Observable$23.class
This is the build.gradle file.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionName "1.1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
// Enable Java 7 features (diamond operator, string switch statements, etc.)
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
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'
apt 'com.google.dagger:dagger-compiler:2.0'
compile 'com.google.dagger:dagger:2.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.google.code.gson:gson:2.3'
compile 'com.squareup:otto:1.3.6'
compile 'com.github.frankiesardo:icepick:2.3.6'
provided 'com.github.frankiesardo:icepick-processor:2.3.6'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'org.parceler:parceler:0.2.9'
compile 'com.netflix.rxjava:rxjava-android:0.20.7'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.jakewharton:butterknife:5.1.2'
compile 'io.reactivex:rxjava-computation-expressions:0.21.0'
}
Problem
compile 'com.netflix.rxjava:rxjava-android:0.20.7' //Problem Here
compile 'io.reactivex:rxjava-computation-expressions:0.21.0'
Call io.reactivex instead of com.netflix.rxjava
Finally
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
compile 'io.reactivex:rxjava-computation-expressions:0.21.0'
Then Clean-Rebuild & Run .
EDIT
You should use latest stable version
compileSdkVersion 25
buildToolsVersion "25.0.1"
targetSdkVersion 25
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'