とあるアプリにGoogleAnalyticsを入れてAPK化しようとしたら、こんなエラーが出て続行できませんでした。

Proguard returned with error code 1. See console
Warning: com.google.analytics.tracking.android.FutureApis: can't find referenced method 'boolean setReadable(boolean,boolean)' in class java.io.File
Warning: com.google.analytics.tracking.android.FutureApis: can'
t find referenced method 'boolean setWritable(boolean,boolean)' in class java.io.File
You should check if you need to specify additional program jars.
Warning: there were 2 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile them and try again.
Alternatively, you may have to specify the option
'-dontskipnonpubliclibraryclassmembers'.
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)
Proguard returned with error code 1. See console
Warning: com.google.analytics.tracking.android.FutureApis: can't find referenced method 'boolean setReadable(boolean,boolean)' in class java.io.File
Warning: com.google.analytics.tracking.android.FutureApis: can'
t find referenced method 'boolean setWritable(boolean,boolean)' in class java.io.File
You should check if you need to specify additional program jars.
Warning: there were 2 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile them and try again.
Alternatively, you may have to specify the option
'-dontskipnonpubliclibraryclassmembers'.
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)

調べてみると、すでに導入していたProguardが悪さをしていたようです。

参考 Proguardでcan’t find referenced class

この記事の通りにproguard.cfgに

-dontwarn
-dontnote

を書き込もうと思ったんですが、proguard.cfgがない! 見つからない!

どうやら、ADT17.0にてproguardが色々変更されたらしく、私の環境ではproguard.cfgは存在しないようです。

で、また頑張って調べたら、プロジェクトフォルダの直下にあるproguard-project.txtがそれの代わりとなるようです。

proguard-project.txtに、下記のようなパラメータを追加します。

-dontwarn com.google.**

これで正常に動作して、APK化も上手くいきました!

ほー、良かった良かった。

参考 Android – Proguardの有効化(なんとか解決?)

Post Navigation