Not able to generate signed apk? [DuplicatePlatformClasses error occured] - android

I am getting this error,
Error: xpp3 defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]
while generating signed apk. How can i solve this problem. Please help me!!
App Gradle,
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.casperon.app.rydepass"
minSdkVersion 17
targetSdkVersion 26
versionCode 17
versionName "4.2"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
cruncherEnabled = false
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':slideDateTimePicker')
compile project(':CountryCodePicker')
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
compile 'com.android.support:multidex:1.0.3'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.github.ybq:Android-SpinKit:1.1.0'
compile 'com.squareup:android-times-square:1.6.5#aar'
compile 'com.google.android.gms:play-services:11.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.d-max:spots-dialog:0.7#aar'
compile 'com.android.support:support-annotations:24.0.0'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.github.paolorotolo:expandableheightlistview:1.0.0'
compile 'com.github.ganfra:material-spinner:1.1.0'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'com.googlecode.libphonenumber:libphonenumber:8.7.0'
compile 'com.github.jakob-grabner:Circle-Progress-View:v1.2.2'
compile 'me.drakeet.materialdialog:library:1.2.2'
compile 'com.wang.avi:library:1.0.1'
compile 'com.android.support:design:24.0.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.prolificinteractive:material-calendarview:1.4.2'
compile 'org.igniterealtime.smack:smack-android:4.1.0-rc1'
compile 'org.igniterealtime.smack:smack-tcp:4.1.0-rc1'
compile 'org.igniterealtime.smack:smack-im:4.1.0-rc1'
compile 'org.igniterealtime.smack:smack-extensions:4.1.0-rc1'
compile 'net.hockeyapp.android:HockeySDK:3.5.0'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
compile 'org.jsoup:jsoup:1.8.3'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.crazy1235:RichEditText:v2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'com.squareup:android-times-square:1.6.5#aar'
//noinspection DuplicatePlatformClasses
/* compile 'org.apache.httpcomponents:httpclient:4.5'*/
'org.apache.httpcomponents:httpclient:jar:4.5.6'
configurations {
all {
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}

Try this,
configurations {
all*.exclude group: 'xpp3', module: 'xpp3'
compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}

I had similar problem. Apache library had been used in whole project and I couldn't exclude this library. Today I tried using jar file instead and it worked. You can download apache http library jar files from here:
https://jar-download.com/artifacts/org.apache.httpcomponents

Related

Android apt plugin is incompatible use 'annotationProcessor' configuration instead [duplicate]

This question already has answers here:
Incompatible plugins for android-apt after upgrading to Android Studio 2.3
(5 answers)
Android Studio Warning: Using incompatible plugins for the annotation processing
(4 answers)
Closed 5 years ago.
hi i'm trying to implement imgly SDK to my app but i get this error when i add sdk compile in Build.Gradle file . i tried to add annotationProcessor "com.google.dagger:dagger-compiler:2.6" but still doesn't work
Error:android-apt plugin is incompatible with the Android Gradle
plugin. Please use 'annotationProcessor' configuration instead.
apply plugin: 'com.android.application'
apply plugin: 'com.mutualmobile.gradle.plugins.dexinfo'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
defaultConfig {
applicationId "maa.myapp"
minSdkVersion 15
targetSdkVersion 26
versionCode 8
versionName "4.1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
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'
}
}
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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'
})
//notifications
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.github.chrisbanes:PhotoView:2.1.3'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:support-v4:26.1.0'
compile ("com.github.bumptech.glide:glide:4.5.0") {
exclude group: "com.android.support"
}
compile 'com.google.dagger:dagger:2.6'
annotationProcessor "com.google.dagger:dagger-compiler:2.6"
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.firebase:firebase-jobdispatcher:0.6.0'
compile 'com.vodyasov:amr:0.5'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
compile 'com.google.guava:guava:23.6-android'
testCompile 'junit:junit:4.12'
compile 'com.squareup:otto:1.3.8'
compile 'ly.img.android:photo-editor-sdk:5.0.13'
apt 'ly.img.android:build-processor:5.0.13'
}
apply plugin: 'com.google.gms.google-services'

Error:Execution failed for task ':app:transformClassesWithDexForDebug' in android [duplicate]

This question already has answers here:
DexIndexOverflowException Only When Running Tests
(4 answers)
Closed 5 years ago.
I am stuck with this error for 2 days.
Error:Execution failed for task
':app:transformClassesWithDexForDebucom.android.build.api.transform.Transfor
mException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.dex.DexIndexOverflowException:
method ID not in [0, 0xffff]: 65536
Here is the gradle file:
apply plugin: 'com.android.application'
android
{
compileSdkVersion 26
buildToolsVersion "26.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.pos"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
// multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'LICENSE.txt'
exclude 'asm-license.txt'
exclude 'META-INF/ASL2.0'
} }
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:support-v4:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
// compile files('libs/gson-2.2.2.jar')
compile files('libs/picasso-2.0.0.jar')
compile files('libs/upg_bridge.jar')
compile files('libs/log4j-1.2.16.jar')
compile files('libs/posindev.jar')
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.google.code.gson:gson:2.7'
// compile 'com.google.android.gms:play-services-base:10.2.0'
compile 'com.google.android.gms:play-services-base:10.2.1'
compile 'com.jakewharton.timber:timber:4.5.1'
compile project(':commerce-driver-uat-2.27.0.157')
compile project(':ingenico-uat-2.27.0.157')
// compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup:otto:1.3.5'
compile 'com.squareup.okhttp:okhttp:2.7.4'
compile 'com.squareup.okhttp:okhttp-ws:2.7.4'
compile 'com.parse.bolts:bolts-android:1.2.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4'
compile 'com.couchbase.lite:couchbase-lite-android:1.4.0'
compile 'com.couchbase.lite:couchbase-lite-android-forestdb:1.4.0'
compile 'com.google.android.gms:play-services-vision:10.2.1'
compile project(':mpos.android.accessories.miura-2.25.0')
compile project(':mpos.android.comlinks.tcp-2.25.0')
compile project(':mpos.android.comlinks.bluetooth-2.25.0')
compile project(':mpos.android.core-2.25.0')
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
// compile 'com.google.android.gms:play-services:11.0.4'
}
If I do not add multidex then it won't generate apk. And if I add multidex it shows error in another class, like it won't be able to import some default classes. It says class not found. And those classes I am getting from a module imported in my project. I don't get what's the issue.
Thanks in advance.
Add this line in your gradle file and then clean the project and run application
android {
...
defaultConfig {
...
multiDexEnabled true
}
}

error with firebase when i tried to build on low device version like kitkat

