gpt4 book ai didi

android - 构建签名的 apk 时显示错误

转载 作者:搜寻专家 更新时间:2023-11-01 07:45:39 24 4
gpt4 key购买 nike

当我构建 apk 时,它没有显示任何错误,但在生成签名的 apk 时,它在 logcat 中显示以下错误。

错误:

  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

我的 build.gradle 文件是:

apply plugin: 'com.android.application'

安卓{ 编译SDK版本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'
}

最佳答案

在您的 build.gradle 中寻找 dexOptions:

dexOptions {
incremental true
javaMaxHeapSize "4g"
}

注释掉行:incremental true

在 2.1.0-rc1 (2016/4/22) 或更高版本中默认开启增量编译。所以在 build.gradle 文件中声明它是多余的。有关更多信息,请查看:https://stackoverflow.com/a/37540467/5192105

打开您的proguard-project.txt(配置文件)并添加。

-dontwarn sun.reflect.**
-dontwarn android.test.**

希望这对您有所帮助。

要禁用此功能:

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'.

打开你的 proguard.pro 并添加:

-dontwarn java.lang.management.**

关于android - 构建签名的 apk 时显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44933291/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com