我在GitHub上有一个项目,既在办公室也在家里工作。大约两个月前,这个项目在两台机器上都正常运行。然后两周前,在我的家用电脑上停止了运行,但是在我的工作电脑上仍然可以正常运行。以下是我得到的错误信息:
: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.
我已经将涉及
不幸的是,我不记得我做了什么来使它停止工作。我认为在这件事发生前一周我升级了Android Studio,并花费了相当长的时间来处理
"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.+' } }"
: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.
给我带来错误的stripe
包是一个第三方库,你可以在这里找到。我按照他们的要求将其列为我的build.gradle文件中的依赖项。
compile 'com.stripe:stripe-android:+'
我已经将涉及
stripe
的所有代码注释掉,应用程序完全正常运行,所以我知道问题与我处理该包的方式有关。不幸的是,我不记得我做了什么来使它停止工作。我认为在这件事发生前一周我升级了Android Studio,并花费了相当长的时间来处理
ProGuard
配置。
我尝试过:
- 在没有进行
ProGuard
更改的master
分支上工作。 - 卸载并重新安装Android Studio。
- 重新克隆git仓库。
- 安装API 17(stripe for eclipse需要此项。虽然不是Studio,但我尝试了一下)。
- 联系stripe客户支持,但他们毫无头绪。
- 这篇stackoverflow文章。然而,没有任何Mac电脑接触过该项目,我也没有个人压缩与
stripe
相关的任何内容。 - 从这里,将魔数从十六进制转换为ASCII码。结果是Q`,我不认识它。
"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应用程序模块 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;
}
}
本地 Android 库模块 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'
}
+
,而是指定完整的版本号来引用stripe-android
。这样你就可以尝试不同的版本来查看是否有问题。对于io.fabric.tools:gradle
也是如此。 - Sean Barbeau