my app work on many devices but when i tried to build or run on low device like kitkat -- and lower it's throw this error :
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: com.google.firebase.provider.FirebaseInitProvider
and here is my gradle..
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "myapplicationId"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
}
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'
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
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 group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
//compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.3'
compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.2.3'
// compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5'
// compile 'org.apache.httpcomponents:httpcore:4.4.1'
// compile 'org.apache.httpcomponents:httpclient:4.5'
// compile 'org.apache.httpcomponents:httpmime:4.2.3'
compile files('libs/volley.jar')
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.android.support:support-annotations:25.3.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
//compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.support:palette-v7:25.3.0'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.android.support:cardview-v7:25.3.0'
compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile 'com.android.support:support-v4:25.3.0'
compile 'com.android.support:support-v13:25.3.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
testCompile 'junit:junit:4.12'
// compile 'com.android.support:multidex:1.0.1'
}
You've applied play services plugin too early, put it in the end of gradle file:
android {
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
plugin: 'com.google.gms.google-services'

Faild to resolve Repository

I have updated my app.Gradle to building tools 25.0.2 also its compiled libraries as shown
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "....."
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions { //to avoid the 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/LICENSE File1: C:\Users\dasse\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.2.2\3c8f6018eaa72d43b261181e801e6f8676c16ef6\jackson-databind-2.2.2.jar File2: C:\Users\dasse\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.2.2\d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b\jackson-core-2.2.2.jar File3: C:\Users\dasse\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.2.2\285cb9c666f0f0f3dd8a1be04e1f457eb7b15113\jackson-annotations-2.2.2.jar
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'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile('com.mikepenz:materialdrawer:5.8.1#aar') { transitive = true }
compile 'com.android.support:appcompat-v7:25.2.1'
compile 'com.android.support:design:25.2.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.mikepenz:google-material-typeface:2.2.0.1#aar'
compile 'com.mikepenz:fontawesome-typeface:4.6.0.3#aar'
compile 'com.sothree.slidinguppanel:library:3.3.1'
compile "com.android.support:support-v4:25.1.1"
compile "com.android.support:support-v13:25.1.1"
compile "com.android.support:cardview-v7:25.1.1"
compile 'com.android.support:support-v4:25.1.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.firebase:firebase-client-android:2.3.1'
compile project(path: ':silo-upstream-release')
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.github.tiagohm:CodeView:0.1.3'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
and then syncing the project gives
I have clicked install many times and restarted android studio with no effect, the installation or the download of the repos. never started
NB : I have a program trace the speen of the network and the program which use it, It says that Android-St. takes a speed for nearly 5 seconds and then do nothing and the speed reterns to zero
You are using wrong dependencies.
Check the official page.
The support libraries 25.2.1 don't exist.
Use the latest version:
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'

app:transformClassesWithJarMergingForRelease' while generating release apk

Hello I have developed one app and its completed.Now i am tryting to create release apk but i am getting following exception
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/HttpMessage.class
My app build.gradle is as follows
I am not getting why the error is occured in my app.debug app is running perfectely.I am getting error while creating release apk
apply plugin: 'com.android.application'
repositories { flatDir {
dirs 'libs' }
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
dexOptions {
javaMaxHeapSize "4g" // 2g should be also OK
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'org/apache/http/entity/mime/version.properties'
exclude 'META-INF/maven/org.apache.httpcomponents/httpmime/pom.properties'
exclude 'META-INF/maven/org.apache.httpcomponents/httpmime/pom.xml'
}
defaultConfig {
applicationId "com.XXXX.XXXX"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile(name: 'peb-lib', ext: 'aar')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.google.android.gms:play-services-safetynet:8.3.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.google.android.gms:play-services-analytics:7.3.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.daimajia.androidanimations:library:1.0.3#aar'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.github.bluejamesbond:textjustify-android:2.1.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.d-max:spots-dialog:0.4#aar'
compile 'com.vlonjatg.android:app-tour:1.0'
compile 'com.mobsandgeeks:android-saripaar:1.0.3'
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'org.jsoup:jsoup:1.8.3'
compile 'me.relex:circleindicator:1.2.1#aar'
compile 'it.sephiroth.android.library.imagezoom:imagezoom:+'
}
Please give solution because i want to publish app on playstore.Thanks in advance
You are using two distinct aar or jar dependencies which includes the apache http client. That is your problem. There are some ways to inspect the content of the jar or aar file like jadx, but since you are a beginner a trail and error way should be fine too.
So first if you don't have jar dependencies please remove this line:
compile fileTree(dir: 'libs', include: ['*.jar'])
Now exclude the apache classes from your dependencies for example:
compile 'com.squareup.retrofit:retrofit:1.9.0'
needs to be converted to:
compile('com.squareup.retrofit:retrofit:1.9.0') {
exclude module: 'httpclient'
}
If it still not compile try the next dependency and so on. That should remove the duplicate classes.
Good luck!

Categories

Resources