When building with Anko 0.9 and with ProGuard, I get the following warning which fails the build:
Warning: org.jetbrains.anko.internals.AnkoInternals: can't find referenced method 'int getThemeResId()' in library class android.view.ContextThemeWrapper
When you ignore the warning, you get a different one:
java.lang.IllegalArgumentException: Stacks have different current sizes [0] and [1]
Unexpected error while performing partial evaluation:
Class = [org/jetbrains/anko/AsyncKt$doAsync$1]
Method = [invoke()Ljava/lang/Object;]
Exception = java.lang.IllegalArgumentException
This call only works with android.support.v7.view.ContextThemeWrapper because in system framework base ContextThemeWrapper is hide this call and the existence of getThemeResId not guaranteed.
You need to use the proguard-android-optimize.txt configuration for ProGuard for https://github.com/Kotlin/anko/issues/206#issuecomment-225512019 to appear.
Any workaround while waiting 0.9.1?
Yes, clone, build, import into your project. ;)
@fboldog do we have any fix other than building and compiling the project on this issue?
Am I understanding correctly that it is currently not possible to use Anko and have proguard enabled because of this issue?
@BoD: You can of course use an older version, like 0.8.3:
compile 'org.jetbrains.anko:anko-common:0.8.3'
ok :'(
Just to clarify, for future people having the same problem: the workaround is to add
-dontwarn org.jetbrains.anko.internals.AnkoInternals to your proguard config file
and to use proguard-android.txt (not proguard-android-optimize.txt) in your gradle build file.
Thanks! Version 0.9.1 which is released fixes this issue!
Most helpful comment
Just to clarify, for future people having the same problem: the workaround is to add
-dontwarn org.jetbrains.anko.internals.AnkoInternalsto your proguard config fileand to use
proguard-android.txt(notproguard-android-optimize.txt) in your gradle build file.