0

proguard を使用してコードを難読化しようとしています。プロジェクトで Google マップを使用しています。

しかし、次の例外が発生しています。

解決方法は?

        Proguard returned with error code 1. See console
    Warning: class [bin/classes/com/google/android/gms/BuildConfig.class] unexpectedly contains class [com.google.android.gms.BuildConfig]
    Warning: class [bin/classes/com/google/android/gms/R$attr.class] unexpectedly contains class [com.google.android.gms.R$attr]
    Warning: class [bin/classes/com/google/android/gms/R$id.class] unexpectedly contains class [com.google.android.gms.R$id]
    Warning: class [bin/classes/com/google/android/gms/R$string.class] unexpectedly contains class [com.google.android.gms.R$string]
    Warning: class [bin/classes/com/google/android/gms/R$styleable.class] unexpectedly contains class [com.google.android.gms.R$styleable]
    Warning: class [bin/classes/com/google/android/gms/R.class] unexpectedly contains class [com.google.android.gms.R]
    Note: there were 1656 duplicate class definitions.
    Warning: there were 6 classes in incorrectly named files.
             You should make sure all file names correspond to their class names.
             The directory hierarchies must correspond to the package hierarchies.
             If you don't mind the mentioned classes not being written out,
             you could try your luck using the '-ignorewarnings' option.
    java.io.IOException: Please correct the above warnings first.
        at proguard.InputReader.execute(InputReader.java:133)
        at proguard.ProGuard.readInput(ProGuard.java:196)
        at proguard.ProGuard.execute(ProGuard.java:78)
        at proguard.ProGuard.main(ProGuard.java:492)
    Proguard returned with error code 1. See console
    proguard.ParseException: Unexpected keyword 'names' in line 30 of file 'D:\redBus_Update_3\proguard-project.txt',
      included from argument number 4
        at proguard.ConfigurationParser.unknownAccessFlag(ConfigurationParser.java:1048)
        at proguard.ConfigurationParser.parseClassSpecificationArguments(ConfigurationParser.java:547)
        at proguard.ConfigurationParser.parseKeepClassSpecificationArguments(ConfigurationParser.java:490)
        at proguard.ConfigurationParser.parse(ConfigurationParser.java:138)
        at proguard.ProGuard.main(ProGuard.java:484)

以下のプロガードファイルの内容を見つけてください。

これらのファイルにも警告を無視するオプションを使用してみました

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

-libraryjars D:\google-play-services_lib_en
-libraryjars D:\redBus_Update_3\libs\FlurryAgent.jar
-libraryjars D:\redBus_Update_3\libs\gson-2.2.2.jar
-libraryjars D:\redBus_Update_3\libs\bugsense-3.0.1.jar
-libraryjars D:\redBus_Update_3\libs\android-support-v4.jar

-keep class android.location.** { *; }

-keep public class com.google.android.maps.** {*;}
-keep public class com.google.android.maps.** {*;}
-keep public class com.google.android.gms.maps.** {*;}

-dontwarn com.google.android.maps.GeoPoint
-dontwarn com.google.android.maps.MapActivity
-dontwarn com.google.android.maps.MapView
-dontwarn com.google.android.maps.MapController 
-dontwarn com.google.android.maps.Overlay
4

2 に答える 2

5

proguard-project.txt で -libraryjars オプションを指定しないでください。標準のビルド スクリプトは、libsディレクトリ内で検出できるライブラリを ProGuard に自動的に渡します。

アプリケーションがデバッグ モードで正常に動作していても、欠落しているクラスに関する警告が表示される場合は、これらのクラスに -dontwarn オプションを追加することを検討する必要があります (このサイトの多くの関連する質問と回答を参照)。

于 2013-03-14T12:25:36.760 に答える