我有一个 react-native 项目,它昨天在 android 上工作正常,但是今天当我运行 react-native run-android
时发生错误。今天在android上运行之前,没有任何改变,只是在AndroidStudio
中打开它。报错如下:
.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/d1dde4fd0fa50f7f7336597688c557a9/res/values/value s.xml:252:5-69: AAPT: error: resource android:attr/fontVariationSettings not found.
.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.0.2.aar/d1dde4fd0fa50f7f7336597688c557a9/res/values/value s.xml:252:5-69: AAPT: error: resource android:attr/ttcIndex not found.
error: failed linking references.
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:processDebugResources'.
Failed to process resources, see aapt output above for details.
主要配置如下:
"react": "16.6.3",
"react-native": "0.57.8"
gradle plugin:com.android.tools.build:gradle:3.1.0
compileSdkVersion 27
buildToolsVersion "27.0.3"
minSdkVersion 19
targetSdkVersion 27
我花了很多时间解决它,但没有成功。
大多数解决方案都是将 android 升级到 AndroidX,但我不能,因为我的项目有很多依赖项,其中一些不支持 AndroidX。
所以我想知道为什么在我运行它时需要android:attr/ttcIndex
。以及如何修复它并且不升级android版本并保持compileSdkVersion 27
最佳答案
这对我有帮助
在文件 android/gradle.properties 的顶部
googlePlayServicesVersion=12.0.1
并创建新的 index.android.bundle
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/应用程序/src/main/res
关于android - react native 中的 "resource android:attr/fontVariationSettings not found.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56665267/