2016-05-16 49 views
0

我正在學習如何在MobileFirst 7.1中實現Proguard for Java模糊處理。我創建了Android環境的新MobileFirst項目,並遵循IBM文檔中描述的過程:在新的IBM MobileFirst 7.1項目中使用Proguard的錯誤

http://www.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.deploy.doc/admin/t_pg_creating_obfus_apk.html?lang=en

然而,試圖出口簽署的APK我收到以下錯誤時:

[ 2016-05-16 15:24:38 - myTestMyTestAppAndroid] Proguard返回錯誤代碼1.請參閱控制檯

[2016-05-16 15:24:38 - myTestMyTestAppAndroid]注意:有2640個重複的類定義。

[2016-05-16 15:24:38 - myTestMyTestAppAndroid]你應該檢查你是否需要指定額外的程序罐。

[2016年5月16日15時24分38秒 - myTestMyTestAppAndroid] java.lang.ClassCastException:java.lang.Object中不能轉換爲java.lang.String

[2016年5月16日15: 24:38 - myTestMyTestAppAndroid]在proguard.obfuscate.MemberObfuscator.newMemberName(MemberObfuscator.java:198)

[2016年5月16日15時24分38秒 - myTestMyTestAppAndroid]在proguard.obfuscate.MemberNameCollector.visitAnyMember(MemberNameCollector。 java:74)

[2016-05-16 15:24:38 - myTestMyTestAppAndroid] at proguard.classfile.util.SimplifiedVisitor.visitProgramMember(Simplifie dVisitor.java:79)

[2016年5月16日15時24分38秒 - myTestMyTestAppAndroid]在proguard.classfile.util.SimplifiedVisitor.visitProgramMethod(SimplifiedVisitor.java:91)

[2016-05- 16 15點24分38秒 - myTestMyTestAppAndroid]在proguard.classfile.visitor.MemberAccessFilter.visitProgramMethod(MemberAccessFilter.java:90)

[2016年5月16日15時24分38秒 - 在proguard.classfile.ProgramMethod myTestMyTestAppAndroid] .accept(ProgramMethod.java:71)

[2016-05-16 15:24:38 - myTestMyTestAppAndroid] at proguard.classfile.ProgramClass.methodsAccept( ProgramClass.java:504)

[2016年5月16日15時24分38秒 - myTestMyTestAppAndroid]在proguard.classfile.visitor.AllMemberVisitor.visitProgramClass(AllMemberVisitor.java:48)

[2016-05- 16 15點24分38秒 - myTestMyTestAppAndroid]在proguard.classfile.ProgramClass.accept(ProgramClass.java:346)

[2016年5月16日15時24分38秒 - 在proguard.classfile.ProgramClass.hierarchyAccept myTestMyTestAppAndroid] (ProgramClass.java:359)

[2016-05-16 15:24:38 - myTestMyTestAppAndroid] at proguard.classfile.LibraryClass.hierarchyAccept(LibraryClass.jav一:371)

[2016年5月16日15時24分38秒 - myTestMyTestAppAndroid]在proguard.classfile.ProgramClass.hierarchyAccept(ProgramClass.java:416)

[2016年5月16日15時24分:38 - myTestMyTestAppAndroid] at proguard.classfile.visitor.ClassHierarchyTraveler.visitProgramClass(ClassHierarchyTraveler。的java:75)

[2016年5月16日15點24分38秒 - myTestMyTestAppAndroid]在proguard.classfile.visitor.MultiClassVisitor.visitProgramClass(MultiClassVisitor.java:85)

[2016年5月16日15 :24:38 - 在myTestMyTestAppAndroid] proguard.classfile.ProgramClass.accept(ProgramClass.java:346)

[2016年5月16日十五時24分38秒 - 在proguard.classfile.ClassPool.classesAccept myTestMyTestAppAndroid](ClassPool .java:116)

[2016-05-16 15:24:38 - myTestMyTestAppAndroid] at proguard.obfuscate.Obfuscator.execute(Obfuscator.java:217)

[2016年5月16日15點24分38秒 - myTestMyTestAppAndroid]在proguard.ProGuard.obfuscate(ProGuard.java:333)

[2016年5月16日15點24分38秒 - myTestMyTestAppAndroid]在proguard.ProGuard.execute(ProGuard.java:135)

[2016年5月16日15點24分38秒 - myTestMyTestAppAndroid]在proguard.ProGuard.main(ProGuard.java:492)

我我很困惑,因爲這應該是一個乾淨的項目,我沒有對基本文件進行任何更改,無論是在應用程序資產還是proguard配置文件中。

那麼,爲什麼試圖導出APK時出現這些錯誤?

