因为 react-native-ble-manager添加过程及碰到的问题
https://github.com/innoveit/react-native-ble-manager
参考:https://blog.csdn.net/withings/article/details/71378562
按react-native-ble-manager
文档在 【Info.plist】加了key之后能正常使用了
坑大了!!!
当前项目的 compileSdkVersion = 29
按文档配置了安卓 Manifest文件,编译通过。
Manifest.permission.BLUETOOTH_CONNECT
查了一下,应该是这个问题
https://blog.csdn.net/minusn/article/details/128660803
在依赖包里确认了一下,的确是版本问题
看了下当前项目的版本 compileSdkVersion = 29 。
救命,要升级。
那就只能升级了。查了下31对应的buildToolsVersion,直接用了。
配置了
buildToolsVersion = "31.0.0"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
编译通过,运行报错
Failed to find Build Tools revision 31.0.0
Install Build Tools 31.0.0 and sync project
Upgrade plugin to version 7.3.1 and sync project
ok 莫名其妙 upgrade plugin 也要升级。
然后,就开始有一些老的兼容性的问题来了
compile project(':react-native-video')
implementation "androidx.appcompat:appcompat:1.0.0"
又查了一下
implementation project(':react-native-video')
implementation "androidx.appcompat:appcompat:1.0.0"
在 Gradle 中,compile 是一种用于指定依赖项的关键字,它用于在构建项目时包含特定的库或模块。然而,从 Gradle 4.0
开始,官方建议将 compile 替换为 implementation 或 api(在某些特定情况下)
看了下报错位置,应该是不支持compile的问题,但是不知道咋改。查了一圈,没看到配置怎么改的,只能改成implementation 试试
// 原来的
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
// 修改后的
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.implementation
into 'libs'
}
反正目前编译这里过了,暂时现在这样
升级了gradle之后, 插件Maven 已经改名为 maven-pulish
相关的expo的组件都需要升级,不然引用都不兼容
Preferences->Android SDK->SDK Tools 安装对应的工具
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
升级react-native-amap3d
UIManagerModule.ViewManagerResolver viewManagerResolver
(React Native): Execution failed for task ':app:generatePackageList'
查了查,发现是gradle不兼容,那么只能在一开始gradle升级不那么激进了,那重头来一下吧。
https://stackoverflow.com/questions/67093053/react-native-execution-failed-for-task-appgeneratepackagelist
现有RN 0.63.0 不支持 gradle 7 https://github.com/react-native-community/cli/pull/1396
先从最小的升级开始
Android Gradle 插件版本与 Gradle 版本 对照表
https://developer.android.google.cn/studio/releases/gradle-plugin?hl=zh-cn
先把Android Gradle 插件版本从4.0.1 升到4.1.0
node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/tasks/VideoResultTask.kt: (30, 112): Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
应该是 android 30 之后 kotlin编译检查严格
https://blog.csdn.net/shulianghan/article/details/118932388
升级一下 expo-image-picker
看起来是重复依赖了,尝试一下排除包
https://stackoverflow.com/questions/63180463/multiple-files-for-cameraview-while-build-app-for-android-react-native
换了一下 expo-camera的包
Targeting S+ (version 31 and above) requires that an explicit value for android
尝试了一下,https://blog.csdn.net/kuanxu/article/details/127089357,降级targetSdkVersion,在真机运行成功了
https://developer.android.google.cn/guide/topics/manifest/uses-sdk-element#ApiLevels
https://developer.android.google.cn/studio/releases/gradle-plugin?hl=zh-cn