gpt4 book ai didi

android - minifyEnabled true 在调试和 Release模式下不起作用

转载 作者:行者123 更新时间:2023-11-29 23:43:18 64 4
gpt4 key购买 nike

我无法在调试和 Release模式下使用 minifyEnabled true 运行 apk。我已经引用了下面的链接,但没有一个对我有用。

1. Android- Error:Execution failed for task ':app:transformClassesWithDexForRelease'

2。 Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes - Android studio 2.0 beta 6

下面是我的应用build.gradle文件

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId 'XX.XX.XXX'
minSdkVersion 21
targetSdkVersion 23
versionCode 9
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
sourceSets.main {
jni.srcDirs = [] //disable automatic ndk-build call
jniLibs.srcDir 'src/main/libs' //integrate your libs from libs instead of jniLibs
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
buildTypes {
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}


}
productFlavors {
}
lintOptions {
checkReleaseBuilds false
}
packagingOptions {
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'

}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
// compile files('libs/maflogonimo-1.210.3.jar')
compile project(':android-logging-log4j-1.0.3')
compile project(':log4j-1.2.17')
compile files('libs/gson-2.6.2.jar')
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.esri.arcgis.android:arcgis-android:10.2.8-1'
//GIS

compile(name:'ClientHubSLL-3.16.1', ext:'aar')
compile(name:'ClientLog-3.16.1', ext:'aar')
compile(name:'Common-3.16.1', ext:'aar')
compile(name:'Connectivity-3.16.1', ext:'aar')
compile(name:'CoreServices-3.16.1', ext:'aar')
compile(name:'DataVaultLib-3.16.1', ext:'aar')
compile(name:'E2ETrace-3.16.1', ext:'aar')
compile(name:'HttpConvAuthFlows-3.16.1', ext:'aar')
compile(name:'HttpConversation-3.16.1', ext:'aar')
compile(name:'MAFLogger-3.16.1', ext:'aar')
compile(name:'MAFLogonCore-3.16.1', ext:'aar')
compile(name:'ODataAPI-3.16.1', ext:'aar')
compile(name:'ODataOnline-3.16.1', ext:'aar')
compile(name:'Request-3.16.1', ext:'aar')
compile(name:'SupportabilityFacade-3.16.1', ext:'aar')

compile(name:'MAFCalendar-3.16.1', ext:'aar')
compile(name:'MAFLocaleAwareControls-3.16.1', ext:'aar')
compile(name:'MAFLogViewer-3.16.1', ext:'aar')
compile(name:'MAFSettingScreen-3.16.1', ext:'aar')
compile(name:'MAFTreeView-3.16.1', ext:'aar')
compile(name:'MAFUIComponents-3.16.1', ext:'aar')
compile(name:'XscriptParser-3.16.1', ext:'aar')
compile(name:'MAFLogonUI-3.16.1', ext:'aar')
compile(name:'MobilePlace-3.16.1', ext:'aar')

}

apply plugin: 'com.google.gms.google-services'

下面是我的 proguard-rules.pro 文件

-renamesourcefileattribute SourceFile
-keepattributes SourceFile, LineNumberTable
-keepattributes Exceptions, Signature

-keepattributes EnclosingMethod
-keepattributes InnerClasses

-keep class org.javarosa.** { *; }
-keep class com.sap.** { *; }

-keep class jcifs.** { *; }


-dontwarn com.google.**
-dontwarn org.apache.**
-dontwarn com.sap.**
-dontwarn au.com.bytecode.**
-dontwarn org.joda.**
-dontwarn android.content.**
-dontwarn android.graphics.**
-dontwarn android.util.**
-dontwarn android.view.**

-dontwarn javax.servlet.**
-dontwarn jcifs.http.**
-dontwarn org.codehaus.**

错误如下,

  Copying resources from program jar [D:\SourceCode\app\build\intermediates\exploded-aar\com.android.support\support-v4\24.0.0\jars\libs\internal_impl-24.0.0.jar] (filtered)
Copying resources from program jar [D:\SourceCode\log4j-1.2.17\log4j-1.2.17.jar] (filtered)
Copying resources from program jar [D:\SourceCode\android-logging-log4j-1.0.3\android-logging-log4j-1.0.3.jar] (filtered)
Copying resources from program jar [D:\SourceCode\app\build\intermediates\transforms\mergeJavaRes\release\jars\2\1f\main.jar] (filtered)
Copying resources from program directory [D:\SourceCode\app\build\intermediates\classes\release] (filtered)
Printing classes to [D:\SourceCode\app\build\outputs\mapping\release\dump.txt]...
:app:transformClassesWithDexForRelease
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 5120 MB.
To do this set org.gradle.jvmargs=-Xmx5120M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Exception parsing classes
Error:1 error; aborting
:app:transformClassesWithDexForRelease FAILED
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_161\bin\java.exe'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 6 mins 42.019 secs

我过去 3 天都在工作。请帮我解决这个问题。提前致谢

最佳答案

First of all add multiDexEnabled to true

defaultConfig {
minSdkVersion 15 // it will work fast
targetSdkVersion 26
multiDexEnabled true
}

并添加依赖项

dependencies {
compile 'com.android.support:multidex:1.0.3'
}

确保创建一个扩展的应用程序类

 <application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>

MultiDexApplication.class

public class MultiDexApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}

注意:确保将您的 gradle 和库升级到最新版本..

转到 gradle.properties 并增加堆大小。我认为您的 RAM 小于 8 GB。

关于android - minifyEnabled true 在调试和 Release模式下不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51669883/

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