Anko: Proguard Warning: org.jetbrains.anko.internals.AnkoInternals: can't find referenced method 'int getThemeResId()' in library class android.view.ContextThemeWrapper

Created on 10 Jun 2016  路  11Comments  路  Source: Kotlin/anko

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

Anko Layouts bug fixed

Most helpful comment

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.

All 11 comments

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!

Was this page helpful?
0 / 5 - 0 ratings