androidreact-nativegradle

react-native-vactor-icon is causing error after update react native 0.72


Here is the app/build.gradle file

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: "com.android.application"
apply plugin: "com.facebook.react"


import com.android.build.OutputFile


android {
  ndkVersion rootProject.ext.ndkVersion

  compileSdkVersion rootProject.ext.compileSdkVersion

  namespace "com.englishmuni"
defaultConfig {
    applicationId "com.englishmuni"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 36
    versionName "1.0.32"
    buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", 
    isNewArchitectureEnabled().toString()
    multiDexEnabled true
  }
   }

     }

dependencies {

  implementation project(':react-native-vector-icons')
}

apply from: file("../../node_modules/@react-native-community/cli-platform- 
android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

Solution

  • Here is the simpler patch that works for variants on RN 0.72,for vector icons. You have to replace these lines in /node_modules/react-native-vector-icons/fonts.gradle

    afterEvaluate {
         .
         .
         .
         android.applicationVariants.all { def variant ->
            def targetName = variant.name.capitalize()
            def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}")
                if (lintVitalAnalyzeTask) {
                    lintVitalAnalyzeTask.dependsOn(fontCopyTask)
                }
            def generateAssetsTask = tasks.findByName("generate${targetName}Assets")
            generateAssetsTask.dependsOn(fontCopyTask)
        }
    

    then patch the package. npx patch-package react-native-vector-icons