Error:Execution failed for task ':app:transformClassesWithDexForLegacyDebug' - android

getting the error "Error:Execution failed for task ':app:transformClassesWithDexForLegacyDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException"
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
// needed for okHttp from 23sdk. https://medium.com/android-news/android-networking-i-okhttp-volley-and-gson-72004efff196#.gsfpn3ez8
useLibrary 'org.apache.http.legacy'
dexOptions {
javaMaxHeapSize "3g"
}
defaultConfig {
applicationId "bf.io.openshop"
minSdkVersion 15
targetSdkVersion 23
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
debug {
minifyEnabled false
multiDexEnabled true
debuggable true
versionNameSuffix '-DEBUG'
}
release {
minifyEnabled false
debuggable true
}
}
testOptions {
unitTests.returnDefaultValues = true
}
productFlavors {
Modern {
minSdkVersion 23
}
Legacy {
minSdkVersion 15
}
}
sourceSets {
androidTest {
resources.srcDirs += ['src/androidTest/resources']
}
}
}
task clearData(type: Exec) {
def clearDataCommand = ['adb', 'shell', 'pm', 'clear', 'bf.io.openshop']
commandLine clearDataCommand
}
repositories { mavenCentral() }
dependencies {
// if needed jar libraries, add them to libs folder and load them here:
// compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.jakewharton.timber:timber:4.1.2'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'mbanje.kurt:fabbutton:1.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.9.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
compile 'com.android.support:multidex:1.0.0'
//// Unit testing dependencies
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-all:1.10.19'
// Set this dependency if you want to use the Hamcrest matcher library
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.powermock:powermock-module-junit4:1.6.4'
testCompile 'org.powermock:powermock-api-mockito:1.6.4'
//// Instrumentation test dependencies
androidTestCompile 'com.android.support:support-annotations:23.4.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
}
apply plugin: 'com.google.gms.google-services'

you can try to clean your project ,rebuild it .It maybe ok.

1.Try to clear cache and rebuild
At path file>clearcache>clear cache and restart
Add multidex support in app level gradle
multudex true inside defaultConfig like this
dexOptions {
javaMaxHeapSize "4g"
}
defaultConfig {
multiDexEnabled true
}

Related

Gradle build fails on enabling data binding

i am facing a strange issue. I have decided to enable databinding in my project and in order to do so i followed the developer.android guidelines. So i added the dataBinding tag in my gradle file and gradle sync fails and shows the following error.
Error:java.lang.NullPointerException
Error:Execution failed for task ':app:mergeDebugResources'.
Error: java.lang.NullPointerException
and no other information is there so that i can track down the problem. My gradle file is below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId '***.********.***'
minSdkVersion 19
targetSdkVersion 26
versionCode 76
versionName '4.8.3'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
// Enabling multidex support.
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
//todo useLibrary is added agains LinkedInActivity which uses legacy http connection,
//should change it to different implementation
useLibrary 'org.apache.http.legacy'
dexOptions {
jumboMode true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
packagingOptions {
exclude 'build.xml'
exclude 'lib/getLibs.ps1'
exclude 'lib/getLibs.sh'
exclude 'lib/gson-2.2.2.jar'
}
dataBinding {
enabled = true
}
lintOptions {
disable 'MissingTranslation'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':library_fab')
implementation project(':library')
implementation project(':barcodeScannerLib')
implementation project(':cropper')
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
}
compile
('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.10.6#aar') {
transitive = true
}
implementation project(':libraryDatePicker')
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.code.gson:gson:2.3.1'
compile 'de.greenrobot:greendao:1.3.7'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.8.0'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:cardview-v7:26.0.1'
compile 'com.android.support:recyclerview-v7:26.0.1'
compile 'com.android.support:palette-v7:26.0.1'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:exifinterface:26.0.1'
implementation project(':librarySweetAlertDialog')
}
apply plugin: 'com.google.gms.google-services'
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.4.0'
}
}
}
}
The problem with Databinding (and Dagger as well) is that, if there's an error, a lot of files are not generated, giving lots of errors. So much in fact, that the default output of javac is not enough to see the error message at the bottom.
Most of the time, it helps to increase the maximum number of error output lines, by adding this to your build.gradle
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "1500"
}
}

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

I am getting the following error while building signed APK
Error:Execution failed for task ':app:transformJackWithJackForRelease'
com.android.build.api.transform.TransformException:
com.android.builder.core.JackToolchain$ToolchainException: Jack configuration exception.
Error while parsing '/Users/omprakash/.android/build-cache/44cf3550bd071d5e2184a0fbb6e8da24ff70e1cb/output/proguard.txt':2
The app is running fine in debug mode.
But when I am building the signed APK I am getting the above error. Tried changing the buildToolVersion but it didn't help. I also have MyApplication class extending MultiDexApplication.
The following is my gradle file:-
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 26
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.omagrahari"
manifestPlaceholders = [onesignal_app_id : "9727c212-****-****-**********",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "21051******"]
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
cruncherEnabled = false
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
dexOptions {
incremental true
preDexLibraries false
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
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.zendesk:sdk:1.11.0.1#aar') {
transitive = true;
}
compile('io.fabric.sdk.android:fabric:1.4.1#aar') {
transitive = true;
}
compile 'com.android.volley:volley:1.0.0'
compile 'com.github.d-max:spots-dialog:0.7#aar'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:26.+'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.google.android.gms:play-services-maps:9.2.0'
compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'com.google.android.gms:play-services-gcm:9.2.0'
compile 'com.daimajia.swipelayout:library:1.2.0#aar'
compile 'com.github.lzyzsd:circleprogress:1.2.1'
compile 'com.cjj.materialrefeshlayout:library:1.3.0'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.cocosw:bottomsheet:1.+#aar'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.2'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'me.relex:circleindicator:1.2.2#aar'
compile 'com.squareup.okhttp3:okhttp:3.9.1'
compile 'com.github.bumptech.glide:glide:4.3.1'
compile 'com.sendbird.sdk:sendbird-android-sdk:3.0.43'
compile 'com.googlecode.libphonenumber:libphonenumber:8.4.2'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
compile 'com.onesignal:OneSignal:3.+#aar'
}
I don't get how to solve this. Please help.

