Duplicate entry in build.gradle zznp.class - java

I am trying to implement Applozic chat in my existing android app. I am already using MQTT for server communication in other classes and its working fine. But after downloading the Applozic library through build.gradle I am getting an error while compiling the application. Applozic also seems to be using the same MQTT technology. The error says:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zznp.class
:app:transformClassesWithJarMergingForDebug FAILED
The build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.xxxxx.xxxx.xxx"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
// Enabling multidex support.
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'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ECLIPSE_.SF'
exclude 'META-INF/ECLIPSE_.RSA'
}
}
/*allprojects {
repositories {
jcenter()
maven {
url "https://repo.eclipse.org/content/repositories/paho-releases/"
}
maven { url "https://jitpack.io" }
}
}*/
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
//testCompile 'junit:junit:4.12'
compile 'com.applozic.communication.uiwidget:mobicomkitui:4.62'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.android.volley:volley:1.0.+'
compile 'com.vlonjatg.android:app-tour:1.0'
compile 'com.mukesh:permissions:1.0.2'
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
/*compile "org.eclipse.paho:org.eclipse.paho.client.mqttv3:${rootProject.ext.clientVersion}"
compile(project(':org.eclipse.paho.android.service')) {
transitive = true
}*/
}
task publishAPK(type: Copy) {
from file("${project.buildDir}/outputs/apk/" + rootProject.ext.sampleArchivesBaseName + "-debug.apk");
into '/shared/technology/paho/Android/' + rootProject.ext.sampleVersion + '/debug/';
}
configurations.compile.exclude module: 'org.eclipse.paho.client.mqttv3'
task debug << {
configurations.compile.each { println it}
}
I do not understand why the error shows up. Which library is causing the conflict? What do I need to modify in order to remove the issue?

The error is due to this compile 'com.google.android.gms:play-services:7.8.0'
lib as it is shown in the
error duplicate entry: com/google/android/gms/internal/zznp.class
:app:transformClassesWithJarMergingForDebug FAILED
try to remove this and sync the project .hope it work

Applozic android sdk is using Google play services v9.0.2 can you check by changing to v9.0.2
compile 'com.google.android.gms:play-services:9.0.2'
and if it exceeds 65k check this link
How to enable multidexing with the new Android Multidex support library

Related

"App not installed" on device error from debug apk, "File appears to be corrupt"

