android - React native 应用程序不适用于 Android 版本 11

标签 android react-native android-studio

我已经在 React Native 中创建了一个应用程序。在 Android 版本 11 上它不工作。我尝试登录,但出现错误,并且使用相同的 ID 和密码在 Android 版本 10 或更低版本上运行。

 buildToolsVersion = "29.0.0"
 minSdkVersion = 16
 compileSdkVersion = 29
 targetSdkVersion = 29
 supportLibVersion = "29.0.0"

我是否必须将 targetsdkversion 更新为 30?

日志

2021-06-04 12:57:12.798 4375-10265/com.xxxI/ReactNativeJS: 'parameters :-', { id: 'LOGIN_ID',
      api: 
       { body: 
          { _parts: 
             [ [ 'command', 'login' ],
               [ 'username', 'xxxxxxxxxxxxxx.com ' ],
               [ 'password', 'xxxxxxx' ] ] } } }
2021-06-04 12:57:12.834 4375-4375/com.xxx D/InputMethodManager: HSIFW - flag : 0
2021-06-04 12:57:41.165 4375-10218/com.xxx I/com.xxx: NativeAlloc concurrent copying GC freed 541077(17MB) AllocSpace objects, 16(320KB) LOS objects, 49% free, 7125KB/13MB, paused 213us total 115.644ms
2021-06-04 12:57:41.214 4375-10220/com.xxx W/System: A resource failed to call release. 
2021-06-04 12:58:12.828 4375-10265/com.xxx I/ReactNativeJS: 'In catch...error :-', { [Error: timeout] line: 557, column: 376, sourceURL: 'index.android.bundle' }

也得到

 E/Netd: getNetworkForDns: getNetId from enterpriseCtrl is netid 0

更新:应用终于可以在 android 11 上运行了

android/build.gradle

      buildToolsVersion = "30.0.0"
      minSdkVersion = 16
      compileSdkVersion = 30
      targetSdkVersion = 30
      supportLibVersion = "30.0.0"

android/app/build.gradle

minifyEnabled true

android/app/src/debug/AndroidManifest.xml

tools:targetApi="30"

最佳答案

在android\build.gradle 添加:

ext {
    minSdkVersion = 21
    compileSdkVersion = 30
    targetSdkVersion = 30
    buildToolsVersion = "30.0.2"
    ndkVersion = "20.1.5948944"
}

在android\app\build.gradle 添加:

implementation("com.squareup.okhttp3:okhttp:4.9.1")
implementation("com.squareup.okhttp3:okhttp-urlconnection:4.9.1")

关于android - React native 应用程序不适用于 Android 版本 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67314727/

相关文章:

android - 如何通过 YouTube API 获取特定用户上传的所有视频

java - 在 Android Studio 中以编程方式添加值的字符串名称

javascript - 如何创建类似 Twitter 的个人资料布局?

android - 无法生成新的签名apk 密码验证失败

java - GSON在解析okHttp响应时返回null

java - Android 创建一个没有 PreferenceActivity 的 PreferenceFragment

javascript - 使用createDrawerNavigator时如何让Header也滑动?

javascript - React-Native: Release模式下的 JavaScript 正则表达式异常(无效组)

java - 将数据从一个 Activity 传递到另一个 Activity ,然后打印

android - 如何使用 Android Studio 管理不断变化的 SNAPSHOT 依赖项?