2016-06-10 26 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工作。 感谢您的帮助 –