[英]It's showing error while building signed apk
When I am building apk it's not showing any error but while generating signed apk it's showing following error in logcat. 当我构建apk时,它没有显示任何错误,但是在生成签名的apk时,它在logcat中显示了以下错误。
Error: 错误:
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find
referenced class java.lang.management.ManagementFactory
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find
referenced class java.lang.management.ThreadMXBean
Warning:org.junit.rules.DisableOnDebug: can't find referenced class
java.lang.management.RuntimeMXBean
Warning:org.junit.rules.DisableOnDebug: can't find referenced class
java.lang.management.RuntimeMXBean
Error:Execution failed for task
':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details
Warning:there were 10 unresolved references to classes or interfaces.
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find
referenced class java.lang.management.ManagementFactory
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find
referenced class java.lang.management.ThreadMXBean
Warning:Exception while processing task java.io.IOException: Please correct
the above warnings first.
Warning:org.junit.rules.DisableOnDebug: can't find referenced class
java.lang.management.ManagementFactory
Warning:org.junit.rules.DisableOnDebug: can't find referenced class
java.lang.management.ManagementFactory
my build.gradle file is: 我的build.gradle文件是:
apply plugin: 'com.android.application'
android { compileSdkVersion 23 buildToolsVersion '25.0.0' android {compileSdkVersion 23 buildToolsVersion '25 .0.0'
defaultConfig {
applicationId "com.infinity.wall_to_paper"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
buildTypes{
debug{
debuggable true
}
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENCE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENCE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/licence.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
} }
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile('com.android.support:appcompat-v7:23.4.0') {
exclude module: 'support-v4'
}
compile('com.android.support:support-v4:23.4.0') {
exclude module: 'support-v4'
}
android {
buildTypes {
debug {
debuggable true
}
}
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-ads:10.2.4'
}
} }
Inside your build.gradle look for the dexOptions
: 在build.gradle内部,查找
dexOptions
:
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
Comment out the line: incremental true
. 注释掉这一行:
incremental true
。
By default incremental is turned on Java compilation in 2.1.0-rc1 (2016/4/22) or later. 默认情况下,在2.1.0-rc1(2016/4/22)或更高版本中启用Java编译增量功能。 So its redundant to declare it in build.gradle file.
因此在build.gradle文件中声明它是多余的。 For more information check this out: https://stackoverflow.com/a/37540467/5192105
有关更多信息,请查看: https : //stackoverflow.com/a/37540467/5192105
Open your proguard-project.txt (config file) and add. 打开您的proguard-project.txt (配置文件)并添加。
-dontwarn sun.reflect.**
-dontwarn android.test.**
Hope this helps. 希望这可以帮助。
To disable this: 要禁用此功能:
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find
referenced class java.lang.management.ManagementFactory
Warning:org.junit.internal.runners.statements.FailOnTimeout: can't find
referenced class java.lang.management.ThreadMXBean
Warning:org.junit.rules.DisableOnDebug: can't find referenced class
java.lang.management.RuntimeMXBean
Warning:org.junit.rules.DisableOnDebug: can't find referenced class
java.lang.management.RuntimeMXBean
Error:Execution failed for task
':app:transformClassesAndResourcesWithProguardForRelease'.
Open your proguard.pro
and add : 打开您的
proguard.pro
并添加:
-dontwarn java.lang.management.**
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.