React Native打包Android报错:AAPT: error: resource android:attr/fontVariationSettings not found.

报错截图:

版本信息:
1.android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 27
        supportLibVersion = "27.0.3"

    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
         classpath "com.google.gms:google-services:3.1.2"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

2.android/gradle.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

解决方案:

在android/build.gradle中加上以下代码:

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 27
                buildToolsVersion "27.0.3"
            }
        }
        configurations.all {
                        resolutionStrategy {
                            force 'com.google.android.gms:play-services-gcm:16.1.0'
                            force 'com.google.android.gms:play-services-location:16.0.1'
                            force 'com.google.android.gms:play-services-basement:16.2.0'
                            force 'com.google.android.gms:play-services-auth:16.0.1'
                            force 'com.google.android.gms:play-services-stats:16.0.1'
                            force 'com.google.android.gms:play-services-base:16.0.1'
                        }
                    }
    }
}

你可能感兴趣的:(React Native打包Android报错:AAPT: error: resource android:attr/fontVariationSettings not found.)