I have a project on GitHub that I work on both in the office at home. For about 2 months it was working fine on both machines. Then two weeks ago, it stopped running on my home PC, but still works fine on my work PC.
This is the error I get:
:app:shrinkDebugMultiDexComponents FAILED
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:shrinkDebugMultiDexComponents'. java.io.IOException: Can't read [D:\dev\gitRepo\app\android\app\build\intermediates\multi-dex\debug\allclasses.jar] (Can't process class [__MACOSX/com/stripe/android/._BuildConfig.class] (Invalid magic number [51607] in class))
- Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
The stripe
package that is giving me errors is a 3rd party library that you can find here. I list it as a dependency in my build.gradle file exactly as they say to.
compile 'com.stripe:stripe-android:+'
I have commented out all code pertaining the stripe
and the app runs completely fine, so I do know it has something to do with how I am handling that package.
Unfortunately I don't remember exactly what I had done to make this stop working. I do think that the week before this happened I upgraded Android Studio, and spent a considerable amount of time messing with ProGuard
configurations.
What I have tried:
master
branch where no ProGuard
changes have been made.stripe
.I think it may have something to do with something I did for ProGuard, but I don't understand how. I'm on a completely different branch than any Proguard work, with a clean AndroidStudio install, with a clean repository clone, and the project still works fine when I'm in the office.
EDIT
I am running this on the debug
BuildType. These are my 3 gradle files. The first is for the entire Project, the second is for the Application Module, and the third is for a local android library Module.
Project build.gradle
:
buildscript {
repositories {
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
allprojects {
repositories {
jcenter()
maven{ url 'http://download.crashlytics.com/maven' }
}
}
Android Application Module build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.app.android"
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
buildConfigField 'Boolean', 'enableCrashlytics', 'true'
}
debug {
buildConfigField 'Boolean', 'enableCrashlytics', 'false'
}
adhoc {
debuggable true
signingConfig signingConfigs.debug
buildConfigField 'Boolean', 'enableCrashlytics', '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 project(':localLibrary')
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'commons-io:commons-io:2.4'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:support-v4:22.0.1'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'
compile 'com.google.android.gms:play-services-maps:8.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'io.card:android-sdk:5.0.1'
compile 'com.stripe:stripe-android:+'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
transitive = true;
}
}
Local Android Library Module build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:22.1.0'
compile 'com.google.code.gson:gson:2.2.2'
compile 'com.android.support:multidex:1.0.0'
compile group: 'org.apache.httpcomponents' , name: 'httpmime' , version: '4.3.5'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5'
}
This problem is probably related to the version of Java that you are running. I had a similar problem and discovered that Java 8 was used for the build. When I changed to Java 7, this build problem was fixed.
In Android Studio go to
File -> Project Structure -> SDK Location
The JDK Location
should be Java 1.7.x (Java 7)
Yeah verify both machines have the same Java version, and indeed the same version of Android Studio. The only other thing I can think of is that maybe Stripe is using the build tools bundled with AS to build your apk, and the ones you have installed by default differ slightly and are missing something - see this post I made on a similar problem I had.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With