Error generating signed Apk with proguard activated in Android Studio 3 - android

I cannot create a signed apk if proguard is active. If not it works.
The error is:
Warning:Exception while processing task java.io.IOException:
Can't write [C:\Users....\AndroidStudioProjects\BStats\app\build\intermediates\transforms\proguard\release\0.jar]
(Can't read [C:\Users.....gradle\caches\transforms-1\files-1.1\play-services-auth-base-11.0.1.aar\37c6010cc8e9c38e6022a124120862be\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [com/google/android/gms/b/ju.class == classes.jar:com/google/android/gms/internal/zzei.class]))
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
my gradle file:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:animated-vector-drawable:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:customtabs:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
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'
// Facebook stuff
// Android SDK
implementation 'com.facebook.android:facebook-android-sdk:4.+'
// Audience Network SDK. Only versions 4.6.0 and above are available
implementation 'com.facebook.android:audience-network-sdk:4.+'
// Account Kit
implementation 'com.facebook.android:account-kit-sdk:4.+'
Why is it complaining about play-services-auth-base-11.0.1.aar if I don't even use it?
Why does it work if not using proguard?
Apreciate your help. Other similar cases use the libs that are being nominated, and the fix is just a matter of having the right versions. This is not the case.
My proguard:
-keepattributes Signature
-dontwarn com.google.android.gms.** - if not I have lots of warnings - and I don't even use com.google.android.gms in my app.
Thanks.

Delete build folder from app and run if not work than try Invalidate Caches/Restart.
Happy coding!!

Very strange...
I made this change:
// Android SDK
implementation( 'com.facebook.android:facebook-android-sdk:4.+' ){
exclude group: 'com.google.android.gms'
}
// Audience Network SDK. Only versions 4.6.0 and above are available
implementation( 'com.facebook.android:audience-network-sdk:4.+'){
exclude group: 'com.google.android.gms'
}
// Account Kit
implementation( 'com.facebook.android:account-kit-sdk:4.+'){
exclude group: 'com.google.android.gms'
}
And now the APK is being generated with Proguard. I didn't test it yet to see if the Facebook integration works properly. In case it does, I think this should be better explanined in the documentation.

Related

How to install "Cloud Text-To-Speech" with Gradle?

I would like to use Cloud Text-To-Speech.
On the documentation page I see that I have to install the client library. On that page you see the code for Maven but in my Android Studio, I am using Gradle and I have no idea how to install it with Gradle.
On MVNRepository I have noticed that I have to use compile group: 'com.google.cloud', name: 'google-cloud-texttospeech', version: '1.2.1'. So on on my application (app -> build.gradle), I have inserted that line to the dependencies. So it looks like this:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
compile group: 'com.google.cloud', name: 'google-cloud-texttospeech', version: '1.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
But that gives me the error: More than one file was found with OS independent path 'META-INF/INDEX.LIST'.
Also, Android Studio tells me "compile is deprecated; replace with implementation". If I replace it, I'll get the error: Cannot fit requested classes in a single dex file (# methods: 151443 > 65536)
I also tried to use:
packagingOptions {
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/DEPENDENCIES'
}
I cleaned my project and restarted the app but then I get the error: Cannot fit requested classes in a single dex file (# methods: 147675 > 65536)
This is too annoying! How can I simply install that library??
Instead of compile group: 'com.google.cloud', name: 'google-cloud-texttospeech', version: '1.2.1', I needed to use implementation 'com.google.cloud:libraries-bom:4.3.0'.

How to resolve all google play-services dependencies with gradle?

Situation
Today, after touching nothing of the project, my gradle yelled at me and wouldn't compile the project. It failed to resolve firebase-iid, firebase-common, play-services-analytics-impl, play-services-auth-api-phone, and play-services-auth-base. So quite a mess after the weekend.
So I checked the versions of the different APIs, and upgraded the ones that needed upgrading, found out that Google had added a mandatory dependency to firebase-core, added it, then upgraded my google-services plugin, and even added a play-services-base dependency. I also upgraded firebase-messaging to version 17.0.0, and crashlytics to version 2.9.3.
But still, the build doesn't compile, with this error message:
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.2,15.0.2], [15.0.4,15.0.4]], but resolves to 15.0.4. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
Gradle Files
Here is my Gradle file (showing dependencies part only), after my attempted fixes:
apply plugin: 'com.android.application'
...
dependencies {
implementation project(':library')
implementation project(':otherlibrary')
implementation 'com.android.volley:volley:1.1.0'
implementation('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-analytics:15.0.2'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation('com.google.android.gms:play-services-ads:15.0.1') {
exclude group: 'com.android.support', module: 'customtabs'
}
implementation 'com.google.android.gms:play-services-identity:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-drive:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.daimajia.slider:library:1.1.5#aar'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:exifinterface:27.1.1'
implementation 'com.android.support:support-v13:27.1.1'
// https://mvnrepository.com/artifact/com.darwinsys/hirondelle-date4j
implementation group: 'com.darwinsys', name: 'hirondelle-date4j', version: '1.5.1'
// For RxAndroid and RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
// (see https://github.com/ReactiveX/RxJava/releases for latest 2.x.x version)
implementation 'io.reactivex.rxjava2:rxjava:2.1.12'
// Crashlytics
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'
// CSV with outputstream writer
implementation 'com.opencsv:opencsv:4.1'
// Gson
implementation 'com.google.code.gson:gson:2.8.5'
debugImplementation 'com.android.support.test:runner:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
androidTestImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
And my project-wide gradle contain these lines:
...
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
...
}
dependencies {
...
classpath 'com.google.gms:google-services:4.0.1'
}
...
Official solution doesn't work
I already tried to fix the version number of multiple libraries according to the official firebase documentation, which is more or less the same as this question.
As you can read in the official documentation link, as of May 2nd, 2018, they offered a way to fix this kind of issue, but the numbers of the versions in question are not the same, and I already tried the given fix (with some downgrades now), to no avail.
Official documentation:
If your app has a dependency on com.google.firebase:firebase-core:15.0.0 as well as any of the following libraries:
com.google.android.gms:play-services-analytics
com.google.android.gms:play-services-appinvite
com.google.android.gms:play-services-tagmanager
com.google.firebase:firebase-analytics
com.google.firebase:firebase-crash
com.google.firebase:firebase-dynamic-links
com.google.firebase:firebase-messaging
You will need to update the version of the latter dependency to
15.0.2. This addresses the issue where version 3.3.0 of the Google Services Gradle plugin reports: The library
com.google.android.gms:play-services-measurement-base is being
requested by various other libraries at [[15.0.0,15.0.0],
[15.0.2,15.0.2]], but resolves to 15.0.2...
So how can I resolve these conflicts of versions in order for my build to compile once again correctly?
So after a day lost in this issue, I found out that the latest version of play-services-analytics is not the one they have published in their website. It is 16.0.0 and not 15.0.2.
Android Studio told that to a colleague as a warning, but mine was unconcerned about it. So here it is, the line that changes everything:
implementation 'com.google.android.gms:play-services-analytics:16.0.0'
I added this to my build.gradle (application version) and it worked:
googleServices { disableVersionCheck = true }
(Keep in mind that this is just to disable the version check, it does not actually fix anything)
I tried reverting back to an old build, and it seemed to work, what i found was that the gradle-wrapper.properties was using and older version (4.5) instead of the 4.6 i had in the newer project. Changing this as well as reverting to classpath 'com.android.tools.build:gradle:3.2.0-alpha08' from alpha15 seemed to do the trick. I think you can use the alpha 15 if you like, but to be sure you can use the classpath 'com.android.tools.build:gradle:3.1.2'.
Along with all these changes the firebase-core and the google-gms-services should be set to version 16.0.0.
Unfortunately google play service has been stopped
This widows msg are generated &never run any google service performs

Glide java.lang.NoSuchMethodError: No virtual method

I'm facing an issue regarding Glide library.
I used couple of multiimagepicker API's from github
but whenever i click for selecting image
it crashes.
every API crash because of this error
java.lang.NoSuchMethodError: No virtual method
load(Ljava/lang/String;)Lcom/bumptech/glide/DrawableTypeRequest; in
class Lcom/bumptech/glide/RequestManager; or its super classes
(declaration of 'com.bumptech.glide.RequestManager' appears ...)
I'm badly stuck due to this error.
i searched on glide forum but still no proper answer found. many looking for answer of this error
Build.gradle:
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.mikepenz:aboutlibraries:5.9.7#aar') {
transitive = true
exclude group: 'com.android.support'
}
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:cardview-v7:26.0.+'
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.github.lolucosmin:PermissionsWrapper:version_1.2'
compile 'com.github.javiersantos:BottomDialogs:1.2.1'
compile 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
compile 'com.appyvet:materialrangebar:1.4'
compile 'com.github.vivchar:ViewPagerIndicator:v1.0.1'
compile 'com.github.bumptech.glide:glide:4.2.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
compile 'com.github.chathuralakmal:AndroidImagePopup:1.2'
compile 'com.ss.bannerslider:bannerslider:1.8.0'
compile 'org.aviran.cookiebar2:cookiebar2:1.0.5'
compile 'com.github.hamsaadev:RTLMaterialSpinner:V1.0.1'
compile 'com.github.darsh2:MultipleImageSelect:v0.0.4'
}
I got the same error using the currently latest version: 4.7.1
The error is likely to cause because of your dependencies, to me, downgrading the Glide version to 4.3.1 worked fine.
implementation'com.github.bumptech.glide:glide:4.3.1'
By the way, use the term implementation, rather than compile as it will be removed this year.
This solution might not work for you, because your version is already 4.2.0
But anyway, Hope it works!
after migrating android to androidx
and upgrading the gradle to newer version I had some problems with glide..
after trying version one by one... this version was the only one that works for me..
recommending on glide 4.8.0
with the newer and with the elders i had some problems.. maybe this version will works for you too..
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.android.support:support-annotations:28.0.0'
annotationProcessor 'com.android.support:support-annotations:28.0.0'
maybe you will find here some info that might help..
https://github.com/bumptech/glide/releases
You are facing this error because MultipleImageSelect:v0.0.4 using old glide version and your project using newer version. When Gradle builds your project, It uses a newer version of Gradle and MultipleImageSelect:v0.0.4 will crash internally. You can confirm this in External libraries of project in android studio. Use same version of glide will solve this problem. Either downgrade your project's version of check latest version of MultipleImageSelect.

