Android - Duplicate entry: android/support/v4/database/DatabaseUtilsCompat.class? - android

My Gradle is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "jim.mp.offline"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
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:multidex:1.0.1'
compile 'com.android.support:support-v4:25.0.0'
compile('com.android.support:appcompat-v7:25.0.0') {
exclude module: 'support-v4'
}
compile files('libs/commons-io-2.4.jar')
compile files('libs/osmdroid-android-4.1.jar')
compile files('libs/slf4j-android-1.5.8.jar')
}
But when I run the project say me :
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/database/DatabaseUtilsCompat.class

My problem was solved :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
repositories {
mavenCentral()
}
defaultConfig {
applicationId "jim.mp.offline"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
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:multidex:1.0.1'){
exclude module: 'support-v4'
}
compile 'com.android.support:support-v4:25.0.0'
compile('com.android.support:appcompat-v7:25.0.0') {
exclude module: 'support-v4'
}
compile('commons-io:commons-io:2.4') {
exclude module: 'support-v4'
}
compile('org.slf4j:slf4j-android:1.7.10') {
exclude module: 'support-v4'
}
compile('org.slf4j:slf4j-api:1.7.10') {
exclude module: 'support-v4'
}
compile files('libs/osmdroid-android-4.1.jar')
}

Related

Duplicate entry: com/google/android/gms/iid/zzc.class

While Trying to implement Admobs in project I m facing the below issue during build apk process.
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/iid/zzc.class
build.gradle
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
defaultConfig {
// ...
multiDexEnabled true
}
dexOptions {
jumboMode true
}
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "eazy.picsart"
minSdkVersion 16
targetSdkVersion 23
versionCode 2
versionName "2.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [appPackageName: "${applicationId}"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
/* compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}*/
/* 3) Exclude duplicate licenses */
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
pickFirst 'AndroidManifest.xml'
exclude 'com/google/android/gms/ads/AdActivity.class'
}
aaptOptions{
cruncherEnabled = false
}
}
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'
})
testCompile 'junit:junit:4.12'
compile 'com.adobe.creativesdk.foundation:auth:0.9.1251'
compile 'com.adobe.creativesdk:image:4.8.4'
compile 'com.localytics.android:library:3.8.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services-ads:11.0.1'
}

Error: more than one library with package name 'com.facebook.react'

I have a react native project that was auto-generated by https://getexponent.com/ when I detached the project. Now I'm getting these build errors after I added react-native-lock with react native link. It works fine as an iOS project with xcode, but android studio is giving me this error:
Error:Execution failed for task ':app:processDebugResources'.
> Error: more than one library with package name 'com.facebook.react'
And the build.grade files
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24.0.3'
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
defaultConfig {
applicationId "com.foo.app"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
manifestPlaceholders = [
'appAuthRedirectScheme': 'com.foo.app'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "8g"
}
}
task exponentPrebuildStep(type: Exec) {
workingDir '../../'
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine 'cmd', '/c', '.\\.exponent-source\\android\\detach-scripts\\prepare-detached-build.bat'
} else {
commandLine './.exponent-source/android/detach-scripts/prepare-detached-build.sh'
}
}
preBuild.dependsOn exponentPrebuildStep
repositories{
flatDir{
dirs 'libs'
}
mavenLocal()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile project(':react-native-lock')
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:multidex:1.0.0'
compile('host.exp.exponent:exponentview:13.0.0#aar') {
exclude module: 'bolts-android'
transitive = true;
}
}
and for react-native-lock
repositories {
jcenter()
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '24.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "0.4.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
ext.libraries = [
testing: [
dependencies.create('junit:junit:4.11') {
exclude module: 'hamcrest-core'
},
'org.robolectric:robolectric:3.0-rc3',
'com.google.guava:guava:18.0',
'org.hamcrest:hamcrest-integration:1.3',
'org.hamcrest:hamcrest-core:1.3',
'org.hamcrest:hamcrest-library:1.3',
'org.mockito:mockito-core:1.10.19',
dependencies.create('com.squareup:fest-android:1.0.+') {
exclude group: 'com.android.support', module: 'support-v4'
},
'org.powermock:powermock-api-mockito:1.6.3',
'org.powermock:powermock-module-junit4-rule:1.6.3',
'org.powermock:powermock-classloading-xstream:1.6.3'
]
]
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:support-v4:23.+'
compile 'com.facebook.react:react-native:+'
compile 'com.auth0.android:lock:1.17.+'
compile 'com.auth0.android:lock-passwordless:1.17.+'
testCompile libraries.testing
}
Change build.gradle from
compile project(':react-native-lock')
to
compile(project(':react-native-lock')) { exclude module: 'react-native' }
As it is documented here: https://docs.getexponent.com/versions/v14.0.0/guides/exponentkit.html#make-native-changes

