Android Proguard SDK8
Proguard configuration
如果您的APP發佈時需要混淆AAB/APK,請參考下方 proguard 設定
8.0.7.1 起 AAR 不再附帶 Proguard 規則,App 的 R8 可以混淆 MADP 與 OM SDK。開啟混淆時,請務必將下列規則加入 App 的 proguard-rules.pro,未加入時 VAST 影音廣告、MRAID 與廣告素材的 JS bridge 功能會失效。
# MADP App-side R8 / ProGuard rules.
# The MADP AAR does not ship consumer rules: integrator apps must add these rules.
# They protect only what MADP looks up by name (Gson models, MRAID reflection and
# the WebView JS bridge); the rest of MADP and OM SDK may be obfuscated by the App.
# Do not add global optimization flags.
# Gson creates these models reflectively and maps JSON keys to field names.
-keep class com.taiwanmobile.pt.adp.view.internal.json.Vast {
<init>(...);
<fields>;
}
-keep class com.taiwanmobile.pt.adp.view.internal.json.AdParameters {
<init>(...);
<fields>;
}
# WebViewClientMraid dispatches commands through getDeclaredMethod(command).
-keepclassmembers class com.taiwanmobile.pt.adp.view.webview.mraid.MraidProcessor {
<methods>;
}
# Ad creatives call these annotated methods through window.android.
-keepclassmembers class com.taiwanmobile.pt.adp.view.webview.JSWebView$JSWebViewExecutor {
@android.webkit.JavascriptInterface <methods>;
}
- 只需保留 MADP 以名稱查找的三類:Gson model(Vast / AdParameters)、MRAID、JS bridge
- 請勿加入
-dontoptimize、-optimizations等全域旗標,以免關閉 App 的程式碼優化