I am attempting to generate an apk to install to a device. I was able to do this with the same project prior to Android Studio version 3.0.0. I cannot post any error logs because the apk generates successfully, but when I try to install it on a device I get "App not installed", "File appears to be corrupt". I have been through a number of other threads to try and fix this but nothing has worked so far.
The previous version on the phone has been uninstalled.
Both Signed and unsigned have been tried.
Instant run has been disabled.
The apk has failed to install on at least 3 different devices.
I have tried downgrading my com.android.tools.build:gradle
Any help would be greatly appreciated, I feel like I've tried everything.
build.gradle (app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.will3596.mobileapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}
dependencies {
implementation 'com.android.support:support-vector-drawable:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
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:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:11.6.2'
compile 'com.google.firebase:firebase-auth:11.6.2'
compile 'com.google.firebase:firebase-database:11.6.2'
compile 'com.google.android.gms:play-services-maps:11.6.2'
compile 'com.google.android.gms:play-services-location:11.6.2'
compile 'com.google.firebase:firebase-storage:11.6.2'
compile 'com.android.support:palette-v7:26.+'
compile 'com.android.support:customtabs:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support:mediarouter-v7:26.+'
compile 'com.android.support:multidex:1.0.2'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.maps.android:android-maps-utils:0.4+'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.7.22'
androidTestCompile 'com.android.support:support-annotations:24.0.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (project):
// 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.1.1'
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 {
jcenter()
maven{
url "https://maven.google.com"
}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Let me know what else I can post to help get a solution.
Steps to generate debug apk from 3.0.0+
Build->Build APK(s).
I found the answer in another thread somewhere. In my android manifest, I had testOnly="true", set to false and it fixed.

Getting duplicate entry error after adding branch.io to my android project

Everything was working fine, but after adding this to my android project error building apk started.Here is the error and dependency
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/crashlytics/android/answers/shim/R.class
compile('io.branch.sdk.android:library:2.6.0#aar') {
transitive = true;
exclude module: 'answers-shim'
}
tried excluding it also but error persists.
Here is my full gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://dl.bintray.com/hani-momanii/maven"}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 19
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
resConfigs "en_US", "hi_IN"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.digits.sdk.android:digits:2.0.6#aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.7#aar') {
transitive = true;
}
compile('io.fabric.sdk.android:fabric:1.3.10#aar') {
transitive = true;
}
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v13:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:gridlayout-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:support-annotations:25.3.1'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-places:10.2.1'
compile 'com.amazonaws:aws-android-sdk-core:2.2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.+'
compile 'com.amazonaws:aws-android-sdk-ddb:2.2.+'
compile 'com.amazonaws:aws-android-sdk-lambda:2.2.+'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.google.firebase:firebase-crash:10.2.1'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
compile 'com.google.firebase:firebase-storage:10.2.1'
compile 'com.google.firebase:firebase-appindexing:10.2.1'
compile 'com.github.clans:fab:1.6.4'
compile 'com.amazonaws:aws-android-sdk-cognito:2.3.9'
compile 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile('io.branch.sdk.android:library:2.6.0#aar') {
transitive = true;
exclude module: 'answers-shim'
}
}
apply plugin: 'com.google.gms.google-services'
If i add the exclude statement to branch and digits then while entering the app it crashes,if added exclude to crashlytics the error persists.But without adding branch everything works perfect no error during apk build too.
I was struggling with this all day today as well. What ended up fixing it for me was rolling back branch to 2.5.9. There obviously seems to be something wrong with the new 2.6.0 release.
Another note for branch I don't have the transitive aar include so it's just
compile ('io.branch.sdk.android:library:2.5.9') {
exclude module: 'answers-shim';
}
Fixed the the issue when removed transitive = true from the dependency
compile('io.branch.sdk.android:library:2.6.0#aar') {
exclude module: 'answers-shim'
}
For those who want to use the latest version of branch.io, you have to add the following lines in your proguard file.
-dontwarn com.crashlytics.android.answers.shim.**
-dontwarn com.google.firebase.appindexing.**
-dontwarn com.android.installreferrer.api.**
With this change exclude module: answers-shim is not required in the gradle file.

duplicate entry: com/google/android/gms/internal/zzqv.class Android Studio

In my project i have implemented play-services-games,first I have tried to add
compile 'com.google.android.gms:play-services:10.0.1'
but i got into some troubles and the solutions that i found was to compile only the needed library
compile 'com.google.android.gms:play-services-games:10.0.1'
and all was great but when I've tried to add play-services-ads things got messy,I have added
compile 'com.google.android.gms:play-services-ads:10.0.1'
Now i get
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzqv.class
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.apps.fightersam"
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', include: ['*.jar'])
compile name: 'unity-ads', ext: 'aar'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.google.android.gms:play-services-games:10.0.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile project(':BaseGameUtils')
}
repositories {
flatDir {
dirs 'libs'
}
}
You have to exclude the duplicate use of an internal transitive dependency.
To find out which
gradle -q dependencies
This will give you the dependency tree. Then you can do something like
compile('com.example.m:m:1.0') {
exclude group: 'org.unwanted', module: 'x
}
I was using the latest version of FirebaseUI 2.0.0 which seemed to be incompatible with google-services:3.0.0. Therefore I downgraded FirebaseUI version to 1.2.0 and added the following code to Project level build.gradle:
allprojects {
repositories {
jcenter()
// Add the following
maven {
url 'https://maven.fabric.io/public'
}
}
}
I had a problem like this, but in my case I have two versions of the Google libraries being imported. In your case
delete this from your dependencies:
compile 'com.google.android.gms:play-services-ads:10.0.1'
Because it's imported from:
compile name: 'unity-ads', ext: 'aar'
Or do the opposite delet unity-ads and let compile 'com.google.android.gms:play-services-ads:10.0.1'
goodluck
In my case Downgrading Both 'com.google.android.gms:play-services-games:10.0.1' and 'com.google.android.gms:play-services-ads:10.0.1'
To 'com.google.android.gms:play-services-games:9.0.1' and 'com.google.android.gms:play-services-ads:9.0.1' did the trick !

Android APP cant build because of httpcore

