その1の続き。
AdMobを導入しようとしてmakeすると、次のようなエラー(正しくはWarning)になる。
:app:proguardRelease Warning: com.google.android.gms.ads.internal.zzbo: can't find referenced class android.webkit.WebResourceError Warning: com.google.android.gms.ads.internal.zzbo: can't find referenced class android.webkit.WebResourceError Warning: com.google.android.gms.internal.zzakm: can't find referenced method 'int getMaxSupportedInstances()' in library class android.media.MediaCodecInfo$CodecCapabilities Warning: com.google.android.gms.internal.zzbif: can't find referenced method 'boolean isInstantApp()' in library class android.content.pm.PackageManager Warning: com.google.android.gms.internal.zzbig: can't find referenced method 'boolean isInstantApp(java.lang.String)' in library class android.content.pm.PackageManager Warning: there were 2 unresolved references to classes or interfaces. You may need to add missing library jars or update their versions. If your code works fine without the missing classes, you can suppress the warnings with '-dontwarn' options. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass) Warning: there were 3 unresolved references to library class members. You probably need to update the library versions. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember) :app:proguardRelease FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:proguardRelease'. > java.io.IOException: Please correct the above warnings first. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED
ググったところ、app/proguard-rules.proに次の行を加えれば良いようだ。(NUmeroのソース置き場)
-keep class com.google.android.gms.ads.** {*;} -dontwarn com.google.android.gms.**
変更後にmakeすると次のような表示が出るようになるが、害はない。
:app:shrinkReleaseResources Removed unused resources: Binary resource data reduced from 103KB to 80KB: Removed 22% Note: If necessary, you can disable resource shrinking by adding android { buildTypes { release { shrinkResources false } } }
これで解決ではあるのだが、試してみたところ、
-keep class com.google.android.gms.ads.** {*;}
は指定せずに、
-dontwarn com.google.android.gms.**
だけでも問題はなさそう。
しかし、まあ、先人に倣っておくことにした。
【参考URL】
NUmeroのソース置き場
琴線探査:こちらのサイトによるとやっぱり-dontwarnのみで良いらしい。ただしAdMobのバージョンは異なる。(com.google.adsというのはかなり古いバージョン)