Duplicate entry for class in gradle - java

I am trying to implement ken burns view in android studio in my app, i have importted the folder which contains its classes, but gradle gives me this error Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry: com/flaviofaria/kenburnsview/MathUtils.class
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "revamp.revamp2015app"
minSdkVersion 9
targetSdkVersion 21
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/Parse-1.5.0.jar')
compile 'com.flaviofaria:kenburnsview:1.0.6'
}
What should i do to make it run ?

The above library is already on maven.
Just remove the imported folder and add the code below to your dependencies:
compile 'com.flaviofaria:kenburnsview:1.0.6'
Sometimes due to downloading issues; the library fails to download. In that case ; just find your .gradle folder and clear cache inside it. Recompile and you are done

Replace this line:
compile 'com.flaviofaria:kenburnsview:1.0.6'
with this one:
compile project(':FOLDER_NAME')
Where FOLDER_NAME is the name of the folder you imported to your project, after that sync your gradle.

Related

Error:Execution failed for task ':app:compileDebugJavaWithJavac

I'm facing this problem when I try to run my app
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
java.io.FileNotFoundException: C:\Users\ggg\Desktop\android\app\libs\support-v4-25.1.0.jar (The
system cannot find the file specified)
this is my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.gumball.at.adventure"
minSdkVersion 14
targetSdkVersion 23
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-25.1.0.jar')
}
any help please
Change your targetSdkVersion to 25
and add this line
multiDexEnabled true
You can add dependencies from here
Try to replace
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/support-v4-25.1.0.jar')
to
compile fileTree(dir: 'libs', include: ['*.jar'])
for including jar library files in your project.
Best you can use gradle dependencies functionalities to add library in your project. Example
compile 'com.android.support:support-v4:25.1.0'
It will automatically download the required library to the project. You don't need to download manually jar files and add to the project.

DuplicatedError while running my app in Android Studio

I know there are lots of answers for my questions but none of them worked for me. Does someone know why this is hapening even if I exclude the two files in gradle.build.
Error:Execution failed for task ':projectPacatioClient:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK org/joda/time/tz/data/America/Argentina/Tucuman
File1: /Users/as/StudioProjects/Project Pacatio Client2/projectPacatioClient/libs/aws-android-sdk-2.0.4-core.jar
File2: /Users/as/.gradle/caches/modules-2/files-2.1/joda-time/joda-time/2.4/89e9725439adffbbd41c5f5c215c136082b34a7f/joda-time-2.4.jar
Here is my Gradle.build file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.0.0'
defaultConfig {
applicationId "io.kit.pc"
minSdkVersion 11
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
apply plugin: 'eclipse'
defaultConfig {
multiDexEnabled true
}
}
dependencies {
compile project(':libraryCropper')
compile files('libs/gcm.jar')
//compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.google.android.gms:play-services:4.4.52'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.google.maps:google-maps-services:0.1.3'
//compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile files('libs/aws-android-sdk-2.0.4-core.jar')
compile files('libs/aws-android-sdk-2.0.4-s3.jar')
compile files('libs/braintree-api-1.3.0-full.jar')
androidTestCompile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
}
I have faced the same issue.
Just remove your duplicate library from build.gradle file. Cross check with app->libs if already exists there.

Run modules independently with source dependencies in Android Studio (Intellij?)

I am using Android studio but this may be a general Intellij question (I'm used to eclipse). This seems like it should be super simple, but I can't figure it out.
I want to be able to run either module in my project independently, which is from what I understand the purpose of a module. This has worked fine until now when I want to call code from my "app" module in my "testmodule" module. Android Studio lets me import the code I need with no problems until I try to build the module. Then I get the expected "package not found" error. So then I try adding this in my "testmodule" build.gradle:
main.java.srcDirs '../app/src/main/java'
This causes two package import statements in my "app" module to fail. One of the failing packages is the package defined in my "app" manifest and the other is specified in my "app" build.gradle
sourceSets {
main.java.srcDirs += '../../connectorAPI/trunk/src'
}
I also tried to make one module depend on another but from what I've read in stack overflow (and the vague Android Studio error) one module must be a library file. This obviously doesn't work since I want to be able to run either. I would love to just copy the code I need but then I'd need to change both every time in version control, which is a nightmare.
In eclipse all you have to do is right click and link source. I can't imagine this is impossible or even out of the ordinary, so I must be missing something simple... can someone please help me out?
build.gradle testmodule
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.XXXXX.testmodule"
minSdkVersion 15
targetSdkVersion 21
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:21.0.3'
compile 'com.google.android.gms:play-services:+'
}
build.gradle app
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.XX.XXX.XXX.XXX"
minSdkVersion 15
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
sourceSets {
main.java.srcDirs += '../../connectorAPI/trunk/src'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.google.android.gms:play-services:+'
// Add the ArcGIS Android 10.2.5 API
compile 'com.esri.arcgis.android:arcgis-android:10.2.5'
compile 'com.googlecode.json-simple:json-simple:1.1'
}
I might be late by a few years but here is what I would do : Declare both modules as library, and create another two as application. Then you can easily import the two libriaries while still having two applications, if that is what you want.
As for the duplicate dependency issue that will arise, you can just add an exclude statement in the build.gradle respectively.