proguard的-project.txt:

# To enable ProGuard in your project, edit project.properties 
# to define the proguard.config property as described in that file. 
# 
# Add project specific ProGuard rules here. 
# By default, the flags in this file are appended to flags specified 
# in ${sdk.dir}/tools/proguard/proguard-android.txt 
# You can edit the include path and order by changing the ProGuard 
# include property in project.properties. 
# 
# 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 *; 
#} 

-injars  bin/classes 
-injars  libs 
-outjars  bin/classes-processed.jar 

# Using Google's License Verification Library 
-keep class com.android.vending.licensing.ILicensingService 

# Specifies to write out some more information during processing. 
# If the program terminates with an exception, this option will print  out the entire stack trace, instead of just the exception message. 
-verbose 

# Annotations are represented by attributes that have no direct effect on the execution of the code. 
-keepattributes *Annotation* 

-keepclassmembers enum * { 
public static **[] values(); 
public static ** valueOf(java.lang.String); 
} 

-keepattributes InnerClasses 
-keep class **.R 
-keep class **.R$* { 
    <fields>; 
} 

# These options let obfuscated applications or libraries produce stack traces that can still be deciphered later on 
-renamesourcefileattribute SourceFile  
-keepattributes SourceFile,LineNumberTable 

# Enable proguard with Cordova 
-keep class org.apache.cordova.** { *; } 
-keep public class * extends org.apache.cordova.CordovaPlugin 

-keep class com.worklight.androidgap.push.** { *; } 
-keep class com.worklight.wlclient.push.** { *; } 
-keep class com.worklight.common.security.AppAuthenticityToken { *; } 

# Enable proguard with Google libs 
-keep class com.google.** { *;} 
-dontwarn com.google.common.** 
-dontwarn com.google.ads.** 

# apache.http 
-keep class org.apache.http.** { *; } 
-dontwarn org.apache.http.** 
-optimizations  !class/merging/vertical*,!class/merging/horizontal*,!code/simplification/arithmetic,!field/*,!code/allocation/variable 

-keep class net.sqlcipher.** { *; } 
-dontwarn net.sqlcipher.** 

-keep class org.codehaus.** { *; } 
-keepattributes *Annotation*,EnclosingMethod 

-keepclassmembers enum * { 
    public static **[] values(); 
    public static ** valueOf(java.lang.String); 
} 

# These classes contain references to external jars which are not  included in the default MobileFirst project. 
-dontwarn com.worklight.common.internal.WLTrusteerInternal* 
-dontwarn com.worklight.jsonstore.** 
-dontwarn org.codehaus.jackson.map.ext.* 
-dontwarn com.worklight.androidgap.push.GCMIntentService 
-dontwarn com.worklight.androidgap.plugin.WLInitializationPlugin 
-dontwarn com.worklight.wlclient.push.GCMIntentService 
-dontwarn org.bouncycastle.** 
-dontwarn com.worklight.androidgap.jsonstore.security.SecurityManager 

-dontwarn com.worklight.wlclient.push.WLBroadcastReceiver 
-dontwarn com.worklight.wlclient.push.common.* 
-dontwarn com.worklight.wlclient.api.WLPush 
-dontwarn com.worklight.wlclient.api.SecurityUtils 

-dontwarn android.support.v4.** 
-dontwarn android.net.SSLCertificateSocketFactory 
-dontwarn android.net.http.* 

回答

0

您需要添加在你proguard-project.txt.

這個崗位#1某些配置可幫助您開始增加對Proguard的一些配置。看起來,他們遇到了類似的問題: Android compile ClassCastException with Proguard

這裏是有用的ProGuard配置列表: http://proguard.sourceforge.net/manual/examples.html#midlet

+0

感謝您的回答,但是我不明白爲什麼我必須修改用作MobileFirst應用程序模板的配置。該視頻和教程不包含任何「將自定義配置添加到文件」部分,因此它應該適用於像這樣的新項目而沒有任何更改。 – user2363813

+0

嗨@ user2363813,我能夠重現您的問題。我同意,使用新的MobileFirst默認項目時,默認的proguard配置應該可以不做任何更改。如果您是IBM客戶,請提交PMR,以便我們進一步研究此問題。 – DoraC

0

這可能是因爲在Android的SDK版本的ProGuard的。我有同樣的問題,並通過更新我的Android sdk工具中的proguard來解決它。

我從https://sourceforge.net/projects/proguard/files/proguard/下載了最新版本的proguard。替換binlib我的proguard與下載的文件夾。 Proguard文件夾可以位於/ android-sdks/tools/proguard中。

希望這會有所幫助。

相關問題