
一切都适用于发布版本.@H_419_3@另一方面,调试版本只能用于棒棒糖设备.当在Lollipop设备上启动时,我总是有臭名昭着的错误:
com.android.dex.DexIndexOverflowException:方法ID不在[0,0xffff]中:65536
这是我在应用程序级别毕业文件中所拥有的:
buildTypes { deBUG { MinifyEnabled true proguardfiles getDefaultProguardfile('proguard-androID.txt'),'proguard-rules.pro' } release { shrinkResources true MinifyEnabled true proguardfiles getDefaultProguardfile('proguard-androID.txt'),'proguard-rules.pro' } } 我试图在调试版本中删除MinifyEnabled true,然后构建失败也在Lollipop上,因此proguard正在运行!但不是在棒棒糖前.
对于我所知道的,MinifyEnabled不应该是平台依赖的,所以也许构建过程在前Lollipop设备上跳过它(因为我不知道是什么原因).
有人知道这个问题的解决方案吗?
PS.我知道多方面的可能性,但我将其作为我的最后手段.
编辑:
这是应用级别毕业文件的完整代码:
apply plugin: 'com.androID.application'apply plugin: 'androID-apt'apply plugin: 'me.tatarka.retrolambda'buildscript { repositorIEs { mavenCentral() } dependencIEs { classpath 'me.tatarka:gradle-retrolambda:3.2.5' classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.5' }}androID { compileSdkVersion 24 buildToolsversion "23.0.3" defaultConfig { applicationID "com.pIErfrancescosoffritti.shuffly" minSdkVersion 16 targetSdkVersion 24 versionCode 30 versionname "0.13" } buildTypes { deBUG { MinifyEnabled true proguardfiles getDefaultProguardfile('proguard-androID.txt'),'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }}def dbflow_version = "3.1.1"dependencIEs { compile filetree(include: ['*.jar'],dir: 'libs') testCompile 'junit:junit:4.12' apt 'com.jakewharton:butterknife-compiler:8.2.1' apt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}" compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}" compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}" compile 'com.androID.support:support-v4:24.1.1' compile 'com.androID.support:design:24.1.1' compile 'com.androID.support:recyclervIEw-v7:24.1.1' compile 'com.androID.support:cardvIEw-v7:24.1.1' compile 'com.androID.support:palette-v7:24.1.1' compile 'com.jakewharton:butterknife:8.2.1' compile 'com.github.PIErfrancescoSoffritti:AndroIDUtils:0.5' compile 'com.github.PIErfrancescoSoffritti:SlIDingDrawer:0.10' compile 'com.github.PIErfrancescoSoffritti:WebBasedOAuth:0.7' compile 'com.github.PIErfrancescoSoffritti:ShrinkingImageLayout:0.4' compile 'com.github.PIErfrancescoSoffritti:ExpandableLayout:0.1' compile 'com.Google.APIs:Google-API-services-youtube:v3-rev177-1.22.0' compile 'com.Google.API-clIEnt:Google-API-clIEnt-androID:1.20.0' compile 'io.reactivex:rxandroID:1.2.1' compile 'io.reactivex:rxjava:1.1.8' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.github.Commit451:ElasticDragdismissLayout:1.0.4' compile 'com.Google.firebase:firebase-core:9.2.1' compile 'com.Google.firebase:firebase-crash:9.2.1' compile 'com.Google.firebase:firebase-ads:9.2.1' compile 'com.artemzin.rxjava:proguard-rules:1.1.8.0'}apply plugin: 'com.Google.gms.Google-services'apply plugin: 'com.getkeepsafe.dexcount' 项目级毕业文件:
buildscript { repositorIEs { jcenter() } dependencIEs { classpath 'com.androID.tools.build:gradle:2.1.2' classpath 'com.neenbedankt.gradle.plugins:androID-apt:1.8' classpath 'com.Google.gms:Google-services:3.0.0' classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.5' }}allprojects { repositorIEs { jcenter() maven { url "https://jitpack.io" } }}task clean(type: Delete) { delete rootProject.buildDir} 保镖规则:
# retrolambda-dontwarn java.lang.invoke.*# picasso-dontwarn com.squareup.okhttp.**# adMob-keep public class com.Google.androID.gms.ads.** { public *;}-keep public class com.Google.ads.** { public *;}# Googleapiclient# Needed to keep generic types and @Key annotations accessed via reflection-keepattributes Signature,RuntimeVisibleAnnotations,AnnotationDefault-keepclassmembers class * { @com.Google.API.clIEnt.util.Key <fIElds>;}# Needed by Google-http-clIEnt-androID when linking against an older platform version-dontwarn com.Google.API.clIEnt.extensions.androID.**# Needed by Google-API-clIEnt-androID when linking against an older platform version-dontwarn com.Google.API.clIEnt.GoogleAPIs.extensions.androID.**# Needed by Google-play-services when linking against an older platform version-dontwarn com.Google.androID.gms.**# com.Google.clIEnt.util.IoUtils references java.nio.file.files when on Java 7+-dontnote java.nio.file.files,java.nio.file.Path# Suppress notes on licensingServices-dontnote **.IlicensingService# Suppress warnings on sun.misc.Unsafe-dontnote sun.misc.Unsafe-dontwarn sun.misc.Unsafe# DBFlow-keep class * extends com.raizlabs.androID.dbflow.config.DatabaseHolder { *; }解决方法 如果你想尝试减少方法计数,或至少你想了解从发布到调试的区别,我建议你尝试看看在AS 2.2预览5中提供的dex计数,他们有一个YouTube视频(也许从谷歌IO),这使得它很容易计算你的方法. 这只是用于计数方法,如果仍然使用相同的buildToolsversion“23.0.3”,您应该在两个版本的AS中都能获得完全相同的apk文件(除了AS 2.2附带其自己的JDK版本,不应该在你的方式).
免责声明:我从来没有使用过这种工具,所以在实际找到凶手之后,我不知道该推荐什么.
编辑:这里是“Apk Analyzer”的视频https://youtu.be/csaXml4xtN8?t=331,它位于“Build”菜单中.不要尝试早于2.2预览3或更高版本的评论,他们预览了一些直到后来才发布的内容.
编辑2:也是为什么只在使用shrinkResources的时候发布?这就是为了消除不必要的方法:“minifyEnabled” vs “shrinkResources” – what’s the difference? and how to get the saved space?
总结以上是内存溢出为你收集整理的android – Proguard minifyEnabled为true,用于调试版本,而不是在前Lollipop上工作全部内容,希望文章能够帮你解决android – Proguard minifyEnabled为true,用于调试版本,而不是在前Lollipop上工作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)