내 앱의 메소드 수가 64k 제한보다 높으므로 Proguard를 사용하여이를 줄입니다.Proguard minifyEnabled 디버그 빌드에서 true이고, Lollipop 이전 버전에서는 작동하지 않습니다.
모든 것이 릴리스 빌드에 잘 작동합니다.
디버그 빌드는 Lollipop + 기기에서만 성공합니다.
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
을 제거 시도했다 :
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
이 내가 응용 프로그램 수준 Gradle을 파일에있는 것입니다 : 사전 롤리팝 장치에 시작할 때 나는 항상 악명 높은 오류가 빌드를 디버그 한 다음 Lollipop +에서도 빌드가 실패합니다. 따라서 proguard가 작동합니다! Lollipop 사전에는 없습니다.
minifyEnabled
은 플랫폼에 종속적이어서는 안되며, 빌드 프로세스는 사전 Lollipop 장치에서 (내가 어떤 이유인지 알지 못해) 건너 뜁니다.
누구든지이 문제에 대한 해결책을 알고 있습니까?
ps. 나는 multidex 가능성을 알고 있지만, 나는 그것을 최후의 수단으로 남겨두고있다.
편집 :
이 응용 프로그램 수준 Gradle을 파일의 전체 코드입니다 :
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'
}
release {
shrinkResources true
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'
프로젝트 수준 Gradle을 파일 :
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 { *; }
를 구축 변형 버전을 선택 디버그에 포함됩니까? LeakCanary처럼? – EpicPandaForce
아니요, 또한 https://github.com/KeepSafe/dexcount-gradle-plugin을 사용하여 디버그 빌드의 메소드 개수를 확인하고 있습니다. 약 30k입니다. (프로 가드로 미니 피팅) –
gradle.build 파일의 전체 코드를 보여주십시오. – Divers