Cannot resolve error in Firebase Chat application

Im trying chat application using firebase. Im getting following error which could nit resolve myself,
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzble.class
I have mentioned below my gradle file
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.google.firebase:firebase-core:10.2.4'
compile 'com.android.support:design:25.3.1'
compile 'com.firebaseui:firebase-ui:1.1.1'
compile 'com.google.firebase:firebase-auth:10.2.4'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
FirebaseUI has transitive dependencies on a number of the Firebase libraries. You must specify a version of FirebaseUI that is compatible with the Firebase libraries you are using. The table of compatible versions is listed in the FirebaseUI documentation. The most recent FirebaseUI version is 1.2.0, which works with library version 10.2.0. A version of FirebaseUI for Firebase libs 10.2.4 and 10.2.6 has not been released.
The safe change is:
compile 'com.firebaseui:firebase-ui:1.2.0'
compile 'com.google.firebase:firebase-auth:10.2.0'
You could try 1.2.0 with 10.2.4 or 10.2.6, but may encounter the same problem you are seeing now.

Google Maps conflict dependency in Gradle

I have tried to add a Google Map fragment to my android app. I add the dependency
compile 'com.google.android.gms:play-services-maps:8.1.0'
However when I try to sync the gradle build file I get the error
Warning:Conflict with dependency 'com.android.support:support-annotations'.
Resolved versions for app (22.2.0) and test app (23.0.1) differ.
On the advice of another stack overflow answer we ran the Gradle dependencies report, and found that the only package that includes the module 22.2.0 is the google play one itself.
I have tried to exclude the module but this is to no avail.
Has anyone solved this problem? Any help would be much appreciated.
I attach the relevant part of the build.gradle file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
//./compile 'com.android.support:appcompat-v7:19.1.0'
androidTestCompile ('com.android.support.test:runner:0.4') {
exclude module: 'support annotations'
}
// Set this dependency to use JUnit 4 rules
androidTestCompile ('com.android.support.test:rules:0.4') {
exclude module: 'support annotations'
}
// Set this dependency to build and run Espresso tests
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.1') {
exclude module: 'support annotations'
}
// Set this dependency to build and run UI Automator tests
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-maps:8.1.0'
}
You are not excluding the support annotations module from your testing libraries because of a small typo. Change "support annotations" to "support-annotations" in your exclude statements.
exclude module: 'support-annotations'
Huh! Faced this issue in the morning and now seeing this question.
I resolved by adding the following additional dependency:
androidTestCompile 'com.android.support:support-annotations:22.+'
I was not sure of the correct resolving version thereby kept with wildcard '+', if you are sure replace the wildcard with the right one.

Categories

Resources