Execution failed for task ':app:preDexDebugAndroidTest' - android

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..

Related

I updated my android studio and gradle to the latest one -> and I can't work with data binding

I get this error message in app Gradle:
Failed to resolve: com.android.databinding:library:3.3.2
I see in another question it because of apt that in the Gradle
I don't have apt in my Gradle
Here is my app Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.ophiropt.meissa"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-std=c++1z -frtti -fexceptions" } }
ndk {
abiFilters 'armeabi-v7a' }
vectorDrawables.useSupportLibrary = true}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}}
dataBinding {
enabled = true }
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
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:25.0.1'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.couchbase.lite:couchbase-lite-android:1.2.0'
compile 'com.google.code.gson:gson:2.6.2'
compile "com.android.support:recyclerview-v7:25.0.0"
compile 'com.android.support:cardview-v7:25.0.0'
compile 'com.android.support:design:25.0.1'
compile 'org.greenrobot:eventbus:3.0.0'
testCompile 'junit:junit:4.12'
compile 'com.afollestad.material-dialogs:core:0.9.4.5'
compile 'com.elmargomez.typer:typerlib:1.0.0'
compile (name:'charting-release', ext:'aar')
compile (name:'drawing-release', ext:'aar')
compile (name:'data-release', ext:'aar')
compile (name:'core-release', ext:'aar')
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
You need a google() dependency:
buildscript {
repositories {
google() // here
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
}
}
allprojects {
repositories {
google() // and here
jcenter()
}
the problem by me was that the minimum SDK version with Gradle gradle:3.3.2 has to be 28 and by me, it is 25

Android Gradle build error while running the project

I have mentioned my gradle below please let me know what is the solution for that question and have used the api level 25 in my project
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
signingConfigs {
config {
keyAlias 'yaksha'
keyPassword '123456'
storeFile file('/home/abhinav/Downloads/yaksha.jks')
storePassword '123456'
}
}
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.tene.yaksha"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
testApplicationId "com.tene.yaksha1"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
testHandleProfiling true
testFunctionalTest true
}
testOptions {
reportDir "$rootDir/test-reports"
resultsDir "$rootDir/test-results"
}
dataBinding {
enabled = true
}
dexOptions {
//incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
}
lintOptions {
// lintConfig file("$project.rootDir/tools/rules-lint.xml")
abortOnError false
htmlOutput file("$project.buildDir/outputs/lint/lint.html")
warningsAsErrors false
xmlReport true
}
buildTypes {
release {
minifyEnabled true
debuggable false
jniDebuggable true
signingConfig signingConfigs.config
renderscriptDebuggable true
shrinkResources true
proguardFile '/home/abhinav/Android/Sdk/tools/proguard/yakshaproguard.txt'
}
debug {
minifyEnabled false
proguardFile '/home/abhinav/Android/Sdk/tools/proguard/yakshaproguard.txt'
multiDexKeepFile file('multidex-config.txt')
}
}
packagingOptions
{
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
testOptions {
unitTests.returnDefaultValues = true
unitTests {
all {
jvmArgs '-XX:MaxPermSize=256m'
if (it.name == 'testDebug') {
systemProperty 'debug', 'true'
}
if (it.name == 'connectedDebugAndroidTest') {
}
}
}
}
configurations {
}
}
dependencies {
// compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.android.gms:play-services:10.2.1'
compile project(':realmtenedbservice')
compile project(':tenewsrestlib')
compile project(':TeneLocationLib')
compile project(':SecurityYsc')
compile project(':library')
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.birbit:android-priority-jobqueue:2.0.1'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
compile 'io.reactivex:rxjava:1.1.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.google.maps.android:android-maps-utils:0.4+'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'io.realm:android-adapters:1.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.sromku:simple-storage:1.2.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'joda-time:joda-time:2.9.7'
compile 'id.zelory:compressor:1.0.4'
compile 'io.reactivex:rxandroid:1.2.1'
}
I'm getting this error while running the project,can you anybody give suggesions why this is coming
Information:Gradle tasks [:app:assembleDebug]
Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class
Information:BUILD FAILED
Information:Total time: 18.768 secs
Information:1 error
Information:1 warning
Information:See complete output in console
You can exclude that class, which is showing duplicate like as
configurations {
all*.exclude group: 'org.apache.commons'
}
I thik this is duplicate
compile 'com.android.support:multidex:1.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

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

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')
}

Does binding class will generate automatically?

I am developing a app with google databinding library. But i found every time i add a new layout xml and the correspond binding class won't generate. And i have to hit the build button on android studio, then the binding class will generate.
Here is the dependencies i use
app build.grade:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.hugo'
apply plugin: 'com.fernandocejas.frodo'
android {
signingConfigs {
}
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.xinpinget.gamecube"
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
production {
signingConfig signingConfigs.config
}
internal {
}
}
// dexOptions {
// incremental true
// }
}
retrolambda {
jdk "/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home"
oldJdk System.getenv("JAVA_HOME")
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':insta-filter-release')
compile project(':library-debug')
compile('com.facebook.fresco:fresco:0.7.0') {
exclude module: 'support-v4'
}
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
// apt ('com.squareup.dagger:dagger-compiler:1.2.2') {
// }
compile('com.android.support:design:23.0.1') {
exclude module: 'support-v4'
exclude module: 'appcompat-v7'
}
compile('io.reactivex:rxandroid:1.0.1') {
exclude module: 'rxjava'
}
compile('io.reactivex:rxjava-debug:1.0.2') {
exclude module: 'rxjava'
}
compile('com.squareup.retrofit:adapter-rxjava:2.0.0-beta2') {
exclude module: 'rxjava'
}
internalCompile 'com.squareup.retrofit:retrofit-mock:2.0.0-beta1'
internalCompile 'com.squareup.retrofit:adapter-rxjava-mock:2.0.0-beta1'
compile('com.squareup.retrofit:converter-gson:2.0.0-beta2') {
exclude module: 'retrofit'
}
compile('com.umeng:fb:5.4.0') {
/**
* If not exclude message module, gradle will throw a error when building.
*/
exclude module: 'message'
exclude module: 'support-v4'
}
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.squareup:otto:1.3.8'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'io.reactivex:rxjava:1.0.14'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile project(':ShareSDK_oneKeyShare')
compile project(':sMSSDK')
compile 'com.android.support:cardview-v7:23.1.0'
}
I solved the problem.
It's caused by android-apt.
https://bitbucket.org/hvisser/android-apt/issues/38/android-apt-breaks-brand-new-data-binding

Categories

Resources