Can't add xstream 1.4.8 dependency to Android using gradle - android

I'm having difficulties with including xstream library to my Android gradle-based app. From what I've read in xstream documentation, it should work "out of the box". However, when I add dependency:
compile 'com.thoughtworks.xstream:xstream:1.4.8'
I get following exception during build process:
* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/xmlpull/v1/XmlPullParser.class
Ok, so maybe I should exclude xmlpull? I tried changing this dependency to:
compile ('com.thoughtworks.xstream:xstream:1.4.8') {
exclude group: 'xmlpull', module: 'xmlpull'
}
And, as a result, after some time:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Exception parsing classes
at com.android.dx.command.dexer.Main.processClass(Main.java:752)
// ...
Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
// ...
1 error; aborting
I've also checked project dependencies using gradle dependencies, but found nothing xml-related there.
My whole build.gradle file:
group 'myGroup'
version '1.0'
apply plugin: 'com.android.application'
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "edu.foo.app"
minSdkVersion 19
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/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
repositories {
mavenCentral();
maven {
url 'https://repository-achartengine.forge.cloudbees.com/snapshot/'
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile project(':Commons')
compile 'commons-io:commons-io:2.4'
compile 'commons-codec:commons-codec:1.10'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'org.achartengine:achartengine:1.2.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.thoughtworks.xstream:xstream:1.4.8'
// compile ('com.thoughtworks.xstream:xstream:1.4.8') {
// exclude group: 'xmlpull', module: 'xmlpull'
// }
}
What should I do to include xstream library to my project?

Solution was to downgrade xstream to v1.4.7 and exclude xmlpull.
compile ('com.thoughtworks.xstream:xstream:1.4.7') {
exclude group: 'xmlpull', module: 'xmlpull'
}
I don't know exactly why, but I'd guess that it must be java8-related.

I was getting the same Error.What i did, i just Disable the "Enable all the test artifacts" from my default preferences.
and Open build variants select unit tests..
Hope above Ans may helps any one.

Related

How to import org.springframework.data into Android Studio using Gradle

I need the org.springframework.data.geo.Point class in my Spring Android app. I have the spring-android dependency already downloaded here. This does not have the .data section. When I try to use Gradle to import a different library I get duplication file errors. After consulting this link I get errors involving Dex cannot parse version 52 byte code. While reviewing this previous post I read that this wasn't the recommend way of getting rid of these errors.
Is there a spring library that I can import that has the org.springframework.data as well as everything given in the org.springframework.android:spring-android-rest-template:2.0.0.M3 library.
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.avi.myapplication"
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 {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/notice.txt'
//pickFirst 'META-INF/spring.schemas'
//pickFirst 'META-INF/spring.tooling'
//pickFirst 'META-INF/spring.handlers'
//pickFirst 'META-INF/spring.factories'
}
}
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'
testCompile 'junit:junit:4.12'
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
}
repositories {
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
Error Message after following this:
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/spring.schemas
File1: C:\Users\Avi.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.0.2.RELEASE\1befa3239976b856202b1735531910a0c2f4e17f\spring-data-commons-2.0.2.RELEASE.jar
File2: C:\Users\Avi.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.0.2.RELEASE\301ee07b390bc8b5691f4206411b49beb06f7ff2\spring-beans-5.0.2.RELEASE.jar
Error Message after following this:
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/zzc.class

My app is running on an android device . It is showing no error while building the app .However , it gives an exception when i am trying to build an APK for the app .
This is my app.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.delluser.oshoguide"
minSdkVersion 17
targetSdkVersion 25
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/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
}
}
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.google.firebase:firebase-crash:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.google.firebase:firebase-storage:10.2.1'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.firebaseui:firebase-ui:0.6.2'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
And this is my build.gradle file:
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
}
I have already tried changing the version of firebase libraries from 11.0.1 to 10.2.1 , but it did not work. I have done Clean and Rebuild . However , i am getting the same error.
My Error is:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/internal/zzf.class
did u try to refresh your project?(in android studio) if not check right hand side there is gradle option open it and select the first option(refresh all projects).

Error during Building an APK file in Android Studio 2.1.1

