rn升级0.60.5遇到的问题

1、Could not get unknown property ‘mergeResourcesProvider’ for object of type com.android.build.gradle
原因:react.gradle文件中调用了比较新的API:variant是gradle android插件中的ApplicationVariantImpl类的对象,它的属性本来叫mergeResources,新版更新为mergeResourcesProvider

variant.mergeResourcesProvider.get().dependsOn(currentBundleTask)

解决方法:需要升级gradle android插件:

// 修改/android/build.gradle文件,下面一行的版本号
classpath ‘com.android.tools.build:gradle:3.3.0’

// 修改/android/gradle/wrapper/grale-wrapper.properties文件,下面一行的版本号 
distributionUrl=https://services.gradle.org/distributions/gradle-4.10.1-all.zip

2、package.json 环境配置
// Linux sudo命令以系统管理者的身份执行指令,也就是说,经由 sudo 所执行的指令就好像是 root 亲自执行
[email protected]

sudo npm install -g n
sudo n stable
node -v

[email protected]

sudo npm i npm -g
npm -v

3、Androidx和Android support库共存问题解决
Error:
Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add ‘tools:replace=“android:appComponentFactory”’ to element at AndroidManifest.xml:15:2-101:16 to override.
按照其建议加上 tools:replace=“android:appComponentFactory” 后依然报错:
解决:
选择工程右键→Refactor→Migrate to Androidx→选中所有需要重命名的目录,执行Do Refactor
android:appComponentFactory=“任意字符” //还要加上这一行

4、> Could not resolve project :react-native-camera

  • Unmatched attributes:
    - Found com.android.build.api.attributes.VariantAttr ‘generalDebug’ but wasn’t required.
    - Found react-native-camera ‘general’ but wasn’t required.
  • Unmatched attributes:
    - Found com.android.build.api.attributes.VariantAttr ‘mlkitDebug’ but wasn’t required.
    - Found react-native-camera ‘mlkit’ but wasn’t required.

解决方法:android/app/build.gradle

defaultConfig {
         ...
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        missingDimensionStrategy 'react-native-camera', 'general'   // 加上这行
        ...
    }

你可能感兴趣的:(RN)