I am using external third party libraries in my project, but the problem I am facing is, two different jar files contains a class with the same name.
Following are the libs I am using
jaxen-1.1-beta-2.jar
jaxen-core.jar
The above given jar files share a class with the same name called "DefaultNavigator.class" so because of this i am getting the following duplicate class error.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/jaxen/DefaultNavigator.class
I need to know whether i can edit/delete unused classes or repeated classes given in the external third party jar files or please guide me whether i can copy only the classes that i required from all the jars and put them up in a single jar file and use. if this is possible please tell me how to do this. I am a beginner to android. Below I am attaching my build.gradle file.
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.xxx.xxx.yyy"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:multidex:1.0.1'
compile files('libs/xsdlib-1.5.jar')
compile files('libs/relaxngDatatype-2.2.jar')
compile files('libs/javax.xml.stream.jar')
compile files('libs/pull-parser-2.jar')
compile files('libs/javax.xml.bind.jar')
compile files('libs/java-rt-jar-stubs-1.5.0.jar')
compile files('libs/jaxen-core.jar')
compile files('libs/jaxen-dom4j.jar')
compile files('libs/jaxen-1.1-beta-2.jar')
}
Related
After upgrading to AS 3.2.1, I get this gradle sync error:
Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve project :androidlib_abc.
my app gradle.build:
apply plugin: 'com.android.application'
allprojects {
repositories {
// The order in which you list these repositories matter.
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "de.gpx.android.rtk"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile project(path: ':androidlib_abc')
}
my androidlib_abc gradle.build file:
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
minSdkVersion 24
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
The "Open File" link in the error message points to the app gradle.build file. When I remove the line
compile project(path: ':androidlib_abc')
Then I can sync the grade project, but I cannot compile and use any package from that library (cannot resolve classes etc.)
I wish I didn't do the update... ("Never change a running system" -_-)
Any ideas how to fix?
UPDATE:
I removed the module from the project and then reimported it. Then everything worked fine! BUT: The module directory is copied into my project directory (usual behaviour). However, I need the module directory to be one level higher, in the same directory as the project directory is. This way, I could share the module with different projects without having duplicates and synchronizing work which saves me a lot of time (in fact I cannot work with multiple projects otherwise).
I used to use this settings.gradle file:
include ':app', ':androidlib_abc'
project(':androidlib_abc').projectDir = new File(rootProject.projectDir, '../androidlib_abc ')
which worked perfectly before AS 3.2.1
Now, after I successfully imported the module again and moved the module directory one level up and changed the settings.gradle file to this again, I get the unable-to-resolve-dependency error again :'-(
UPDATE2:
Using another constructor without the argument rootProject.projectDir allowed me to do the gradle sync.
include ':app', ':androidlib_abc'
project(':androidlib_abc').projectDir = new File('../androidlib_abc')
The library is finally listed on the left side!
However, a new issue came up. No classes/methods/fields etc. defined in the modul can be resolved. Not even in classes within the module itself although they are even in the same directory (package)... Cleaning and Rebuilding didn't help. Strange thing is, that building succeeds and I can apparently even install the app on my device and have it run without any exceptions...!? So is this just an IDE bug maybe?
UPDATE3
I deleted the .gradle and .idea directory and restarted AS. Everything's fine now B-)
try building androidlib_abc once .are you able to see this library in the side menu ?.
It could be that this particular library is not imported properly
I tried to use Google Map Service by using com.google.maps:google-maps-services:0.1.7 version.
After adding complie 'com.google.maps:google-maps-services:0.1.7'to build.gradle(Module: app), I tried to sync the project.
Then I got following errors in Messages Gradle Sync,
D:\Solutions\Security\app\build.gradle
Error:(26, 0) Gradle DSL method not found: 'complie()'
Possible causes:The project 'AIGSecurity' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 2.3.2 and sync project
The project 'Security' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin.
Apply Gradle plugin
And This is my build.gradle(Module: app) file,
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "solutions.com.security"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
complie 'com.google.maps:google-maps-services:0.1.7'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'joda-time:joda-time:2.9.4'
compile 'com.auth0.android:jwtdecode:1.1.0'
compile 'com.android.support.constraint:constraint-layout:+'
androidTestCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.android.support:support-annotations:24.2.0'
compile 'com.google.firebase:firebase-messaging:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
Is there any way to fix this issue ?
you misspelled compile
complie 'com.google.maps:google-maps-services:0.1.7'
to
compile 'com.google.maps:google-maps-services:0.1.20'
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 !
I am trying to use opencsv library jar file but while importing i am getting the error message saying "Fail to load plugin descriptor from file *.jar".
I checked for META-INF/plugin.xml file inside the jar, but there is none.
So, i am now importing the source code of opencsv. I am getting error with java 7 api used within the library source code. All the usages of 'java.bean.*' package is giving 'cannot find symbol' error.
Following is the build.gradle file content:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.amadeus.jbisht.mytestproject"
minSdkVersion 23
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'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.+'
testCompile 'junit:junit:4.12'
}
Please let me know what am I missing here. I can see it listed under 'External Libraries' but android studio isnt picking it up.
Gradle dependencies are the way to go:
compile group: 'com.opencsv', name: 'opencsv', version: '3.8+'
E.g.,
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile group: 'com.opencsv', name: 'opencsv', version: '3.8+'
}
Gradle will automatically import the required files and integrate the library.
opencsv need some java.bean libraries, but they are not included in the Android SDK.
To resolve this :
download sources of opencsv
download openbean
include both in your Android Studio project
replace java.bean.* dependancies by localpath.bean.* in opencsv sources
my Gradle suddenly decided not to build my project anymore, and I have no idea. I suspect its because its on dropbox, but it hasnt been a problem for the month Ive worked on it. I have not edited anything in my build files. I updated java JDK to newest, and made sure the project is pointed to it. The gradle look like this;
// 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'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 22
}
dependencies {
}
and
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.nan.spymap"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories { mavenCentral() }
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: 'ParseFacebookUtilsV4-*.jar', dir: 'libs')
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.android.support:design:22.2.0'
}
build.gradle file of project (top-level) must not contain android root tag. Try to remove it.