Couple of days ago, I upgraded my Android Studio, and now I am facing a problem.
Actually I am trying to build an APK file from my project to test my app on a real device and when I click at Build--> Build Apk then I receive couple of errors in Message Gradle Build. I don't know why these errors are coming please elaborate on the reason as well.
Errors
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/android/volley/VolleyError;
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.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value 2
build.gradle file
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dovezeal.gapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
//compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.1.1'
// Volley
compile 'com.android.volley:volley:1.0.0'
//compile 'com.mcxiaoke.volley:library:1.0.+'
/* compile files('libs/com.mcxiaoke.volley library-1.0.0.jar')*/
// RecyclerView
compile 'com.android.support:recyclerview-v7:23.0.+'
// A simple way to define and render UI specs on top of your Android UI.
compile 'org.lucasr.dspec:dspec:0.1.1'
compile files('libs/library-1.0.0.jar')
// YouTube Player
compile files('libs/YouTubeAndroidPlayerApi.jar')
// GOSN
/* compile files('libs/gson-2.2.3.jar')*/
}
Edit - 1
As janki gadhiya said in her comment below, to change minifyEnabled true and try adding multiDexEnabled true under defaultConfig
with these changes both errors above are gone, but now this following error is coming up.
Error:Execution failed for task:app:transformClassesWithJarMergingForDebug'
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/android/volley/Request$Priority.class
build.gradle file
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dovezeal.gapp"
minSdkVersion 19
targetSdkVersion 23
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
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
//compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.1.1'
// as you already compiled gradle for volley here
compile 'com.android.volley:volley:1.0.0'
// RecyclerView
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'org.lucasr.dspec:dspec:0.1.1'
// you don't need this so comment the below line.
//compile files('libs/library-1.0.0.jar')
// YouTube Player
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
Edit : Explanations
Your errors 1 - 2 : mean you are having more than 65,000 methods in your project, so I told you to set multiDexEnable true.
Your error 3 : means you're having more than one library having the implementation for the class Request$Priority.class, so the compiler is confused which to choose. So it is showing the error Duplicate entry. This will be solved by packaging options, this will let you use duplicate files.
Add this in your build gradle
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
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'
}
I am also getting the same error. When adding the
compile 'com.google.firebase:firebase-ads:10.2.0'
but it is removed when i do as follow:
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.google.firebase:firebase-ads:10.2.0'
}
apply plugin: 'com.google.gms.google-services'**
and in BuildVarient use debugging mode.
I think it will help you.
while updating firebase any google play services then try to update all the libraries. this worked for me. hope it works in some cases.
Bit late to answer but I faced the same issue.
I was able to rectify it using multiDexEnabled -> true
and used packaging options in build.gradle, post the changes .apk got installed successfully.
Syntax:
defaultConfig {
....
....
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 {
...
...
}
Hope it helps.

Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease' : java.io.IOException - Proguard Issue

Been struggling to figure the reason behind the issue (see stacktrace below) while trying to use proguard.
Apart from the libraries mentioned in gradle file, the app deals with opening sockets, serializing/deserializing data, ciphers and jwt tokens, dealing with WifiManager & WifiP2pManager.
It would be great if anyone could help point out the issue, or at least help me dig into the issue better. I have tried adding all the possible proguard rules for the different libraries and to not minify our own parent package as well.
My gradle file
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'
apply plugin: 'com.google.gms.google-services'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile project(':android')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.google.code.gson:gson:2.4'
compile 'commons-codec:commons-codec:1.9'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'com.android.support:support-v4:23.1.1'
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.some.org.package"
minSdkVersion 18
targetSdkVersion 23
versionCode 5
versionName "0.9.0"
}
buildTypes {
release {
minifyEnabled true
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/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'
}
}
Proguard-rules.pro
Proguard file link
./gradlew clean assembleRelease -d --stacktrace
https://jsfiddle.net/w7htgrxd/3
The build log explicitly mentions the reasons why the build is failing. There are various references to missing classes, wrong configurations, attributes that are not kept although being used, ....
I suggest that you look at the referenced manual pages and apply the suggested changes, most of them being -keepattributes ...., -dontwarn ....
If you do not manage to resolve all warnings, you can finally add also -ignorewarnings to ignore the remaining ones and let ProGuard continue processing your application.

duplicate entry AbsHListView in my Android Project

I am working on one android application, where i am using two libraries ( Aviary android sdk and PrintIO sdk)
Getting conflict in libraries and getting this error each time when compiling project :
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: it/sephiroth/android/library/widget/AbsHListView$1.class
I have not used such library anywhere in my project as well as i also checked in both libraries, but not found anything.
Please anyone suggest me anything why i am getting this conflict in my project?
EDIT :
Here is my build.gradle file :
apply plugin: 'com.android.application'
repositories {
mavenCentral()
jcenter()
mavenLocal()
maven {
name 'maven.aviary.com'
url uri("http://maven.aviary.com/repo/release")
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
lintOptions {
disable 'MissingTranslation'
}
defaultConfig {
applicationId "XXXXX.XXXXX"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
multiDexEnabled true
}
packagingOptions {
exclude 'lib/armeabi-v7a/librsjni.so'
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'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/httpclient-4.0.1.jar')
compile files('libs/httpcore-4.0.1.jar')
compile project(':MaterialDialog')
compile files('libs/universal-image-loader-1.9.1.jar')
compile project(':StaggeredGrid')
compile project(':CustomFloatingButtonLibrary')
compile files('libs/dropbox-android-sdk.jar')
compile files('libs/gcm.jar')
compile project(':image_select_lib')
compile files('libs/json-simple-1.1.1.jar')
compile project(':chipsLib')
compile files('libs/aws-android-sdk-1.4.3-s3.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.instabug.library:instabugsupport:1.+'
// compile 'com.aviary.android.feather.sdk:aviary-sdk:3.6.3'
compile 'com.yalantis:phoenix:1.2.3'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.google.android.gms:play-services-location:7.5.0'
compile project(':Aviary-SDK')
compile project(':SwipyLib')
compile project(':printio')
}
EDIT 2 :
I searched for library (AbsHListView) using CTRL + N and it result in following :
I did a google search for the class it/sephiroth/android/library/widget/AbsHListView$1.class and found out it is used by the library here.
Looks like one of your dependencies is using this library. If you are on Windows press CTRL + N and enter this AbsHListView and search. You will find the conflicting class.
EDIT:
Change your dependency like this:
compile project(':printio') {
exclude group: 'it.sephiroth.android.library.widget'
}

Categories

Resources