Getting Duplicate entry java.util.zip.ZipException: duplicate entry:

I am getting the duplicate entry issue at runtime if I add the intercom library to my gradle.
This is my total app gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
lintOptions {
abortOnError false
disable "ResourceType"
checkReleaseBuilds false
}
ndk {
abiFilters "armeabi", "armeabi-v7a","x86"
}
applicationId "com.sample.activities"
minSdkVersion 19
targetSdkVersion 26
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
with_ImageProcessor {
}
without_ImageProcessor {
}
}
}
configurations {
}
dependencies {
compile 'com.google.android.gms:play-services-base:11.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.viewpagerindicator:library:2.4.1#aar'
configurations {
all*.exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-gcm:11.0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
compile 'com.google.firebase:firebase-appindexing:11.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:support-v4:26.0.2'
compile 'com.android.support:support-v13:26.0.2'
//for intercom
compile 'io.intercom.android:intercom-sdk-fcm:4.+'
compile 'com.google.firebase:firebase-auth:11.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'
compile 'com.uncopt:android.justified:1.0'
compile 'com.google.firebase:firebase-invites:11.0.1'
}
apply plugin: 'com.google.gms.google-services'
i am getting this issue afetr adding this line
compile 'io.intercom.android:intercom-sdk-fcm:4.+'
This is the run Time error I am getting
Error:Execution failed for task':waleteros:transformClassesWithJarMergingForWith_ImageProcessorDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzbax.class
Please help me to resolve this issue
Try to add following version of intercom library instead of version you are using :
compile 'io.intercom.android:intercom-sdk-fcm:4.0.0'
OR
compile 'io.intercom.android:intercom-sdk-fcm:4.0.4'

TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/util/MapCollections$ArrayIterator.class

this is my project build.gradle file .whenever i run the project in android studio i get the duplicate entry: android/support/v4/util/MapCollections$ArrayIterator.class error
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "com.aitsolution.bizitapp.bizit"
minSdkVersion 16
targetSdkVersion 23
versionCode 14
versionName "1.13"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
dexOptions {
javaMaxHeapSize "3g"
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
dependencies {
// compile fileTree(include: ['*.jar'], dir: 'libs')
// testCompile 'junit:junit:4.12'
compile files('libs/linkedin-j-android.jar')
compile files('libs/MobileOcrEngine.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
compile files('libs/ksoap2_2.6.0.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.android.gms:play-services-appindexing:9.0.0'
compile 'com.android.support:cardview-v7:23.3.+'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.google.code.gson:gson:2.4'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.edmodo:cropper:1.0.1'
}
I think facebook sdk comes with v4-support library exclude that and try.
compile ('com.facebook.android:facebook-android-sdk:4.6.0') {
exclude module: 'support-v4'
}

Update gradle to experimental version - Error

I'm following the guide http://tools.android.com/tech-docs/new-build-system/gradle-experimental to update my gradle configuration in order to use ndk.
Pluggin version: 0.6.0-alpha5
Gradle version: 2.10
After the changes, I get the error:
Gradle sync failed: Cause: com.android.build.gradle.managed.AndroidConfig$Impl
Here is my build.gradle. Did I forgot something or made a mistake ?
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.appid"
minSdkVersion.apiLevel 19
targetSdkVersion.apiLevel 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file('proguard-android.txt'))
proguardFiles.add(file('proguard-rules.pro'))
}
}
ndk {
moduleName "ImageProc"
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
// JSON serialization
compile 'com.google.code.gson:gson:2.4'
// Network
compile 'com.squareup.retrofit:retrofit:2.0.0-beta3'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp3:okhttp:3.0.0-RC1'
// Junit
testCompile 'org.robolectric:robolectric:3.0'
}
I believe that buildTypes should be outside the "android" block. Also, possibly replace "defaultConfig" with "defaultConfig.with" I followed build.gradle structure in this answer. Then Gradle finally was able to build.
Maybe this will help.
My working file for:
Android Studio: 3.0.1
with:
classpath 'com.android.tools.build:gradle-experimental:0.11.1'
looks like this:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.niedved.xxx"
minSdkVersion.apiLevel 19
targetSdkVersion.apiLevel 22
ndk {
moduleName "mupdf"
}
multiDexEnabled true
jackOptions {
enabled true
}
}
buildTypes {
release {
jackOptions {
enabled true
}
minifyEnabled false
proguardFiles.add(file("proguard-rules.pro"))
}
}
productFlavors {
}
compileOptions.with {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
}
dependencies {
compile project(':main')
compile 'com.android.support:multidex:1.0.2'
compile 'com.google.http-client:google-http-client-android:+'
compile 'com.google.api-client:google-api-client-android:+'
compile 'com.google.api-client:google-api-client-gson:+'
compile 'com.google.code.gson:gson:2.6'
compile files('libs/devsmartlib.jar')
compile files('libs/ormlite-core-4.48.jar')
compile files('libs/ormlite-android-4.48.jar')
compile files('libs/retrofit-1.7.1.jar')
compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.android.gms:play-services-maps:11.6.2'
compile 'com.google.android.gms:play-services:11.6.2'
}

Categories

Resources