Package does not exist when using separate App as a dependency

I'm trying to compile an App utilising a separate App as a dependency but when I compile referencing modules from this library I see several "error:package does not exist" and "error:cannot find symbol class" messages from graddle. The following are my two build files.
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'AndroidManifest.xml'
exclude 'resources.arsc'
exclude 'classes.dex'
}
}
dependencies {
repositories {
mavenCentral()
}
compile 'com.android.support:support-v4:+'
compile 'com.google.code.gson:gson:2.2.2'
compile 'com.google.android.gms:play-services:+'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile 'com.android.support:support-v4:+'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'se.emilsjolander:stickylistheaders:2.+'
compile 'com.googlecode.libphonenumber:libphonenumber:+'
compile files('libs/crashlytics.jar')
compile files('libs/httpclient-4.2.3.jar')
compile files('libs/libphonenumber-5.9.jar')
compile files('libs/mobileservices-0.2.0-javadoc.jar')
compile files('libs/mobileservices-0.2.0.jar')
compile files('libs/stringtotime-1.0.4.jar')
compile files('libs/urbanairship-lib-2.0.2.jar')
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+'
compile files('libs/FlurryAnalytics-4.0.0.jar')
compile 'com.squareup.picasso:picasso:2.3.3'
compile project(':wheel')
}
Dependency gradle:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "kankan.wheel"
minSdkVersion 5
targetSdkVersion 7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
Can anyone help/experienced this before? Android Studio does not highlight any issues in the class and I can ctrl+click through to the packages referenced which seems to mean it is set up correctly...
Thanks!
The buildTypes section should not be in library build.gradle file.
You cannot have two gradle scripts using the com.android.application plugin at the same time. Change the dependency project to apply the 'library' plugin.
If that doesn't do it, change the targetSdkVersion of your dependency to that of your core project.
If you are using a Android library module as a dependency (i.e. mylib), then make sure in your app.iml file that you see the following line toward the end of the file:
<orderEntry type="module" module-name="mylib" exported="" />
Try changing min and target sdk to 11 and 19 according in dependency gradle-default config.
I had a similar issue posted here
But I got it resolved using #Doge's suggestion,
I converted the dependency android project to library project.
Thanks.

Android studio clean error: uses-sdk:minSdkVersion 1 cannot be smaller than version 4

So I'm using Android studio for my android app and after adding a .jar file to my project I now get this error:
Execution failed for task ':androidrss:processDebugTestManifest'.
java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 4 declared in library com.android.support:support-v4:20.0.0
Thing is that I can build and run my app but i cannot do a clean of my project (Build->Clean Project). So i tried removing the .jar file and then do a clean still gets the same error. Also did a File->Invalidate Caches/Restart, this didn't work either.
I tired searching my project for minSdkVersion 1 and minSdkVersion "1" without any hits.
This is my Manifest.XML part with SDK version:
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="17" />
This is my Grandle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.golfboxdk"
minSdkVersion 15
targetSdkVersion 17
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile project(':library')
compile project(':androidrss')
compile files('libs/achartengine-1.2.0.jar')
compile files('libs/android-query-full.0.25.5-beta.jar')
compile files('libs/axis-1.2.1.jar')
compile files('libs/bugsense3.1.jar')
compile files('libs/diting-1.0.jar')
compile files('libs/jsoup-1.7.2.jar')
compile files('libs/ksoap2-android-assembly-2.5.7-jar-with-dependencies.jar')
compile files('libs/pojoxml-1.0.jar')
compile files('libs/simple-xml-2.7.jar')
compile 'com.android.support:support-v4:20.+'
compile 'com.google.code.gson:gson:2.2.2'
compile 'com.android.support:appcompat-v7:20.+'
}
So anyone able to help me out with this clean error?
EDIT 1: I took a look at the manifestMerge file thats generated when the error occurs and is has minSdkVersion="1", But why is this? Been struggling with this for 3 hours now, would really appreciate some help.
EDIT 2: It seems like setting the min/max SDK for ALL of my modules did the trick.

Categories

Resources