因此,当我去运行react-native run-android
时,它对我来说变得难以管理,并且出现以下错误。
> Task :appcenter:processDebugAndroidTestResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':appcenter:processDebugAndroidTestResources'.
> Android resource linking failed
Output: /Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:957: error: resource android:attr/fontVariationSettings not found.
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:958: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Command: /Users/danale/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-osx.jar/ab8b4c002a26280088f841e3556db287/aapt2-3.2.1-4818971-osx/aapt2 link -I\
/Users/danale/Library/Android/sdk/platforms/android-27/android.jar\
--manifest\
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/merged_manifests/debugAndroidTest/processDebugAndroidTestManifest/merged/AndroidManifest.xml\
-o\
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/processed_res/debugAndroidTest/processDebugAndroidTestResources/out/resources-debugAndroidTest.ap_\
-R\
@/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/incremental/processDebugAndroidTestResources/resources-list-for-resources-debugAndroidTest.ap_.txt\
--auto-add-overlay\
--java\
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/generated/not_namespaced_r_class_sources/debugAndroidTest/processDebugAndroidTestResources/r\
-0\
apk\
--output-text-symbols\
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/symbols/androidTest/debug/R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-4818971-osx Daemon #0
Output: /Users/danale/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0.aar/4c088e56fbd7693aff9e8546648730a6/res/values-v28/values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values-v28/values-v28.xml:11: AAPT: error: resource android:attr/dialogCornerRadius not found.
/Users/danale/.gradle/caches/transforms-1/files-1.1/drawee-1.10.0.aar/e4fd679c2bdde73e31136252e1856cdc/res/values/values.xml:3:5-58:857: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/danale/.gradle/caches/transforms-1/files-1.1/drawee-1.10.0.aar/e4fd679c2bdde73e31136252e1856cdc/res/values/values.xml:3:5-58:857: AAPT: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Command: /Users/danale/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-osx.jar/ab8b4c002a26280088f841e3556db287/aapt2-3.2.1-4818971-osx/aapt2 link -I\
/Users/danale/Library/Android/sdk/platforms/android-27/android.jar\
--manifest\
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/merged_manifests/debugAndroidTest/processDebugAndroidTestManifest/merged/AndroidManifest.xml\
-o\
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/processed_res/debugAndroidTest/processDebugAndroidTestResources/out/resources-debugAndroidTest.ap_\
-R\
@/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/incremental/processDebugAndroidTestResources/resources-list-for-resources-debugAndroidTest.ap_.txt\
--auto-add-overlay\
--java\
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/generated/not_namespaced_r_class_sources/debugAndroidTest/processDebugAndroidTestResources/r\
-0\
apk\
--output-text-symbols\
/Users/danale/Desktop/engage-application.mobile/node_modules/appcenter/android/build/intermediates/symbols/androidTest/debug/R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.1-4818971-osx Daemon #0
好的,如果我用./gradlew clean build
清理了构建,但是然后出现了这个错误:
> Task :app:processDevDebugManifest FAILED
/Users/danale/Desktop/engage-application.mobile/android/app/src/main/AndroidManifest.xml:22:18-91 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 <application> element at AndroidManifest.xml:13:5-55:19 to override.
我的AndroidManifest.xml
文件应该是此升级的文件,实际上我删除了android:allowBackup="false"
,因为它对此抱怨还很深:
/Users/danale/Desktop/engage-application.mobile/android/app/src/main/AndroidManifest.xml:21:9-36 Error:
Attribute application@allowBackup value=(false) from AndroidManifest.xml:21:9-36
is also present at [:react-native-splash-screen] AndroidManifest.xml:12:9-35 value=(true).
Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:13:5-55:19 to override.
这里的解决方案是什么?我尝试添加它告诉我的建议,但仍然不满意。
这是我的AndroidManifest.xml
文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nfib.engage">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:launchMode="singleTop"
android:exported="true"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="@string/link_launcher"
android:pathPrefix="/auth" />
<data
android:scheme="https"
android:host="@string/link_launcher"
android:pathPrefix="/events" />
<data
android:scheme="https"
android:host="@string/link_launcher"
android:pathPrefix="/account/surveys" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
我的android/build.gradle
:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.2"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.7'
distributionUrl = distributionUrl.replace("bin", "all")
}
当我运行以下命令:./gradlew --refresh-dependencies
时,我获得了成功的构建,但是一旦运行并再次运行react-native run-android
再次返回相同的错误消息。
抱怨dialogCornerRadius
的文件是这个文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Base.Theme.AppCompat" parent="Base.V28.Theme.AppCompat"/>
<style name="Base.Theme.AppCompat.Light" parent="Base.V28.Theme.AppCompat.Light"/>
<style name="Base.V28.Theme.AppCompat" parent="Base.V26.Theme.AppCompat">
<!-- We can use the platform styles on API 28+ -->
<item name="dialogCornerRadius">?android:attr/dialogCornerRadius</item>
</style>
<style name="Base.V28.Theme.AppCompat.Light" parent="Base.V26.Theme.AppCompat.Light">
<!-- We can use the platform styles on API 28+ -->
<item name="dialogCornerRadius">?android:attr/dialogCornerRadius</item>
</style>
</resources>
这是我对AndroidManifest.xml
文件的最新重构,但我仍然遇到相同的错误:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nfib.engage"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<application
android:name=".MainApplication"
android:appComponentFactory="androidx"
tools:replace="android:appComponentFactory"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:exported="true"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="@string/link_launcher"
android:pathPrefix="/auth" />
<data
android:scheme="https"
android:host="@string/link_launcher"
android:pathPrefix="/events" />
<data
android:scheme="https"
android:host="@string/link_launcher"
android:pathPrefix="/account/surveys" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
答案 0 :(得分:0)
看看这个讨论https://github.com/facebook/react-native/issues/25371
shreyakupadhyay的答案于30/07/19是我的情况下正确的解决方法。
答案 1 :(得分:0)
运行npx jetify
是我的解决方法。