这是我得到的错误:
: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.
给我错误的条带包是第三方库that you can find here.我将它作为我的build.gradle文件中的依赖项完全按照他们的说法列出.
compile 'com.stripe:stripe-android:+'
我已经注释掉了与条纹相关的所有代码,并且应用程序运行完全正常,所以我知道它与我如何处理该包有关.
不幸的是,我不记得我做了什么让这个停止工作.我确实认为在发生这一周的前一周我升级了Android Studio,并花了相当多的时间搞乱ProGuard配置.
我尝试过的:
>在没有进行ProGuard更改的主分支上工作.
>卸载并重新安装Android Studio
>重新克隆git repo
>安装API 17(eclipse的条纹需要这个.不是Studio,但我试了一下).
>联系条形客户支持,但他们没有任何线索.
> This stack overflow post.但是,没有Mac计算机触及过该项目,也没有亲自压缩与条纹有关的任何内容.
> From here,将幻数从十六进制转换为ASCII.结果是我不认识的Q`.
我认为这可能与我为ProGuard所做的事情有关,但我不明白如何做.我和Proguard的工作完全不同,有一个干净的AndroidStudio安装,有一个干净的存储库克隆,当我在办公室时,项目仍然正常.
编辑
我在调试BuildType上运行它.这些是我的3个gradle文件.第一个是整个项目,第二个是应用程序模块,第三个是本地android库模块.
项目build.gradle:
buildscript {
存储库{
jcenter()
maven {url’http://download.crashlytics.com/maven‘}
}
依赖{
classpath’com.android.tools.build:grad: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','false' } adhoc { debuggable true signingConfig signingConfigs.debug buildConfigField 'Boolean','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' }
解决方法
在Android Studio中转到
File -> Project Structure -> SDK Location
JDK位置应该是Java 1.7.x(Java 7)