duplicate entry error after adding google services - android

I wanted to add firebase to one of my app. I integrated firebase according to firebase offical documents. but when I tried to "run" app. it gives me this warning
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzc.class
I removed all the firebase coding & removed it from gradle file. but error still exist untill I remove this line
apply plugin: 'com.google.gms.google-services'
but unfortunately I need google services to work with firebase. here is my app gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId ""
minSdkVersion 19
targetSdkVersion 22
versionCode 15
versionName "2.01"
multiDexEnabled true
}
dexOptions {
preDexLibraries = false
}
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(include: ['*.jar'], dir: 'libs')
compile files('libs/main.jar')
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.commit451:NativeStackBlur:1.0.1'
compile 'com.google.firebase:firebase-analytics:9.0.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.facebook.android:audience-network-sdk:4.11.0'
}
apply plugin: 'com.google.gms.google-services'
here is my project gradle file
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
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()
}
}

The problem was with Facebook Audience network. once I excluded google services it worked fine. If anyone having same problem change your audience network dependency like this
compile ('com.facebook.android:audience-network-sdk:4.11.0'){
exclude group: 'com.google.android.gms'
}

Add these dependencies:
compile 'com.google.android.gms:play-services-location:11.0.4'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.google.android.gms:play-services-places:11.0.4'

Add
android{
....
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
to your app's gradle file.

Add Firebase related dependencies
And Firebase related dependencies under dependencies in the same build.gradle file.
dependencies {
compile 'com.google.firebase:firebase-core:9.2.0' // this line must be included to integrate with Firebase
compile 'com.google.firebase:firebase-messaging:9.2.0' // this line must be included to use FCM
}
Update services using com.google.android.gms:play-services
If you add Firebase into an existing project which uses any function of gms:play-services, such as gps location,
you have to update their versions, too. Upon writing this tutorial, 9.2.0 works well. If you get compilation problems, you need to check find out the correct version number.
compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'com.google.android.gms:play-services-places:9.2.0'
Source:
https://www.codementor.io/flame3/send-push-notifications-to-android-with-firebase-du10860kb

Related

Build Failed: Program Type Already Present

I have searched online about this error and the issue always seems to end up being some sort of dependency conflict. I think I am supposed to add exclude after certain dependencies, but I am unsure which one(s). It's also unclear based on the error which dependency I should actually exclude; all I know is that the group is probably com.android.support...
Here's what I've tried:
Adding multiDexEnabled true to my defaultConfig block in build.gradle.
Cleaning the project in Android Studio.
Manually deleting (from the file system) the entire .gradle directory.
I've made sure compileSdkVersion and targetSdkVersion are the same.
I've made sure all my Android dependencies use the same version (namely 26.1.0).
Despite all this, I still get this error when I build:
Program type already present: android.support.compat.R$bool
and from the Java compiler:
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
F:\ExampleProject\app\build\intermediates\transforms\dexBuilder\debug\115,
F:\ExampleProject\app\build\intermediates\transforms\externalLibsDexMerger\debug\0
Here is my module's build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.myapp.exampleproject"
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.2"
}
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:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:support-compat:26.1.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.1.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.1.0'
}
and lastly, my project's build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Any help in rectifying this would be greatly appreciated.
This is a problem with Glide 4.1.0. Use the version 4.1.1 instead which fix the bug by remove the R*.class file from their dependencies. (source)
This is probably because of Glide library. Try to exclude the support library from it with:
// add support-fragment removed from Glide.
implementation "com.android.support:support-fragment:26.1.0"
implementation ('com.github.bumptech.glide:glide:4.1.0') {
exclude group: 'com.android.support'
exclude module: 'support-fragment'
exclude module: 'appcompat-v7'
}
You can see the support library inside Glide at Glide build.gradle
Solution:
implementation ('com.github.bumptech.glide:glide:4.1.0') {
exclude group: 'com.android.support'
exclude module: 'support-fragment'
exclude module: 'appcompat-v7'
}

Projects created at console.firebase.google.com must use the new Firebase Authentication SDKx available from firebase.google.com/dosc/auth

