Skip to content

android: keep the prefixed jni_zero classes in consumer rules - #107

Merged
davidliu merged 1 commit into
livekit:masterfrom
NateIsern:fix/keep-prefixed-jni-zero
Sep 25, 2026
Merged

davidliu merged 1 commit into
livekit:masterfrom
NateIsern:fix/keep-prefixed-jni-zero

Conversation

@NateIsern

Copy link
Copy Markdown

Problem

#102 moved Android to the prefixed io.github.webrtc-sdk:android-prefixed artifact and updated the WebRTC keep rule to livekit.org.webrtc.**, but the jni_zero rule still keeps org.jni_zero.**. The prefixed artifact relocates jni_zero too: its libs/shadow-all.jar (144.7559.15) contains only livekit/org/jni_zero/*, with no unprefixed org/jni_zero classes.

In an app with R8 enabled (minifyEnabled true), livekit.org.jni_zero.JniInit is therefore stripped, and the native library aborts while loading. Reproduced on a Pixel 8a running Android 16, with a release build using @livekit/react-native-webrtc 144.2.0 (via @livekit/react-native 3.0.0), Expo SDK 57 and RN 0.86:

W System.err: java.lang.ClassNotFoundException: livekit.org.jni_zero.JniInit
F libc    : Fatal signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) ...
F DEBUG   :   #04 pc ... base.apk!libjingle_peerconnection_so.so (JNI_OnLoad+64)

144.1.2 wasn't affected, because it used the unprefixed artifact that org.jni_zero.** matches.

Fix

Keep livekit.org.jni_zero.**, mirroring the org.webrtc → livekit.org.webrtc change in #102. With the equivalent rule in the app's own ProGuard config, the same release build starts normally.

The prefixed artifact (livekit#102) relocates jni_zero to livekit.org.jni_zero,
but the consumer rule still keeps org.jni_zero. With R8 enabled the
relocated JniInit is stripped and JNI_OnLoad aborts at startup.

@davidliu davidliu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, thanks for the PR!

@davidliu
davidliu merged commit 932575f into livekit:master Sep 25, 2026
5 checks passed
NateIsern added a commit to OxyHQ/Allo that referenced this pull request Sep 26, 2026
#181)

@livekit/react-native-webrtc 144.2.0 ships the PREFIXED WebRTC build
(livekit.org.*), but its consumer rules still keep org.jni_zero.**. With
R8 on in release builds, livekit.org.jni_zero.JniInit is stripped and
libjingle_peerconnection_so aborts in JNI_OnLoad at launch
(ClassNotFoundException, then SIGTRAP) — reproduced on a Pixel with
Mention, which carries the same rule.

Keep the class through expo-build-properties' extraProguardRules until
livekit/react-native-webrtc#107 (merged, unreleased) ships. The new test
reads the installed consumer rules: it fails if nobody keeps the class,
and fails again once upstream does, so ours gets deleted.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
BLiYing added a commit to BLiYing/im-rtc-android that referenced this pull request Sep 27, 2026
…g.webrtc 避免宿主撞包名

宿主 rongxin_android 接入时崩在 NoClassDefFoundError: Lorg/webrtc/EglBase——它自家老 VoIP
引擎(libECMedia.so,JNI 硬绑定 org.webrtc)跟本 SDK 标准版 io.github.webrtc-sdk:android 的
org.webrtc 撞 duplicate class,宿主排掉了标准版依赖,但老引擎的 fork 里没有 EglBase 这个类。

改用 io.github.webrtc-sdk:android-prefixed(同版本号 150.7871.01),org.webrtc 与 native JNI
绑定层 jni_zero 一并改名到 livekit.org.webrtc / livekit.org.jni_zero,两份实现不再共享类名,
宿主不需要排除任何一边。consumer-rules.pro 补 jni_zero 的 keep 规则——漏这条是已知坑:native
层按名字反射找 JniInit,Java 侧没有显式引用,R8 会当死代码裁掉,症状是装机正常、一调
PeerConnectionFactory.initialize() 就崩,堆栈还看不出是这里(社区里
livekit/react-native-webrtc#107 等项目踩过同一个坑)。

./scripts/test.sh 六步全绿。未真机验——尤其要拿开 R8/minify 的 release 包验一次
livekit.org.jni_zero 的 keep 规则真的生效,debug 包默认不跑 R8 测不出来。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants