2017-01-17 8 views
3

내 코드에 proguard를 적용한 후에도 여전히 읽기 쉽습니다. 클래스와 패키지는 이름이 바뀌지 않습니다. 클래스 변수, 즉 모두 이름이 바뀌 었습니다. Android Studio 2.2.3. 빌드 : Gradle을 내 릴리스 APK보기Android Studio의 ProGuard는 매우 약한 난독 화 기능을 제공합니다.

# Add project specific ProGuard rules here. 
# By default, the flags in this file are appended to flags specified 
# in C:.....proguard/proguard-android.txt 
# You can edit the include path and order by changing the proguardFiles 
# directive in build.gradle. 
# 
# For more details, see 
# http://developer.android.com/guide/developing/tools/proguard.html 

# Add any project specific keep options here: 

# If your project uses WebView with JS, uncomment the following 
# and specify the fully qualified class name to the JavaScript interface 
# class: 
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { 
# public *; 
#} 
-dontwarn com.github.mikephil.charting.** 
-keep class android.support.v7.** { *; } 
-keep class android.support.graphics.drawable.** { *; } 

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 24 
buildToolsVersion "25.0.1" 

defaultConfig { 
    applicationId "com.mypackagename" 
    minSdkVersion 19 
    targetSdkVersion 24 
    versionCode 3 
    versionName "1.0" 
    vectorDrawables.useSupportLibrary = true 
} 

buildTypes { 
    release { 
     minifyEnabled true 
     shrinkResources true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 

dexOptions { 
    dexInProcess = true 
} 

    lintOptions { 
    abortOnError true 
    checkReleaseBuilds true 
} 
} 

ext { 
supportLibVersion = '25.0.1' 
playServisesVersion = '10.0.0' 
} 

repositories { 
maven { url "https://jitpack.io" } 
} 

dependencies { 
compile fileTree(dir: 'libs', include: ['*.jar']) 
compile 'com.github.PhilJay:MPAndroidChart:v2.2.5' 
compile 'org.greenrobot:eventbus:3.0.0' 
compile 'com.wdullaer:materialdatetimepicker:3.0.0' 
compile 'com.aurelhubert:ahbottomnavigation:2.0.1' 
compile "com.android.support:appcompat-v7:${supportLibVersion}" 
compile "com.android.support:cardview-v7:${supportLibVersion}" 
compile "com.android.support:design:${supportLibVersion}" 
compile "com.google.android.gms:play-services-analytics:${playServisesVersion}" 
compile "com.google.android.gms:play-services-drive:${playServisesVersion}" 
compile "com.google.firebase:firebase-ads:${playServisesVersion}" 
compile "com.google.firebase:firebase-core:${playServisesVersion}" 
compile 'com.anjlab.android.iab.v3:library:1.0.34' 
compile 'com.github.paolorotolo:appintro:4.1.0' 
compile 'net.danlew:android.joda:2.9.5.1' 
} 
apply plugin: 'com.google.gms.google-services' 

proguard-rules.pro 2.2.3

build.gradle enter image description here

+0

@Aenadon 예. 나는 proguard-android-optimize.txt를 시도했다. 내 apk는 30kb 작게 보이지만 눈에 띄는 차이는 없습니다. – despecher

답변

2

AppIntro 라이브러리를 사용하고 있습니다. 이 라이브러리에는 라이브러리의 프로 가드 규칙이 프로젝트의 모든 클래스를 보존하는 문제가 있습니다. 라이브러리의 프로 가드 규칙은 로컬 라이브러리의 규칙과 병합되므로 최종 빌드에서는 모든 클래스가 보존되고 난독 화되지 않습니다.

이 문제는 4.2에서 수정되었지만이 버전은 Maven Central에서 릴리스되지 않았습니다. 한편 라이브러리를 로컬에서 복제하고 수동으로 그 라이브러리에서 가져와야합니다.

단계 : 로컬 Github에서를 통해

  1. 다운로드 또는 라이브러리를 복제
  2. 새로운 만들기 프로젝트의 루트에 새 폴더 libs 만들기 (녹색 Clone or Download 버튼이있다) 폴더 AppIntrolibs 폴더
  3. 복제 된 프로젝트의 library- 폴더의 내용을에 배치하십시오폴더는 우리가 일반적으로 작동합니다 당신의 build.gradle

지금 난독 화에 compile project(':libs:AppIntro')로 교체하여 settings.gradle

  • compile 'com.github.paolorotolo:appintro:4.1.0'include ':libs:AppIntro' 추가 3 단계
  • 에서 만든!

  • +0

    답변 해 주셔서 감사합니다. 예. 실제로 AppIntro 라이브러리를 제거한 후 proguard가 제대로 작동하기 시작했습니다. – despecher

    +0

    동일한 문제가 생겼습니다. 프로젝트에이 AppIntro 라이브러리가 없습니다. ProGuard에서 모든 수업을 제외시키는 나쁜 사과를 올바르게 진단하고 찾아내는 방법은 무엇입니까? – Segabond