Error:Execution failed for task ':packageAllReleaseClassesForMultiDex' - android

Help! Its my .gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "test.app.android.player"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
}
dependencies {
compile files('libs/android-support-v4-22.2.1.jar')
compile files('libs/android-support-v7-recyclerview-22.2.1.jar')
compile files('libs/applovin-6.1.5.jar')
compile files('libs/appodeal-1.14.6.jar')
compile files('libs/chartboost-6.2.0.jar')
compile files('libs/flurry-analytics-6.2.0.jar')
compile files('libs/inmobi-5.2.0.jar')
compile files('libs/my-target-4.2.0.jar')
compile files('libs/unity-ads-1.4.7.jar')
compile files('libs/yandex-metrica-2.30.jar')
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.android.support:multidex:1.0.0'
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
And i got this error in logcat see this: Error:Execution failed for task ':packageAllReleaseClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: android/support/v4/view/PagerAdapter.class
I dont find duplicate

You have to remove
compile files('libs/android-support-v4-22.2.1.jar')
The 'com.google.android.gms:play-services-ads:8.4.0' has a dependency with com.android.support:support-v4:23.0.0. In this way you adding twice the same class with different version.

Related

transformClassesWithJarMergingForDebug,com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:

I am getting this error when trying to run application on device.However gradle sync is always successful.
Error:Execution failed for task
':EmployeeManager:transformClassesWithJarMergingForDebug'. >
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
javax/jmdns/impl/constants/DNSConstants.class
See the Grdale file below.
apply plugin: 'com.android.application'
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile(name:'jmdns-3.4.1', ext:'jar')
compile(name:'mlite', ext:'jar')
compile project(':EmpManager')
compile project(':CustomerManager')
compile project(':NGPS_COMMON_LIBS')
}
android {
compileSdkVersion 19
buildToolsVersion '23.0.2'
packagingOptions{
exclude("META.INF/LICENSE.txt")
exclude("META.INF/README.txt")
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
defaultConfig {
multiDexEnabled true
}
}
I just removed packagingOptions from gradle and the issue has been resolved.

Error:Execution failed for task ':dexRelease'

This is my .gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "net.test.android.sk"
minSdkVersion 15
targetSdkVersion 23
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
}
dependencies {
compile 'com.google.android.gms:play-services:8.4.0'
compile files('libs/android-support-v4-22.2.1.jar')
compile files('libs/android-support-v7-recyclerview-22.2.1.jar')
compile files('libs/applovin-6.1.5.jar')
compile files('libs/appodeal-1.14.6.jar')
compile files('libs/chartboost-6.2.0.jar')
compile files('libs/flurry-analytics-6.2.0.jar')
compile files('libs/unity-ads-1.4.7.jar')
compile files('libs/inmobi-5.2.0.jar')
compile files('libs/my-target-4.2.0.jar')
compile files('libs/yandex-metrica-2.30.jar')
}
When I build my Android app, I get the next error:
Error:Execution failed for task ':dexRelease'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2
Install multidex but new error: Error:Execution failed for task ':packageAllReleaseClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry: android/support/v4/view/PagerAdapter.class

After add Fabric for crash report I can't add new libs in gradle

I'm just installed the library Fabric for Crash monitoring, but now, I'm trying to add a library to rate your app (compile 'com.androidsx:rate-me:4.0.0') but now gradle stops showing that it failed to resolve the library.
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'io.fabric'
repositories {
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.3.2#aar') {
transitive = true;
}
compile 'com.android.support:support-v4:22.1.1'
compile files('libs/library-1.0.6.jar')
compile files('libs/gcm.jar')
compile files('libs/acra-4.6.1.jar')
compile files('libs/acra-4.6.1-sources.jar')
compile files('libs/acra-4.6.1-javadoc.jar')
compile files('libs/TestFlightLib.jar')
compile files('libs/crouton-1.8.4.jar')
compile project(':LVL')
compile files('libs/bugsense-3.5.jar')
compile 'com.androidsx:rate-me:4.0.0'
}
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
The output:
What is the problem?
Solved:
jcenter() was missing inside repositories section.
Thanks.

aapt finished with non-zero exit value 1

Recently I'm trying to use LeakCanary to fix OOM(out of memory) issues for my Android app. And I added
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
to my build.gradle, following the instructions on LeakCanary website. After gradle build, I got
"/android-sdk/android-sdk_r22.6.2-linux/build-tools/21.1.1/aapt'' finished with non-zero exit value 1
This is part of my build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
}
}
apply plugin: 'android'
apply plugin: 'maven'
android {
compileSdkVersion 19
buildToolsVersion '22.0.1'
defaultConfig {
multiDexEnabled true
}
lintOptions {
abortOnError false
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
res.srcDirs = ['res']
}
instrumentTest.setRoot('tests')
}
dexOptions {
jumboMode = true
preDexLibraries = false
javaMaxHeapSize = '2g'
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
repositories {
flatDir {
dirs 'libs'
}
maven {
url "http://XXXXX/nexus/content/repositories/releases"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile(name: 'ShortcutBadger-1.0.1', ext: 'aar')
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
}
When I updated the CompileSDKVersion to 22 and buildToolsVersion to 22.0.1, it worked.
Hope this can help anyone having this problem.
I changed
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
to
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
As well as the CompileSDKVersion to 22 and buildToolsVersion to 22.0.1 as suggested by CherryWang https://stackoverflow.com/a/30496364/1247248
I got this from a comment in Gradle finished with non-zero exit value 1 (ic_launcher.png: error: Duplicate file)

Android error on imported module build,gradle - Could not find method instrumentTestCompile()

On import ListViewAnimation library, I get rebuild error
Error:(7) A problem occurred evaluating project ':library'.
Could not find method instrumentTestCompile() for arguments [org.mockito:mockito-core:1.9.5, build_n73cqp2judtlhpna5h10rio8c$_run_closure1_closure3#20e75be5] on project ':library'.
This is the imported module build.gradle:
apply plugin: 'android-library'
dependencies {
compile 'com.nineoldandroids:library:2.4.0'
instrumentTestCompile ('org.mockito:mockito-core:1.9.5') { exclude group: 'org.hamcrest' }
instrumentTestCompile ('com.google.dexmaker:dexmaker-mockito:1.0') { exclude group: 'org.hamcrest' }
instrumentTestCompile ('junit:junit:4.11') { exclude group: 'org.hamcrest' }
instrumentTestCompile 'org.hamcrest:hamcrest-all:1.3'
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
instrumentTest {
java.srcDirs = ['tests/java']
}
}
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionName project.VERSION_NAME
versionCode Integer.parseInt(new Date().format('yyyyMMddHH'))
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
apply from: '../maven_push.gradle'
What is the problem ?
instrumentTest has been renamed in androidTest in recent android-gradle-plugin
You have to rename in the build.gradle :
instrumentTestCompile --> androidTestCompile
instrumentTest --> androidTest

Categories

Resources