React Native 代码在 react-native-device-info 之后中断

React Native code broke after react-native-device-info

我正在研究 React Native 项目并尝试从 https://github.com/react-native-device-info/react-native-device-info 这个库中获取设备信息。并且,此后构建失败。这是我的 build.gradle 样子:

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 21
        compileSdkVersion = 29
        targetSdkVersion = 29
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.0.1")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}

我也试过这个解决方案React Native: Get device name through Native Modules without callback 但没有帮助。任何人都可以建议从 react-native 项目中获取设备信息。谢谢

在深入研究代码 3 天并将其与我的备份代码进行比较后,我找到了解决方案并且现在运行良好。

我已经 "react-native-msal": "^4.0.2", 安装了 Active Directory 身份验证。

而且,react-native-device-info 需要较低版本的 "react-native-msal": "^3.1.1",

所以,我使用以下命令将 msal 降级到 3.1.1。

yarn add react-native-msal@3.1.1

希望这对面临相同问题的任何人有所帮助。

谢谢