You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native点击组件应用崩溃无控制台日志,ADB捕获到ModuleIdSetter IllegalStateException异常

解决React Native点击组件崩溃且无RN日志的Android端问题

最近碰到个棘手的情况:点击React Native应用里的某个组件时,应用直接崩溃,但React Native控制台连一条错误日志都没输出。没办法只能转向Android系统日志,通过执行adb logcat命令拿到了关键的错误信息,下面就来拆解问题并给出可行的解决方案。

关键错误日志

05-09 17:52:41.083 2488 3263 W GCoreFlp: No location to return for getLastLocation()
05-09 17:52:41.087 2488 7469 I LogUtils: [Places]: ?: Couldn't find platform key file. [CONTEXT service_id=253 ]
05-09 17:52:41.168 2488 2488 I GeofencerStateMachine: removeGeofences: removeRequest=RemoveGeofencingRequest[REMOVE_BY_PENDING_INTENT pendingIntent=PendingIntent[creatorPackage=com.google.android.gms], packageName=com.google.android.gms]
05-09 17:52:41.175 2488 2488 I chatty : uid=10109 com.google.android.gms.persistent identical 1 line
05-09 17:52:41.181 2488 2488 I GeofencerStateMachine: removeGeofences: removeRequest=RemoveGeofencingRequest[REMOVE_BY_PENDING_INTENT pendingIntent=PendingIntent[creatorPackage=com.google.android.gms], packageName=com.google.android.gms]
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: java.lang.IllegalStateException: Unable to get current module info in ModuleManager created with non-module Context
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at com.google.android.chimera.config.ModuleManager.getCurrentModule(:com.google.android.gms@202414022@20.24.14 (040700-319035315):2)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at aewd.a(:com.google.android.gms@202414022@20.24.14 (040700-319035315):4)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at aewg.b(:com.google.android.gms@202414022@20.24.14 (040700-319035315):9)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at aeso.a(Unknown Source:0)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at rpm.a(:com.google.android.gms@202414022@20.24.14 (040700-319035315):0)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at rlv.c(:com.google.android.gms@202414022@20.24.14 (040700-319035315):1)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at rlt.b(:com.google.android.gms@202414022@20.24.14 (040700-319035315):1)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at rok.b(:com.google.android.gms@202414022@20.24.14 (040700-319035315):6)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at rok.c(:com.google.android.gms@202414022@20.24.14 (040700-319035315):6)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at rok.b(:com.google.android.gms@202414022@20.24.14 (040700-319035315):10)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at rok.a(:com.google.android.gms@202414022@20.24.14 (040700-319035315):17)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at rok.g(:com.google.android.gms@202414022@20.24.14 (040700-319035315):3)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at sdr.a(:com.google.android.gms@202414022@20.24.14 (040700-319035315):2)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at scr.a(:com.google.android.gms@202414022@20.24.14 (040700-319035315):10)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at sci.a(:com.google.android.gms@202414022@20.24.14 (040700-319035315):0)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at scl.handleMessage(:com.google.android.gms@202414022@20.24.14 (040700-319035315):28)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at android.os.Handler.dispatchMessage(Handler.java:107)
05-09 17:52:41.206 2488 2976 E ModuleIdSetter: at aekz.a(:com.google.android.gms@202414022@20.24.14 (040700-319035315):2)

问题分析

从日志里最核心的错误java.lang.IllegalStateException: Unable to get current module info in ModuleManager created with non-module Context可以看出,问题根源在Google Play Services的模块管理逻辑上:初始化ModuleManager时使用了非模块类型的Context,导致它无法获取到当前模块的信息,最终触发了应用崩溃。结合日志里的定位、地点服务相关日志,推测是你用到的定位/地点类功能(比如RN的第三方定位库)和Google Play Services的交互出现了异常。

解决方案

1. 统一Google Play Services依赖版本

这种错误很大概率是因为项目中不同的Google Play Services依赖版本不一致导致的冲突。打开你的android/build.gradle(模块级的build.gradle文件),确保所有和play-services相关的依赖(比如play-services-location、play-services-places)使用同一个版本号,比如日志里出现的20.24.14:

dependencies {
    // 示例:统一版本号
    implementation 'com.google.android.gms:play-services-location:20.24.14'
    implementation 'com.google.android.gms:play-services-places:20.24.14'
    // 其他相关依赖也保持版本一致
}

2. 检查Context的使用方式

如果你的原生Android代码(或者你使用的第三方RN库)里有初始化ModuleManager的逻辑,一定要确保使用的是模块Context——比如直接用Activity实例(this)或者getBaseContext(),而不是getApplicationContext(),后者是应用级别的Context,不符合模块管理的要求。

3. 清理缓存并重建项目

缓存有时候会引发各种奇怪的问题,试试这套操作:

  • 清理RN项目缓存:npm cache clean --force
  • 进入Android目录清理项目:cd android && ./gradlew clean
  • 重新安装依赖:npm install
  • 重新运行应用:npx react-native run-android

4. 排查第三方RN库

如果是使用了第三方的定位/地点类RN库,可能是库本身的实现存在问题。去看看该库的GitHub Issues,有没有其他用户遇到类似的崩溃情况,或者直接更新到该库的最新版本试试。

内容的提问来源于stack exchange,提问作者Jyotiranjan Sahoo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 16:19:09