感谢如下两个地址
https://react-native-community.github.io/upgrade-helper/?from=0.74.2&to=0.75.1
https://github.com/facebook/react-native/issues/46069
重点来了:
AndroidManifest.xml 需要添加android:supportsRtl="true"
需要改:
<application
。。。。。。。
android:supportsRtl="true" >
kotlinVersion = "1.9.22" 升级到 kotlinVersion = "1.9.24"
/* Autolinking */
autolinkLibrariesWithApp()
按如下步骤
Step-1 Update package.json file for "react-native": "0.74.x" to "react-native": "0.75.2"
Step-2 Update the distributionUrl inside the gradle-wrapper.properties file distributionUrl=https://services.gradle.org/distributions/gradle-8.7-bin.zip
Step-3 Add autolinkLibrariesWithApp() within the app/build.gradle file. react { autolinkLibrariesWithApp() }
Step-4 Remove below lines from app/build.gradle file. apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle") applyNativeModulesAppBuildGradle(project)
Step-5 Remove below line from settings.gradle file. apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
Step-6 Add below lines above the rootProject.name property. pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") } plugins { id("com.facebook.react.settings") } extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
rootProject.name = 'ProjectName'
Step-7 Delete the .build, .gradle folder from android
Step-8 Remove node_modules, yarn.lock file and run yarn android command to build the application
app/build.gradle 里面添加如下代码去除依赖,有些工程不需要
dependencies{
implementation'androidx.core:core:1.9.0'
implementation'androidx.appcompat:appcompat:1.4.1'
// 其他依赖
// 排除重复依赖
// implementation('some.library:version') {
// exclude group: 'com.android.support', module: 'support-compat'
// }
}
configurations.all{
resolutionStrategy.eachDependency{ details->
if (details.requested.group =='com.android.support') {
details.useTarget"androidx.core:core:1.9.0"
}
}
}
package.json 里面需要升级部分第三方库