升级到 React Native 0.58 后遇到的问题

1、adb: error: cannot bind listener: Operation not permitted

  • 原因:可能是 Google 加强了安全性,现在已经无法在 Android API 28+ 的模拟器(Simulator)上执行类似于 adb reverse tcp:8082 tcp:8082 命令了,会报如上错误

  • 解决方案:

    • 1.1、要么别在 Android API 28+ 模拟器上执行 adb reverse 命令
    • 1.2、要么用低版的模拟器调试

2、Only fullscreen opaque activities can request orientation

  • 报错现象:在华为荣耀V10(Android 8.0)上 App 无法启动

  • 报错详情:在 Logcat 里显示 Only fullscreen opaque activities can request orientation

  • 原因:只有全屏不透明的 activity 可以设置 orientation

  • 解决方案: 在 AndroidManifast 文件中找到相关的 Activity 类的注册,找到 android:screenOrientation='portrait',将其删除。

3、android.support.v4 与 com.android.support:support-compat:28 的不合

  • 报错现象:无法成功打出 Debug 或 Release 包

  • 报错详情: Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:14:5-64:19 to override.

  • 原因:
    项目中部分依赖(如:react-native-device-info)是用+号来匹配新版包

def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION    = "+"
implementation "com.google.android.gms:play-services-gcm:$googlePlayServicesVersion"
  • 解决方案:打开主工程的 android/build.gradle,在 ext 里添加 googlePlayServicesVersion = "15.0.1"
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容