Mengatasi error transformClassesAndResourcesWithProguardForRelease


Setelah lama tak ditengok, seminggu terakhir berkas proyek punya kantor kembali dibuka. Belum banyak yang berubah, lalu saya coba lakukan build APK rilis.. Hasilnya? Gagal. Total. Muncul error seperti ini:

Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details
~Build gagal~

Ini kenapa?

Kalau tak salah, terakhir build rilis apk sekitar Juni lalu masih aman-aman saja. Saya masih bisa build dengan baik dan bisa unggah APK ke playstore. Tapi kenapa sekarang tiba-tiba tidak bisa? Padahal saya cuma tambah librari RXJava supaya kekinian. Masa cuma nambah librari itu saja jadi error? Errornya seperti ini:

Warning: com.google.common.util.concurrent.FuturesGetChecked$GetCheckedTypeValidatorHolder$ClassValueValidator$1: can't find superclass or interface java.lang.ClassValue
Warning: com.google.common.base.AbstractIterator: can't find referenced class com.google.errorprone.annotations.CanIgnoreReturnValue
Warning: com.google.common.base.Converter: can't find referenced class com.google.errorprone.annotations.concurrent.LazyInit
Warning: com.google.common.base.Converter: can't find referenced class com.google.errorprone.annotations.CanIgnoreReturnValue
Warning: com.google.common.base.Converter: can't find referenced class com.google.errorprone.annotations.CanIgnoreReturnValue
Warning: com.google.common.base.Converter: can't find referenced class com.google.errorprone.annotations.CanIgnoreReturnValue
Warning: com.google.common.base.Converter: can't find referenced class com.google.errorprone.annotations.CanIgnoreReturnValue
Warning: com.google.common.base.Function: can't find referenced class com.google.errorprone.annotations.CanIgnoreReturnValue
...
...
Note: com.google.android.gms.internal.zzcem: can't find dynamically referenced class android.os.SystemProperties
Note: com.google.android.gms.internal.zzchl: can't find dynamically referenced class com.google.android.gms.tagmanager.TagManagerService
Note: com.google.common.util.concurrent.MoreExecutors: can't find dynamically referenced class com.google.appengine.api.ThreadManager
Note: com.google.common.util.concurrent.MoreExecutors: can't find dynamically referenced class com.google.apphosting.api.ApiProxy
...
...
Note: there were 2 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 101 unkept descriptor classes in kept class members.
You should consider explicitly keeping the mentioned classes
(using '-keep').
(http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 13 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Note: there were 27 accesses to class members by means of introspection.
You should consider explicitly keeping the mentioned class members
(using '-keep' or '-keepclassmembers').
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)

Warning: there were 733 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 15 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)

Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Anehnya, error ini cuma terjadi jika saya melakukan build rilis. Kalau build debug biasa masih bisa. Berarti masalahnya ada di konfigurasi rilis. Tapi apa? Saya coba nonaktifkan settingan minifyEnabled  menjadi false , lalu build ulang. Hasilnya? Berhasil. Wah… Jadi masalahnya ada di sini. Dari hasil googling dan ubek-ubek stackoverflow, tersangka utama ada di berkas proguard. Saya coba matikan proguard, dan benar, build berhasil.

Salahnya di mana? Karena perasaan saya tak lagi ulik lagi berkas proguard-rules.pro . Ubek-ubek SO lagi, katanya itu warning harus di-ignore. Tapi caranya bagaimana ya?

Dari hasil coba-coba, ternyata solusinya simpel. Cukup tambahkan dua baris berikut di berkas proguard-rules.pro :

-dontwarn com.google.**
-dontnote com.google.**

Coba build lagi, dan… kali ini berhasil. Fyuh… Ternyata cuma begitu doang 😐


Ada komentar?

This site uses Akismet to reduce spam. Learn how your comment data is processed.