我正在处理本机项目并尝试从 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 项目中获取设备信息。谢谢