I am trying to enable GoogleSignIn for my android app and trying to run this code. I have created the json file from firebase console and pasted it in app. Enabled the google login from firebase but after running app on my phone it gives me error.
firebaseError: Projects created at console.firebase.google.com must use the new Firebase Authentication SDKx available from firebase.google.com/dosc/auth
Similar threads said to remove firebase client dependency but if I remove it I have compilation error. I also have tried to add latest dependency from the docs but no luck.
my gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE-FIREBASE.txt'
}
}
dependencies {
compile 'com.firebase:firebase-client-android:2.0.3+'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.google.android.gms:play-services:5.0.89'
compile 'org.twitter4j:twitter4j-core:4.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
What am I missing? What dependency I have to add other than firebase -client because if I add the latest the code still doesnt work.
Edit: After removing
compile 'com.firebase:firebase-client-android:2.0.3+'
compile 'com.google.android.gms:play-services:5.0.89'
And adding
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.google.android.gms:play-services-auth:10.2.0'
So my dependency looks like this
dependencies {
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'org.twitter4j:twitter4j-core:4.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
But for Above dependency now I have compilation issues in my code like.
For import com.firebase.client.Firebase; Cannot find the symbol client
import com.google.android.gms.plus.Plus; Cannot find the symbol plus
I have just created new project from link. It 's really easy to follow and sign in. Firebase did all work. You can discover the link below to know which configuration you missed.
Link to test sing in Google project

No resource found that matches the given name (at 'cardBackgroundColor' with value '?android:attr/colorBackgroundFloating')

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"

Failed to resolve: com.firebase:firebase-client-android:2.3.1

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'

cloud messaging and android

I am trying to implement google cloud messaging and push notifications on my android app
I am following official google tutorial , I am using android studio
https://developers.google.com/cloud-messaging/android/client
and I am getting this error
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2
here is my build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/notice.txt'
}
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "com.myapp.example"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets.main {
jniLibs.srcDir 'libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'org.java-websocket:Java-WebSocket:1.3.0'
compile 'com.github.nkzawa:socket.io-client:0.3.0'
compile 'rongi.rotate-layout:rotate-layout:1.0.1'
compile 'com.vdurmont:emoji-java:2.0.1'
compile 'commons-lang:commons-lang:2.5'
compile 'com.github.javadev:underscore:1.6'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.2.0'
compile 'com.beardedhen:androidbootstrap:1.1.1'
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.reginald.swiperefresh:library:1.1.1'
compile 'com.makeramen:roundedimageview:2.2.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.github.d-max:spots-dialog:0.4#aar'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'in.srain.cube:grid-view-with-header-footer:1.0.12'
compile 'com.vstechlab.easyfonts:easyfonts:1.0.0'
}
also here is my project build.gradle file
// 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.2.3'
classpath 'com.google.gms:google-services:1.4.0-beta3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
After some-days and nightmares, Finally I can defeat the problem and believe it could be of help to others.
Because of my massive coded project, test and checking each advice takes about 5 minutes of my system to build. I examined almost all of SO community suggestions and I wanna conclude them here:
This is most likely a problem with the dependencies you have listed in your build.gradle file for you app.
Things I do not recommend:
Unless you have an absolute need to enable multiDex in your
build.gradle DO NOT DO IT, this is just stepping over the
underlying problem in your app and not getting to the root of it. You
are also unnecessarily increasing the size of your apk, and there
could be unexpected crashes when there is a conflicting method in your
dex file.
Things to look out for:
Check all your dependencies in your build.gradle file if you have any
duplication. Are you referencing a dependency that also includes a
dependency you have already included? For example, if your including
appcompat-v7 there is no need to include appcompat-v4 since v7
includes all features from v4.
My Issue: GOOGLE PLAY SERVICES >> causing my app to exceed method limit in my dex file.
If you do not need all the google play services library dependencies DO NOT INCLUDE this line in your build.gradle compile 'com.google.android.gms:play-services:8.3.0' and instead just use what you need!! also check if your can build correctly with lower versions of the dependency.
Google has a comprehensive list of the libraries for selectively compiling here
With all that said you probably only need to include this one line in gradle for your Google Analytics:
dependencies{
compile 'com.google.android.gms:play-services-plus:8.3.0'
}
Well Done!
take a look in your gradle console and check the exact error
i just had the same problem. i solved it with:
Clean the project (at first, gradle had a error because of multiple classes included)
only include the service you really needed from play.
https://developers.google.com/android/guides/setup#split
Add one more file in your dependency list
compile 'com.android.support:multidex:1.0.0'
and add following to your defaultconfig
defaultConfig {
//your stuff
multiDexEnabled true
}

Categories

Resources