FAILURE: Build failed with an exception.
* What went wrong:
Failed to capture snapshot of output files for task ':app:processDebugResources' property 'sourceOutputDir' during up-to-date check.
> Could not read path 'I:\ReactProject\Project\ReactNativeDemo\android\app\build\generated\source\r\debug\android\arch\lifecycle\livedata\core'.
解决方法:cd android
gradlew clean
解决方法:import android.support.annotation.Nullable; ——>import androidx.annotation.Nullable;
> Task :react-native-picker:verifyReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-picker:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
I:\ReactProject\Project\a9app\amor\node_modules\react-native-picker\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRa
dius not found.
I:\ReactProject\Project\a9app\amor\node_modules\react-native-picker\android\build\intermediates\res\merged\release\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerR
adius not found.
I:\ReactProject\Project\a9app\amor\node_modules\react-native-picker\android\build\intermediates\res\merged\release\values\values.xml:2727: error: resource android:attr/fontVariationSettin
gs not found.
I:\ReactProject\Project\a9app\amor\node_modules\react-native-picker\android\build\intermediates\res\merged\release\values\values.xml:2728: error: resource android:attr/ttcIndex not found.
error: failed linking references.
解决方法:
打开文件:node_modules/react-native-picker/android/build.gradle
修改为:
android {
compileSdkVersion 28
//buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
解决方法:
android/app/build.gradle中添加
dependencies{
implementation 'com.android.support:support-v4:22.2.0'
}
Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
解决方法:
android/app/build.gradle中添加
defaultConfig {
...
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
问题:
gradle版本过低
解决方法:
到项目的 android/gradle/wrapper/gradle-wrapper.properties
将 distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
改为:distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
保存后重新run-android,如果在下载gradle超时失败时建议使用AndroidStudio进行加载
解决方法:
清空缓存然后再打包安装或者安装调试
cd ./android
gradlew clean
Execution failed for task ':react-native-fast-image:mergeReleaseResources'.
Could not resolve all files for configuration ':react-native-fast-image:releaseRuntimeClasspath'.
> Could not resolve com.facebook.react:react-native:+.
Required by:
project :react-native-fast-image
> Failed to list versions for com.facebook.react:react-native.
> Unable to load Maven meta-data from https://maven.google.com/com/facebook/react/react-native/maven-metadata.xml.
> Could not get resource 'https://maven.google.com/com/facebook/react/react-native/maven-metadata.xml'.
> Could not GET 'https://maven.google.com/com/facebook/react/react-native/maven-metadata.xml'.
> Connect to maven.google.com:443 [maven.google.com/172.217.24.14] failed: connect timed out
解决方法,修改后clean之后再打包
repositories {
mavenCentral()
google()
maven {
url "https://maven.google.com"
}
}
改为
repositories {
mavenCentral()
google()
maven {
url "http://maven.aliyun.com/nexus/content/groups/public/"
}
}