diff --git a/agentweb-core/build.gradle b/agentweb-core/build.gradle index 009ff5d5..cb149619 100644 --- a/agentweb-core/build.gradle +++ b/agentweb-core/build.gradle @@ -13,6 +13,9 @@ android { versionName VERSION_NAME testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + // Issue #1072: ship Proguard/R8 rules so consumer apps do not have to + // re-declare the @JavascriptInterface keep rule themselves. + consumerProguardFiles 'consumer-rules.pro' } diff --git a/agentweb-core/consumer-rules.pro b/agentweb-core/consumer-rules.pro new file mode 100644 index 00000000..f400dd48 --- /dev/null +++ b/agentweb-core/consumer-rules.pro @@ -0,0 +1,14 @@ +# Consumer Proguard/R8 rules for AgentWeb. +# +# Issue #1072: in release builds the JS bridge methods were stripped because +# the host app did not have a keep rule for @JavascriptInterface. AgentWeb +# itself uses reflection-style discovery on these methods, so the rule needs +# to apply to every consumer that ships the library. + +-keepclassmembers class * { + @android.webkit.JavascriptInterface ; +} + +# AgentWeb's own bridge plumbing relies on reflection over its public API. +-keep class com.just.agentweb.** { *; } +-dontwarn com.just.agentweb.**