2017-02-07 3 views
3

Ich versuche, Proguard in meiner App zu implementieren, aber ich bin nicht in der Lage, es zu tun. Ich habe sowohl minifyEnabled als auch shrinkResources aktiviert. Hier ist meine build.gradle Datei:Fehler bei der Verwendung von 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' 

Und hier sind die Bilder von Fehler, die ich erhalten: enter image description here

enter image description here

Der Fehlercode war zu groß, deshalb habe ich beschlossen Bild posten anstelle von Code. Jede Hilfe ist willkommen, danke im voraus

+0

auf den ersten Scheck http://stackoverflow.com/a/41427114/3395198 –

+1

@IntelliJAmiya Danke, ich werde es versuchen –

+0

Normalerweise müssen Sie Ausnahmen in der Proguard-Datei definieren. Ich denke, Fabric und die anderen Abhängigkeiten sollten in ihren Dokumenten aufgelistet sein, um hinzuzufügen. –

Antwort

1

Zuerst korrigieren Sie Ihre debug und release Abschnitt.

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" 
    } 

} 

Weitere Informationen Read Errors while building APK Android Studio

+0

Immer noch der gleiche Fehler, überprüfen Sie meine erste Zeile Fehler, es ist immer noch gleich –

+0

@BhaveshMisri in Ordnung. Bitte teilen Sie Ihre 'build.gradle' –

+0

Ich habe die Bearbeitung in meiner Frage gemacht, Sie können es jetzt überprüfen. –

0

die Ausnahmen für jede Abhängigkeit der proguard-rules.pro Datei hinzufügen. Einige Abhängigkeiten erfordern jedoch keine Proguard-Regeln.

Zum Beispiel, weil Sie retrofit verwenden, werden Sie diese hinzufügen müssen:

# 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 

auf Ihre proguard Datei

+1

Ich habe es auch in der Manifest-Datei konfiguriert, aber es zeigt denselben Fehler. Ich denke, dass ich Ausnahmen in der Pro-Schutz-Datei für andere Abhängigkeiten definieren muss. –

+0

Ich habe meine build.gradle-Datei bereits in meiner Frage –

+0

hinzugefügt. Haben Sie immer minifyEnable und shrinkresources auf true gesetzt? –

Verwandte Themen