React Native 项目 Android Gradle 失败(React-Native-Reanimated Fail)
Posted
技术标签:
【中文标题】React Native 项目 Android Gradle 失败(React-Native-Reanimated Fail)【英文标题】:React Native Project Android Gradle Fail (React-Native-Reanimated Fail) 【发布时间】:2021-01-05 21:41:18 【问题描述】:我正在使用 VS Code 和 react-native 编写应用程序,在尝试安装 react-native-material-ripple 后,我在尝试构建我的应用程序时遇到了以下错误:
/////////////////////////////////////// //////////////////////////////////////// FAILURE:构建失败并出现异常。
在哪里: 构建文件 'C:\Users\D'errah\Documents\Code\React\dowProjectMatcher\node_modules\react-native-reanimated\android\build.gradle' 行:89
出了什么问题: 配置项目 ':react-native-reanimated' 时出现问题。
java.io.IOException:文件名、目录名或卷标语法不正确 ///////////////////////////////////////// ///////////////////////////////////////////////p>
在此之前,该应用程序运行良好。我去了有问题的文件并查看了提到的错误行:
提到的行:
classpath += files(android.bootClasspath)
完整文件:
def safeExtGet(prop, fallback)
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
buildscript
if (project == rootProject)
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
repositories
google()
jcenter()
dependencies
classpath 'com.android.tools.build:gradle:3.5.2'
apply plugin: 'com.android.library'
apply plugin: 'maven'
android
compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
defaultConfig
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
versionCode 1
versionName "1.0"
lintOptions
abortOnError false
repositories
mavenLocal()
maven
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
maven
// Android JSC is installed from npm
url "$rootDir/../node_modules/jsc-android/dist"
google()
jcenter()
dependencies
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation "androidx.transition:transition:1.1.0"
def configureReactNativePom(def pom)
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
pom.project
name packageJson.title
artifactId packageJson.name
version = packageJson.version
group = "com.swmansion.reanimated"
description packageJson.description
url packageJson.repository.baseUrl
licenses
license
name packageJson.license
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
distribution 'repo'
developers
developer
id packageJson.author.username
name packageJson.author.name
afterEvaluate project ->
task androidJavadoc(type: Javadoc)
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
classpath += files(project.getConfigurations().getByName('compile').asList())
include '**/*.java'
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc)
classifier = 'javadoc'
from androidJavadoc.destinationDir
task androidSourcesJar(type: Jar)
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
include '**/*.java'
android.libraryVariants.all variant ->
def compileTask
if (variant.hasProperty('javaCompileProvider'))
compileTask = variant.javaCompileProvider.get()
else
compileTask = variant.javaCompile
def name = variant.name.capitalize()
task "jar$name"(type: Jar, dependsOn: compileTask)
from compileTask.destinationDir
artifacts
archives androidSourcesJar
archives androidJavadocJar
task installArchives(type: Upload)
configuration = configurations.archives
repositories.mavenDeployer
// Deploy to react-native-event-bridge/maven, ready to publish to npm
repository url: "file://$projectDir/../android/maven"
configureReactNativePom pom
问题是,我很确定即使在应用程序运行时,这条线就已经是这样了。因此,我在过去的几个小时里都在谷歌上搜索,但无法弄清楚问题的原因/如何解决。
任何帮助将不胜感激!
注意事项:
-使用 VS 代码
-在安装 react-native-material-ripple 之前工作(尝试卸载、测试、重新安装、测试)
【问题讨论】:
你知道了吗。我想知道这是否与我的错误有关***.com/questions/64090671/… 我关闭了笔记本电脑并重新启动了 Windows,然后应用程序没有任何变化。 【参考方案1】:我也发生了同样的错误,请阅读此文档以正确安装 react-native-reanimate。
安装最新版
纱线添加 react-native-reanimated@next
或
npm i react-native-reanimated@next
现在转到 android dir 和 gradlew clean,更多详细信息请点击下面的链接
https://docs.swmansion.com/react-native-reanimated/docs/installation
【讨论】:
以上是关于React Native 项目 Android Gradle 失败(React-Native-Reanimated Fail)的主要内容,如果未能解决你的问题,请参考以下文章
react-native 使用react-native run-android 启动项目 报错 Android project not found
React Native 项目 Android Gradle 失败(React-Native-Reanimated Fail)
在现有项目 React-Native 中添加现有的原生项目 Android
react-native run-android上的React Native错误
在模块 jetified-firebase-jobdispatcher-0.6.0-runtime.jar 中找到 React Native Android Duplicate class com.g