2017-02-07 3 views
3

Я пытаюсь реализовать proguard в своем приложении, но я не могу этого сделать. Я включил как minifyEnabled, так и shrinkResources. Вот мой build.gradle файл:Ошибка при использовании Proguard

buildscript { 
repositories { 
    maven { url 'https://maven.fabric.io/public' } 
} 

dependencies { 
    classpath 'io.fabric.tools:gradle:1.+' 
} 
} 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 
apply plugin: 'android-apt' 

repositories { 
maven { url 'https://maven.fabric.io/public' } 
} 

apply plugin: 'com.neenbedankt.android-apt' 

android { 
signingConfigs { 
    testSigned { 
     keyAlias 'test' 
     keyPassword 'testing123' 
     storePassword 'testing123' 
     //storeFile file('C:/Users/Motobeans/Desktop/testSignedArchitecture.jks') 
    } 
} 
compileSdkVersion rootProject.ext.compileSdkVersion 
buildToolsVersion rootProject.ext.buildToolsVersion 
defaultConfig { 
    applicationId "in.mylo.pregnancy.baby.app" 
    minSdkVersion rootProject.ext.minSdkVersion 
    targetSdkVersion rootProject.ext.targetSdkVersion 
    versionCode rootProject.ext.versionCode 
    versionName rootProject.ext.versionName 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    multiDexEnabled true 
} 
buildTypes { 
    debug { 
     shrinkResources false // This must be first 
     minifyEnabled false // This must be after shrinkResources 
     multiDexEnabled true 
     proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 
    } 
    release { 
     shrinkResources false 
     minifyEnabled false 
     multiDexEnabled true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 

packagingOptions { 
    exclude 'META-INF/DEPENDENCIES.txt' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/NOTICE.txt' 
    exclude 'META-INF/NOTICE' 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/NOTICE.txt' 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/notice.txt' 
    exclude 'META-INF/license.txt' 
    exclude 'META-INF/dependencies.txt' 
    exclude 'META-INF/LGPL2.1' 
} 
compileOptions { 
    sourceCompatibility JavaVersion.VERSION_1_7 
    targetCompatibility JavaVersion.VERSION_1_7 
} 

} 

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    exclude group: 'com.android.support', module: 'support-annotations' 
}) 
testCompile 'junit:junit:4.12' 
// Multidex support 
compile 'com.android.support:multidex:1.0.1' 
// Android Support Libraries 
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion" 
compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion" 
compile "com.android.support:support-v4:$rootProject.supportLibraryVersion" 
compile "com.android.support:design:$rootProject.supportLibraryVersion" 
compile "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion" 
compile "com.android.support:palette-v7:$rootProject.supportLibraryVersion" 
/* 
* Guava is a set of core libraries that includes new collection types (such as multimap and multiset), 
* immutable collections, a graph library, functional types, an in-memory cache, and APIs/utilities for concurrency, 
* I/O, hashing, primitives, reflection, string processing, and much more! 
*/ 
compile "com.google.guava:guava:$rootProject.guavaVersion" 
// BugFender (logging to server) 
compile 'com.bugfender.sdk:android:0.6.2' 
// Timber (Logging library) 
compile 'com.jakewharton.timber:timber:4.3.1' 
// Dagger Dependency 
compile 'com.google.dagger:dagger:2.7' 
apt 'com.google.dagger:dagger-compiler:2.7' 
compile 'javax.annotation:javax.annotation-api:1.2' 
// Retrofit 
compile 'com.squareup.retrofit2:retrofit:2.1.0' 
compile 'com.squareup.retrofit2:converter-gson:2.1.0' 
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' 
//RxAndroid 
compile 'io.reactivex:rxandroid:1.2.1' 
compile 'io.reactivex:rxjava:1.1.6' 
// Logging Interceptor 
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1' 
// Crash Handler : Show custom activity 
compile 'cat.ereza:customactivityoncrash:1.5.0' 
// EasyImage - Image picker from Gallery or Camera 
compile 'com.github.jkwiecien:EasyImage:1.3.1' 
//Marshmallow Permission Library 
compile('com.github.afollestad:assent:0.2.0') { 
    transitive = true 
} 
// jakewharton butterknief library 
compile 'com.jakewharton:butterknife:8.1.0' 
apt 'com.jakewharton:butterknife-compiler:8.1.0' 

// Jakewharton byte library 
compile 'com.jakewharton.byteunits:byteunits:0.9.1' 
// Glide - Image Loading Library 
compile 'com.github.bumptech.glide:glide:3.7.0' 

// Leak canary (A memory leak detection library for Android and Java) 
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5' 
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5' 

// EventBus 
compile 'org.greenrobot:eventbus:3.0.0' 

// Marshmallow Permission Library 
compile('com.github.afollestad:assent:0.2.0') { 
    transitive = true 
} 

// Ripple Layout Activity Transition 
compile 'com.liuguangqiang.ripplelayout:library:0.1.0' 

// Fabric Crashlytics 
compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
    transitive = true; 
} 