I am getting this error when I build my android app on my Machine, it runs perfectly on my old latptop/android enviroment , I get this error. Please let me know, if you need me to show more codes.
Old laptop is running one Android 1.2.2
Gradle 2.2.1 ??
my machine runs on 2.1.1
Gradle 2.10.0
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.io.FileNotFoundException: C:\Users\Ahmad\AndroidStudioProjects\AMHAPP\app\build\intermediates\libs3\httpcore-4.3.jar
(The system cannot find the path specified)
OR
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
java.io.FileNotFoundException: C:\Users\Ahmad\AndroidStudioProjects\TestApp.gradle\2.2.1\taskArtifacts\lib\jcifs-1.3.18.jar (The system cannot find the path specified)
Note: the following for the build paths of android studio
Example:
old machine :
compile files('C:/Users/Administrator/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ftp4j-1.7.2.jar')
new machine:
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ftp4j-1.7.2.jar')
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "AMH.Code.testapp"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android.packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/jcifs-1.3.18.jar')
compile files('build/libs2/commons-io-2.4.jar')
compile files('build/intermediates/libs3/httpcore-4.3.jar')
compile files('libs/httpmime-4.0.1.jar')
compile files('libs/apache-mime4j.jar')
compile files('libs/commons-io-2.4.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ftp4j-1.7.2.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/libs2/apache-commons-net.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')
compile files('libs/core-2.2.jar')
compile files('C:/Users/Ahmad/AndroidStudioProjects/TestApp/.gradle/2.2.1/taskArtifacts/lib/libs2/zbar.jar')
compile files('libs/commons-net-3.3.jar')
compile files('libs/ksoap2-android-assembly-3.4.0-jar-with-dependencies.jar')
}
apply plugin: 'announce'
Try add this to your build.gradle
android {
useLibrary 'org.apache.http.legacy'
}
Either download jar for httpcore from here : http://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore/4.3.2
and add to your lib package and right click and add it as library
or
add gradle dependency in your gradle dependencies{} tag by adding :
compile 'org.apache.httpcomponents:httpcore:4.4.4'
and sync project.

Duplicate files copied in APK META-INF

hi im new in android development, i am trying to build my apk but i got this erorr. and i update my gradle and i got duplicate copy. how can i fix this error?
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup.okhttp/okhttp/pom.properties
File1: C:\Users\Toshiba\.gradle\caches\modules-2\files-2.1\com.squareup.okhttp\okhttp\2.0.0\4c8d1536dba3812cc1592090dc20c47a4ed3c35e\okhttp-2.0.0.jar
File2: C:\Users\Toshiba\.gradle\caches\modules-2\files-2.1\com.crashlytics.android\crashlytics\1.1.13\e821eafa1bf489a26bdb71f95078c26785b37a1\crashlytics-1.1.13.jar
and here's my build.gradle is this the error comes?
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.mymonas.ngobrol"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "0.9.0.68"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'], exclude: 'android-support-v4.jar')
compile project('libs:floatlabel')
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:support-v13:21.0.0'
compile 'com.squareup.retrofit:retrofit:1.7.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.1'
compile 'com.google.android.gms:play-services:6.1.11'
compile 'com.viewpagerindicator:library:2.4.1#aar'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.makeramen:roundedimageview:1.3.0'
compile 'com.andreabaccega:android-form-edittext:1.1.0#aar'
compile 'com.crashlytics.android:crashlytics:1.+'
}
I had the same or at least a very similar problem today with our React Native app. The problem was only on my Mac though. The only plausible explanation we could think of was that I updated a bunch of Android Studio tools and then gradle couldn't build properly with our dependencies. Anyways after excluding the pom.properties and pom.xml from okhttp I kept getting the same error but it turns out that I just had to exclude even more files. This is my complete packagingOptions in build.gradle:
packagingOptions {
exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties'
exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'
exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.xml'
exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties'
}
to solve your problem please add this to your build gradle
packagingOptions {
exclude 'META-INF/pom.properties' /*OR*/ 'META-INF/maven/com.squareup.okhttp/okhttp/pom.properties
}
It seems like okhttp and crashlytics don't work together in newer gradle versions (2.10 in my case). I fixed this by updating the crashlytics to a newer version (which is now called Fabric).
packagingOptions
{
exclude 'META-INF/maven/com.squareup.okhttp/okhttp/pom.properties
exclude 'META-INF/maven/com.squareup.okhttp/okhttp/pom.xml'
}
Please check for correct path "com.squareup.okhttp/okhttp/pom.properties" in your errorlog.

Categories