导致错误的Gradle依赖关系“无效幻数” [英] Gradle dependency causing error "Invalid Magic Number"
问题描述
我在GitHub上有一个项目,我在家里的办公室工作。大约2个月它在两台机器上工作正常。然后两周前,它停止在我的家用PC上运行,但在我的工作PC上仍然正常工作。
这是我得到的错误:
:app:shrinkDebugMultiDexComponents FAILED
失败:构建失败,出现异常。
- 出错:
任务':app:shrinkDebugMultiDexComponents'的执行失败。
java.io.IOException:无法读取[D:\dev\gitRepo\app\android\app\build\intermediates\multi-dex\debug\allclasses。 jar](无法处理类[__MACOSX / com / stripe / android /._ BuildConfig.class](类中的无效幻数[51607]))
- 尝试:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。
stripe
给我错误的软件包是第三方库你可以在这里找到。
compile'com.stripe:stripe- android:+'
我已经注释掉了所有有关 不幸的是,我不记得我已经做了什么让这个停止工作。我认为在这之前的一周里我升级了Android Studio,并花费了大量的时间来处理 我尝试过的方法: 我认为这可能与我为ProGuard所做的一些事情,但我不明白。我与Proguard的工作完全不同,安装了干净的AndroidStudio,有一个干净的存储库克隆,当我在办公室时,项目仍然正常工作。 编辑 我在 项目 Android应用程序模块 本地Android库模块 这个问题可能与您运行的Java版本有关。我有一个类似的问题,并发现Java 8被用于构建。当我更改为Java 7时,此构建问题已得到解决。 在Android Studio中转到 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. The I have commented out all code pertaining the 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 What I have tried: 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 Project Android Application Module Local Android Library Module
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 The 这篇关于导致错误的Gradle依赖关系“无效幻数”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! stripe
和应用程序运行完全正常,所以我知道这与我如何处理该包有关。
ProGuard
配置。
$ b
master
分支中没有 ProGuard
更改
stripe
相关的任何内容
调试
BuildType。这些是我的3个gradle文件。第一个用于整个Project,第二个用于应用程序模块,第三个用于本地android库Module。
build.gradle
:
buildscript {
repositories {
jcenter()
maven {url' http://download.crashlytics.com/maven '}
}
依赖关系{
classpath'com.android.tools.build:gradle:1.2.3'
classpath'com.crashlytics.tools.gradle:crashlytics-gradle:1. +'
}
}
allprojects {
存储库{
jcenter()
maven {url'http:// download .crashlytics.com / maven'}
}
}
build.gradle
buildscript {
存储库{
maven {url'https://maven.fabric.io/public'}
}
依赖项{
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
buildToolsVersion22.0.1
defaultConfig {
applicationIdcom.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'布尔','enableCrashlytics','tru e'
}
debug {
buildConfigField'布尔','enableCrashlytics','false'
}
adhoc {
可调试真
signedConfig signingConfigs.debug
buildConfigField'Boolean','enableCrashlytics','true'
}
}
packagingOptions {
exclude'META-INF / DEPENDENCIES.txt'
排除'META-INF / LICENSE.txt'
排除'META-INF / NOTICE.txt'
排除'META-INF / NOTICE'
排除'META-INF /许可'
排除'META-INF /相关性'
排除'META-INF / notice.txt'
排除'META-INF / license.txt'
排除'META- INF / dependencies.txt'
exclude'META-INF / LGPL2.1'
}
}
依赖关系{
编译项目(':localLibrary')
编译'com.facebook.android:facebook-and roid-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;
build.gradle
apply plugin:'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion22.0.1
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard -rules.txt'
}
}
}
依赖关系{
编译'com.android.support:support-v4:22.1.0'
编译'com.google.code.gson:gson:2.2.2'
编译'com.android.support:multidex:1.0.0'
编译组:'org.apache。 httpcomponents',名称:'httpmime',版本:'4.3.5'
编译组:'org.apache.httpcomponen ts',name:'httpclient-android',版本:'4.3.5'
}
文件 - >项目结构 - > SDK位置
JDK位置
应该是Java 1.7.x(Java 7)
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:+'
stripe
and the app runs completely fine, so I do know it has something to do with how I am handling that package. ProGuard
configurations.
master
branch where no ProGuard
changes have been made.stripe
.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.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' }
}
}
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;
}
}
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'
}
File -> Project Structure -> SDK Location
JDK Location
should be Java 1.7.x (Java 7)