// Circular ImageView 
compile 'de.hdodenhof:circleimageview:1.2.1' 

// View pager 
compile 'com.ogaclejapan.smarttablayout:library:[email protected]' 

// Crescento Curve container 
compile 'com.github.developer-shivam:crescento:1.0.1' 

// Shape Image View 
compile 'com.github.siyamed:android-shape-imageview:[email protected]' 
//compile 'com.github.siyamed:android-shape-imageview:[email protected]' 

// Fonts 
compile 'me.anwarshahriar:calligrapher:1.0' 

//Google Sign In 
/* compile 'com.google.android.gms:play-services-auth:9.8.0' 
compile 'com.google.android.gms:play-services:9.8.0'*/ 
/* 
    compile 'com.google.android.gms:play-services-auth:10.0.1' 
*/ 

// Branch.io 
compile 'io.branch.sdk.android:library:2.+' 

// Branch + Segment Integration library 
compile 'com.weiwangcn.betterspinner:library:1.1.0' 

//segment and clevertap 
compile 'com.segment.analytics.android:analytics:4.+' 
compile 'com.clevertap.android:clevertap-segment-android:+' 

//segment and branch 
compile 'io.branch.segment.analytics.android.integrations:branch:+' 

// Loader View 
compile 'com.elyeproj.libraries:loaderviewlibrary:1.2.2' 

// Animation 
compile 'com.eftimoff:androidplayer:[email protected]' 
compile 'com.nineoldandroids:library:2.4.0' 

compile 'com.ogaclejapan.smarttablayout:library:[email protected]' 

//Custom Chrome tab 
compile 'com.android.support:customtabs:25.0.1' 

// Epoxy Adapter 
compile 'com.airbnb.android:epoxy:1.5.0' 

//mixpanel 
compile "com.mixpanel.android:mixpanel-android:4.+" 

// firebase//Add this line 
compile 'com.google.firebase:firebase-core:9.6.1' 
compile 'com.google.firebase:firebase-messaging:9.6.1' 
compile 'com.google.android.gms:play-services:9.6.1' 
compile 'com.thefinestartist:ytpa:1.2.1' 
compile 'com.caverock:androidsvg:1.2.1' 

// Flow layout 
compile 'org.apmem.tools:layouts:[email protected]' 
// Text Drawable 
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' 
compile 'pl.bclogic:pulsator4droid:1.0.3' 

//Tune 
compile 'com.tune:tune-marketing-console-sdk:4.9.0' 

// Pug notification 
compile 'com.github.halysongoncalves:pugnotification:1.8.1' 

compile 'com.facebook.android:facebook-android-sdk:4.+' 
} 
apply plugin: 'com.google.gms.google-services' 

И здесь образы ошибки, которые я получаю: enter image description here

enter image description here

Код ошибки была слишком большой, поэтому я решил разместить изображение вместо кода. Любая помощь приветствуется, спасибо заранее

+0

при первой проверке http://stackoverflow.com/a/41427114/3395198 –

+1

@IntelliJAmiya Спасибо, я попробую –

+0

Обычно вам нужно определить исключения в файле proguard. Я думаю, что ткань и другие зависимости должны содержать ее в своих документах для добавления. –

ответ

1

На первом исправить свой debug и release раздел.

buildTypes 
{ 
    debug { 
    shrinkResources true // This must be first 
    minifyEnabled true // This must be after shrinkResources 
     proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 
    } 
    release { 
    shrinkResources true // This must be first 
    minifyEnabled true // This must be after shrinkResources 
     proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 
    } 

} 

Для получения дополнительной информации, Read Errors while building APK Android Studio

+0

По-прежнему такая же ошибка, проверьте мою первую строку ошибки, она все равно такая же –

+0

@BhaveshMisri okay. Пожалуйста, поделитесь своим 'build.gradle' –

+0

Я сделал редактирование в своем вопросе, вы можете проверить его сейчас. –

0

Добавить исключения для каждой зависимости от proguard-rules.pro файла. Однако некоторые зависимости не требуют правил proguard.

Например, потому что вы используете retrofit, вам необходимо добавить следующее:

# Platform calls Class.forName on types which do not exist on Android to determine platform. 
-dontnote retrofit2.Platform 
# Platform used when running on RoboVM on iOS. Will not be used at runtime. 
-dontnote retrofit2.Platform$IOS$MainThreadExecutor 
# Platform used when running on Java 8 VMs. Will not be used at runtime. 
-dontwarn retrofit2.Platform$Java8 
# Retain generic type information for use by reflection by converters and adapters. 
-keepattributes Signature 
# Retain declared checked exceptions for use by a Proxy instance. 
-keepattributes Exceptions 

в файл Proguard

+1

Я также настроил его в файле манифеста, но он показывает ту же ошибку. Я думаю, что я должен определять исключения в файле pro guard для других зависимостей. –

+0

Я уже добавил файл build.gradle в свой вопрос –

+0

У вас всегда есть minifyEnable и shrinkresources, установленный в true? –

Смежные вопросы