2016-06-10 34 views
0

我剛剛意識到混淆,並希望設置proguard與我的應用程序一起工作。我在日食工作,我把它我project.properties所建議的很多地方,因爲這樣爲Android應用程序設置proguard項目

# This file is automatically generated by Android Tools. 
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! 
# 
# This file must be checked in Version Control Systems. 
# 
# To customize properties used by the Ant build system edit 
# "ant.properties", and override values to adapt the script to your 
# project structure. 
# 
# To enable ProGuard to shrink and obfuscate your code, uncomment this  (available properties: sdk.dir, user.home): 
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard- project.txt 

# Project target. 
target=android-23 
android.library.reference.1=../../Resources/route_planner_app_basic 

和我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: 

-injars  bin/classes 
-injars  libs 
-outjars  bin/classes-processed.jar 
-libraryjars /usr/local/java/android-sdk/platforms/android-9/android.jar 

-dontpreverify 
-repackageclasses '' 
-allowaccessmodification 
-optimizations !code/simplification/arithmetic 
-keepattributes *Annotation* 

-keep public class * extends android.app.Activity 
-keep public class * extends android.app.Application 
-keep public class * extends android.app.Service 
-keep public class * extends android.content.BroadcastReceiver 
-keep public class * extends android.content.ContentProvider 

-keep public class * extends android.view.View { 
    public <init>(android.content.Context); 
    public <init>(android.content.Context, android.util.AttributeSet); 
    public <init>(android.content.Context, android.util.AttributeSet, int); 
    public void set*(...); 
} 

-keepclasseswithmembers class * { 
    public <init>(android.content.Context, android.util.AttributeSet); 
} 

-keepclasseswithmembers class * { 
    public <init>(android.content.Context, android.util.AttributeSet, int); 
} 

-keepclassmembers class * extends android.content.Context { 
    public void *(android.view.View); 
    public void *(android.view.MenuItem); 
} 

-keepclassmembers class * implements android.os.Parcelable { 
    static ** CREATOR; 
} 

-keepclassmembers class **.R$* { 
    public static <fields>; 
} 

-keepclassmembers class * { 
    @android.webkit.JavascriptInterface <methods>; 
} 

# 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 *; 
#} 

當我出口它的工作罰款但是當我第一次運行應用程序時,我發現有一個錯誤,所以我修復了這個錯誤,從那時起,每次我嘗試導出應用程序時,都會收到以下錯誤消息。

[2016-06-10 17:55:33 - route_planner_TT] Proguard returned with error code 1. See console 
[2016-06-10 17:55:33 - route_planner_TT] java.io.IOException: Can't read [C:\Users\Gareth Edwards\git_repos\workspace\route_planner_TT\usr\local\java\android-sdk\platforms\android-9\android.jar] (No such file or directory) 
[2016-06-10 17:55:33 - route_planner_TT] at proguard.InputReader.readInput(InputReader.java:230) 
[2016-06-10 17:55:33 - route_planner_TT] at proguard.InputReader.readInput(InputReader.java:200) 
[2016-06-10 17:55:33 - route_planner_TT] at proguard.InputReader.readInput(InputReader.java:178) 
[2016-06-10 17:55:33 - route_planner_TT] at proguard.InputReader.execute(InputReader.java:100) 
[2016-06-10 17:55:33 - route_planner_TT] at proguard.ProGuard.readInput(ProGuard.java:196) 
[2016-06-10 17:55:33 - route_planner_TT] at proguard.ProGuard.execute(ProGuard.java:78) 
[2016-06-10 17:55:33 - route_planner_TT] at proguard.ProGuard.main(ProGuard.java:492) 
[2016-06-10 17:55:33 - route_planner_TT] Caused by: java.io.IOException: No such file or directory 
[2016-06-10 17:55:33 - route_planner_TT] at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:50) 
[2016-06-10 17:55:33 - route_planner_TT] at proguard.InputReader.readInput(InputReader.java:226) 
[2016-06-10 17:55:33 - route_planner_TT] ... 6 more 

這是五個小時前,我一直拉着我的頭髮,因爲請幫助。

回答

0

在你的ProGuard-project.txt您包括使用下列選項的android.jar:

-libraryjars /usr/local/java/android-sdk/platforms/android-9/android.jar 

,但你似乎在Windows計算機上運行。您需要將其更改爲指向安裝在計算機上的android.jar的正確Windows路徑。

0

好像只是應該使用SDK Manager下載/重新下載Android SDK 9。

+0

你知道它是否必須是SDK9,在SDK經理說它已經過時並且不會下載,我有8和10嗎? –

+0

但你的錯誤信息清楚地表明,proguard找不到Android SDK 9: 'java.io.IOException:Can not read [C:\ Users \ Gareth Edwards \ git_repos \ workspace \ route_planner_TT \ usr \ local \ (沒有這樣的文件或目錄) [2016-06-10 17:55:33 - route_planner_TT]' 你能否驗證'C:\ Users \ Gareth Edwards \ git_repos \ workspace \ route_planner_TT \ usr \ local \ java \ android-sdk \ platforms \ android-9 \ android.jar'存在嗎?如果它存在,那麼問題可能是由路徑中的空間字符引起的,它可能發生在Windows平臺上。 –

+0

是的,錯誤是由於SDK9不存在造成的,我只是想知道如果需要SDK9或者SDK9 +中的任何一個都可以正常工作,那麼可以從更普遍的意義上讓proguard工作。 感謝您的幫助 –