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

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.

Related

Trying to build on Android

I am trying to build my app but i received this error. I have rebuilt, cleaned progect and reset Android Studio. This is the screenshot of the problem:
Code error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex 'C:\Users\User-1.gradle\caches\modules-2\files-2.1\stax\stax-api\1.0.1\49c100caf72d658aca8e58bd74a4ba90fa2b0d70\stax-api-1.0.1.jar' to 'C:\Users\User-1\Documents\workspace\WebUpHosting\app\build\intermediates\transforms\dex\debug\folders\1000\10\stax-api-1.0.1_4deeb811af0ea67608aa694ead937d7c9ac36202'
The problem is when i am building, because my app compiles right. Anyone knows how i could solve that?
UPDATE:
buil.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.webuphosting.app"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dexOptions {
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled false
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 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.daimajia.easing:library:2.0#aar'
compile 'com.daimajia.androidanimations:library:2.3#aar'
compile 'com.android.support:support-v4:26.+'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'com.android.support:recyclerview-v7:26.0.+'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile "com.squareup.retrofit2:converter-simplexml:2.3.0"
testCompile 'junit:junit:4.12'
}
Hard to tell the exact problem with more code to see, but as a solution, you could just simply disable pre-dex:
boolean preDexLibraries
Whether to pre-dex libraries. This can improve incremental builds, but clean builds may be slower.
To do so, add the following block in your main module (app)'s build.gradle file, inside the android:
android {
// everything else
dexOptions {
preDexLibraries = false
}
}
By default, it is set to true, so by setting it to false, you could get around your issue, but it may not solve the root-cause.

Could not find method exclude() for arguments [{module=support-v4}]

I am trying to run my application with instant run turned off but I get this error:
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
android/support/v4/view/KeyEventCompatEclair.class
Here is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.jua.app"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile project(path: ':app_Data')
compile files('libs/android-support-v4.jar')
}
I tried the solution from this thread:
compile files('libs/android-support-v4.jar'){
exclude module: "support-v4"
}
And now I am receiving this error when I try to Sync now gradle.build:
Error:(29, 0) Could not find method exclude() for arguments
[{module=support-v4}] on file collection of type
org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection.
Open File
I am a little lost right now, If anyone has any idea how to solve this I would appreciate it.
EDIT
I removed
compile files('libs/android-support-v4.jar')
completly and I still get the first error.
This is a syntax issue. The closure in which you are calling exclude is being interpreted as an argument to the files() method, which is incorrect. Should look like this
compile (files('libs/android-support-v4.jar')){
exclude module: "support-v4"
}
For anyone having the same problem, I deleted android-support-v4.jar from folder and now it works. For some reason, if you remove it from inside the gradle.build file it continues to create problems.

Error:Execution failed for task ':app:processDebugManifest'. while adding Firebase UI dependency

I was adding Firebase UI depency but am getting a problem in syncing the project . Below is my gradle script.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "pixsor.app.huzykamz.pixoradmin"
minSdkVersion 13
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'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-crash:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.firebaseui:firebase-ui:0.4.3'
}
apply plugin: 'com.google.gms.google-services'
and below is the image of the error am getting , please help me out.
The Android system will prevent the user from installing the
application if the system's API Level is lower than the value
specified in this attribute.
Check your error log .
You should change your minSdkVersion version at first .
minSdkVersion 16 // 13 Conflict for your requirement
targetSdkVersion 23
Then Clean-Rebuild-Restart & Gradle
com.google.firebase:firebase using min level 16 .

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.

Gradle sync failing after attempting to import Parse project

I was following the Parse quickstart guide, downloaded their sample project, and opened it. There was a problem there, and now my previously working, non-Parse project is having trouble with Gradle. I'm getting the following problem every time I try to sync:
Error:(4, 0) Cannot get property 'compileSdkVersion' on extra properties extension as it does not exist
I've been researching this online, and nothing I can find can even begin to help me. Any thoughts, at least on where to start? Thanks in advance!
EDIT: By request, here's my Gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "jpb9rq.cs2110.virginia.edu.chinupdemo"
minSdkVersion 15
targetSdkVersion 21
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:21.0.3'
}

Categories

Resources