gpt4 book ai didi

android - 尝试在 Android 上运行我的 React Native 应用程序时出错

转载 作者:行者123 更新时间:2023-12-04 23:36:11 26 4
gpt4 key购买 nike

我已经构建了我的 React Native 应用程序,并使用我的 iOS 设备进行了几个月的测试和故障排除。现在我正在尝试第一次在 Android 上构建和测试该应用程序。问题是,我在尝试运行我的应用程序的 Android 版本时不断出错。经过数小时的调试和故障排除后,我尝试创建一个新的 RN 项目,看看它是否可以在我的模拟器和设备上运行。我让那部分工作,然后我想将现有应用程序项目的文件复制/粘贴到新项目中。
我将现有 Assets 、样式、源 JS 文件和 package.json 文件粘贴到新项目中,运行 npm install然后我在运行 react-native run-android 时得到了与原始项目中完全相同的错误消息。 .
完整的错误信息在这里:

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugAssets'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.facebook.yoga:proguard-annotations:1.14.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
- https://repo.maven.apache.org/maven2/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
- file:/Users/MyUser/.m2/repository/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
- file:/Users/MyUser/MyAppFolder/MyApp/node_modules/react-native/android/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
- file:/Users/MyUser/MyAppFolder/MyApp/node_modules/jsc-android/dist/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
- https://www.jitpack.io/com/facebook/yoga/proguard-annotations/1.14.1/proguard-annotations-1.14.1.pom
Required by:
project :app > com.facebook.react:react-native:0.64.2
> Could not find com.facebook.fbjni:fbjni-java-only:0.0.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
- https://repo.maven.apache.org/maven2/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
- file:/Users/MyUser/.m2/repository/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
- file:/Users/MyUser/MyAppFolder/MyApp/node_modules/react-native/android/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
- file:/Users/MyUser/MyAppFolder/MyApp/node_modules/jsc-android/dist/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
- https://www.jitpack.io/com/facebook/fbjni/fbjni-java-only/0.0.3/fbjni-java-only-0.0.3.pom
Required by:
project :app > com.facebook.react:react-native:0.64.2
> Could not find com.yqritc:android-scalablevideoview:1.0.4.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
- https://repo.maven.apache.org/maven2/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
- file:/Users/MyUser/.m2/repository/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
- file:/Users/MyUser/MyAppFolder/MyApp/node_modules/react-native/android/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
- file:/Users/MyUser/MyAppFolder/MyApp/node_modules/jsc-android/dist/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
- https://www.jitpack.io/com/yqritc/android-scalablevideoview/1.0.4/android-scalablevideoview-1.0.4.pom
Required by:
project :app > project :react-native-video

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10s

at makeError (/Users/MyUser/MyAppFolder/MyApp/node_modules/execa/index.js:174:9)
at /Users/MyUser/MyAppFolder/MyApp/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/Users/MyUser/MyAppFolder/MyApp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
at async Command.handleAction (/Users/MyUser/MyAppFolder/MyApp/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:186:9)
我试过运行 ./gradlew clean在android文件夹中没有任何运气。我的 build.gradle 文件如下所示:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "20.1.5948944"
kotlinVersion = "1.3.72"
}
repositories {
repositories {
google()
maven { url 'https://maven.google.com' }
mavenLocal()
mavenCentral()

// jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.1")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
mavenCentral()

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")
}

maven { url 'https://www.jitpack.io' }
}
}
如果您知道该怎么做或遇到类似问题,请告诉我!

最佳答案

我遇到了同样的问题,并通过卸载 react-native-video (npm uninstall --save react-native-video) 暂时解决了这个问题。这不是一个很好的答案,因为我需要那个组件,但我还没有完整的解决方案。我想不知何故 com.yqritc:android-scalablevideoview:1.0.4。 react-native-video 需要,但已丢失或删除。欢迎其他想法。
更新:已解决!在 Android 文件夹中的 build.gradle 中,您需要像这样在所有项目(而不是构建依赖项)中添加存储库“jcenter()”...

allprojects {
repositories {
mavenCentral()
mavenLocal()
jcenter()
}

关于android - 尝试在 Android 上运行我的 React Native 应用程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68835157/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com