Error:Execution failed for task ':app:compileReleaseJavaWithJavac'. >

I have 3 Android app in one project as shown above. I have a library called "mylibs" which used by all app. I want to generate a signed APK (with ProGuard) for app,app2 and app3. So I go to Build > Generate Signed APK.. then
Errors while building APK
Messages shows as below :
Gradle app :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.biocryptodisk.bookconverter"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName '1.0'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
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:support-v4:23.4.0'
testCompile 'junit:junit:4.12'
compile project(':mylibs')
}
Gradle app2 :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.biocryptodisk.app2"
minSdkVersion 19
targetSdkVersion 23
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(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:support-v4:23.4.0'
testCompile 'junit:junit:4.12'
compile project (':mylibs')
}
Gradle app3:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.biocryptodisk.uniqreader"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName '1.0'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:support-v4:23.4.0'
compile files('libs/epublib-core-latest.jar')
compile files('libs/slf4j-android-1.6.1-RC1.jar')
compile project(':mylibs')
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
}
Gradle mylibs :
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
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(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:support-v4:23.4.0'
testCompile 'junit:junit:4.12'
}
The AESCBC256Crypt and others classes stated above are all from mylibs. What I have done wrong here?

Execution failed for task :app:transformClassesAndResourcesWithProguardForRelease

I am trying to release my Android application with Gradle.
app build Grade::
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "xxxx.xxxxx"
minSdkVersion 9
targetSdkVersion 24
versionCode 1
versionName "2.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
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:24.2.1'
testCompile 'junit:junit:4.12'
}

Execution failed for task ':app:preDexDebugAndroidTest'

I am trying to setup a framework in Android Studio with Espresso and Cucumber.
When I am trying to run Android test configuration, the build fails giving me the following exception:
Execution failed for task ':app:preDexDebugAndroidTest'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
This is my bundle.gradle file dependencies.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "testapp.drayson.com.testapp"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
// multiDexEnabled true
testInstrumentationRunner "testapp.drayson.com.testapp.Instrumentation"
}
sourceSets {
androidTest {
assets.srcDirs = ['src/androidTest/assets']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile 'com.android.support:support-annotations:23.1.0'
androidTestCompile('com.android.support.test:runner:0.3')
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
//Cucumber
androidTestCompile 'info.cukes:cucumber-android:1.2.0#jar'
androidTestCompile 'info.cukes:cucumber-picocontainer:1.2.4'
androidTestCompile('info.cukes:cucumber-junit:1.1.4') {
exclude module: 'cucumber-jvm-deps'
exclude module: 'cucumber-core'
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
androidTestCompile('info.cukes:cucumber-jvm:1.2.4') {
}
androidTestCompile('info.cukes:cucumber-core:1.2.4') {
exclude module: 'cucumber-jvm-deps'
}
androidTestCompile('info.cukes:cucumber-jvm-deps:1.0.3') {
}
//Espresso
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1') {
exclude module: 'junit'
exclude module: 'runner'
}
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
exclude module: 'espresso-core'
exclude module: 'support-v4'
}
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
}
try adding multiDexEnabled as true in your
buildType{ release{ multiDexEnabled true} }
hope it works for you..

Categories

Resources