2016-04-05 11 views
7

Ich habe versucht, eine signierte APK zu erstellen. Ich verwende auch Proguard. In meiner Anwendung verwendete ich JodaTime für einige Zwecke. Ich benutzte joda-Zeit-2.7.jar dort. Zuerst konnte ich ein signiertes APK erhalten, ohne proguard zu aktivieren, es gab keine Fehler. Dann habe ich proguard aktiviert und versucht, die APK zu generieren, aber ich habe Fehler erzeugt. Im Folgenden sind die Fehler aufgeführt.Konnte signiertes APK mit aktiviertem proguard nicht generieren, wenn Joda Time verwendet wird

Warning:org.joda.time.LocalDateTime: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.LocalTime: can't find referenced class org.joda.convert.FromString 
Warning:org.joda.time.LocalTime: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.Minutes: can't find referenced class org.joda.convert.FromString 
Warning:org.joda.time.Minutes: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.MonthDay: can't find referenced class org.joda.convert.FromString 
Warning:org.joda.time.MonthDay: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.Months: can't find referenced class org.joda.convert.FromString 
Warning:org.joda.time.Months: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.MutableDateTime: can't find referenced class org.joda.convert.FromString 
Warning:org.joda.time.MutablePeriod: can't find referenced class org.joda.convert.FromString 
Warning:org.joda.time.Period: can't find referenced class org.joda.convert.FromString 
Warning:org.joda.time.Seconds: can't find referenced class org.joda.convert.FromString 
Warning:org.joda.time.Seconds: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.Weeks: can't find referenced class org.joda.convert.FromString 
Warning:org.joda.time.Weeks: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.YearMonth: can't find referenced class org.joda.convert.FromString 
Warning:org.joda.time.YearMonth: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.Years: can't find referenced class org.joda.convert.FromString 
Warning:org.joda.time.Years: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.base.AbstractDateTime: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.base.AbstractDuration: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.base.AbstractInstant: can't find referenced class org.joda.convert.ToString 
Warning:org.joda.time.base.AbstractPeriod: can't find referenced class org.joda.convert.ToString 
Warning:there were 37 unresolved references to classes or interfaces. 
    You may need to add missing library jars or update their versions. 
    If your code works fine without the missing classes, you can suppress 
    the warnings with '-dontwarn' options. 
    (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass) 
Exception while processing task java.io.IOException: Please correct the above warnings first. 
    at proguard.Initializer.execute(Initializer.java:473) 
    at proguard.ProGuard.initialize(ProGuard.java:233) 
    at proguard.ProGuard.execute(ProGuard.java:98) 
    at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074) 
    at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139) 
    at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115) 
    at com.android.builder.tasks.Job.runTask(Job.java:48) 
    at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41) 
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227) 
    at java.lang.Thread.run(Thread.java:745) 

Unten ist mein build.gradle Datei:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.theacetechnologies.voicetype" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile 'com.android.support:design:23.1.1' 
    compile files('libs/joda-time-2.7.jar') 
} 

Jede Idee, warum ich nicht in der Lage bin, die versengt APK zu erzeugen, wenn proguard aktiviert ist? Ich glaube, dass dies etwas mit Joda Time zu tun hat, da ich zuvor signierte APKs ohne JODA-Zeit generiert habe.

+0

Bitte geben Sie Ihre proguard conf. Sie müssen Ausnahmen für die Joda-Klassen machen, sonst werden sie von proguard ebenfalls verschleiert. Was in diesem Fehler endet. –

+0

Und Ihre Abhängigkeiten sind fehl konfiguriert, Zeile 1 enthält Zeile 5;) Weil Dateibaum (...) enthält alle Gläser in libs Ordner. –

Antwort

11

diese Zeilen zu Ihrer proguard Datei hinzufügen

-dontwarn org.joda.convert.** 
-dontwarn org.joda.time.** 
-keep class org.joda.time.** { *; } 
-keep interface org.joda.time.** { *;} 
+0

Vielen Dank, mein Lieber. – Barrier

Verwandte Themen