Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions agentweb-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Comment on lines 14 to +18
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testInstrumentationRunner is assigned twice; the second line overrides the first, which is confusing and makes the support runner line effectively dead. Consider removing the unused assignment to keep defaultConfig unambiguous.

Copilot uses AI. Check for mistakes.

}

Expand Down
14 changes: 14 additions & 0 deletions agentweb-core/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -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 <methods>;
}
Comment on lines +8 to +10
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-keepclassmembers will keep the annotated methods, but if a consumer’s shrink config strips runtime annotation attributes, @JavascriptInterface can be removed and AgentWeb’s checkObject() / WebView reflection will still fail at runtime. Consider also keeping runtime-visible annotation attributes (e.g., RuntimeVisibleAnnotations) so the @JavascriptInterface metadata survives R8/Proguard in consumer apps.

Copilot uses AI. Check for mistakes.

# AgentWeb's own bridge plumbing relies on reflection over its public API.
-keep class com.just.agentweb.** { *; }
-dontwarn com.just.agentweb.**
Loading