DuplicatedError while running my app in Android Studio - java

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.

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.

Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForDebug'

I must use certain librairy in my project.
When I want bebu my application I receive an indication which says to me that my code exceeds 65k method.
Thus I decided to use Proguard.
But I receive this error.
my code of buile.gradle
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "transplusafrica.delydress"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
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:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.squareup:otto:1.3.8'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.google.android.gms:play-services-maps:9.2.0'
compile 'com.google.android.gms:play-services-gcm:9.2.0'
compile 'com.google.android.gms:play-services-location:9.2.0'
}
I receive this error
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForDebug'.
java.io.IOException: proguard.ParseException: Expecting type and name instead of just '' before '(' in line 114 of file 'C:\Users\AMANI\AndroidStudioProjects\DelyDress\app\build\intermediates\proguard-rules\debug\aapt_rules.txt'
Warning:Exception while processing task java.io.IOException: proguard.ParseException: Expecting type and name instead of just '' before '(' in line 114 of file 'C:\Users\AMANI\AndroidStudioProjects\DelyDress\app\build\intermediates\proguard-rules\debug\aapt_rules.txt'
:app:transformClassesAndResourcesWithProguardForDebug FAILED
In my case it was line in aapt_rules.txt with -keepclassmembers that include my layout file. And after check this layout i'm found empty android:onClick="" param. Removing this solve my problem.

Not able to add dependecy in gradle(Android Studio)

I am trying to add this dependency https://github.com/hoang8f/android-flat-button in to my android studio project and I am getting
Error:(26, 13) Failed to resolve: info.hoang8f:fbutton:1.0.5
I am able to add google play services dependency easily without any problems.
Below is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.planner"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'info.hoang8f:fbutton:1.0.5'
}
Solutions tried:- 1.)Gradle is working in online mode not offline.
2.)Cleaned and builded/rebuilded the project.
3.) Changed to
repositories {
mavenCentral()
}
in my root gradle file
4.) Tools->android->Sync Project with gradle files
Still no luck in making it work.
P.S.:- Not that it effects the questions, I faced the same problem while trying to add parse sdk via gradle, so I added the jar file independently.
add
repositories {
mavenCentral()
}
include android tag
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.planner"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
mavenCentral()
}}
Please try this. Add fbutton-1.0.5.aar file into your lib folder.
repositories {
flatDir {
dirs 'libs'
}
}
Add aar file into dependencies.
dependencies {
compile(name:'ARFile', ext:'aar')
}
Did you noticed how looks like build.gradle of a demo project?
https://github.com/hoang8f/android-flat-button/blob/master/demo/build.gradle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 2
versionName "1.1"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
} }
dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.larswerkman:HoloColorPicker:1.4'
compile fileTree(dir: 'libs', include: ['*.jar']) // compile project(':library')
compile 'info.hoang8f:fbutton:1.0.5'
}
Check if you're not missing something in your Gradle file or you put something wrong
EDIT: I've put whole your build.gradle file into my new project and it's work fine.
If rebuilding not help, create a new clean project and put this build.gradle. Tell me is it works with new project.
EDIT2:
In your project you have two build.gradle change the second one to
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
}
allprojects {
repositories {
jcenter()
}
}
I had the same problem.
Invalidate cache and restart your android studio. Then sync gradle.
I cloned the project and used "demo" module to test the lib. The lib that you needed was downloaded successfully and this is expected, because it exists in the maven repo
The only point I noticed - probably you may have problems with gradle, because there's runProguard command, that is not used in gradle no more.
So you may just delete it or change to minifyEnabled false.
After doing this, demo project assembles successfully

Error:Execution failed for task ':app:dexDebug'. Process 'command java.exe finished with non-zero exit value 2

I know this question has been asked many times but i am still not able to find the solution. I check for each and every possible duplication library but didn't find it. Here is my Manifest
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dp.myquest"
minSdkVersion 16
targetSdkVersion 16
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/abs.jar')
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/android-async-http-1.4.4.jar')
compile files('libs/android-query-full.0.26.7.jar')
compile files('libs/App42_ANDROID_SDK_3.0.1.jar')
compile files('libs/commons-collections4-4.0.jar')
compile files('libs/commons-net-3.3.jar')
compile files('libs/mail.jar')
compile files('libs/picasso-2.5.0.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.facebook.android:facebook-android-sdk:3.19.0'
}
It has nothing to do with duplicate, the problem is android has a limit of 64k method for an dex file in app.
You need to enable multidex.
This is how you can do it
http://developer.android.com/tools/building/multidex.html

Duplicate entry for class in gradle

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.

Categories

Resources