react native android gradle 从8.6升级到8.7的痛苦历程

感谢如下两个地址

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 里面需要升级部分第三方库

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容