首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >构建失败:当我运行npm运行android时无法安装该应用程序

构建失败:当我运行npm运行android时无法安装该应用程序
EN

Stack Overflow用户
提问于 2022-06-22 23:41:45
回答 2查看 2.9K关注 0票数 2

我试图用reactnative构建一个移动应用程序,并在android仿真器上进行测试,但是当我使用npm运行android程序时,它就失败了。我尝试修改gradle.build文件(将sdk版本升级到31 ..)但什么都不管用。npm安装工作正常,没有任何漏洞。

这是命令的输出:

代码语言:javascript
复制
>react-native run-android
    
    warn Package react-native-vector-icons has been ignored because it contains invalid configuration. Reason: "dependency.assets" is not allowed
    info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
    (node:16364) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
    (Use `node --trace-warnings ...` to show where the warning was created)
    Jetifier found 1186 file(s) to forward-jetify. Using 12 workers...
    info Starting JS server...
    info Installing the app...
    > Task :app:mergeDebugAssets FAILED
    
    Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
    Use '--warning-mode all' to show the individual deprecation warnings.
    See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
    23 actionable tasks: 23 executed
    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
    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/addon2/03 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/repository2/03 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/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/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
    Warning: �l�ment inattendu (URI : "", local : "base-extension"). Les �l�ments attendus sont <{}codename>,<{}layoutlib>,<{}api-level>
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:mergeDebugAssets'.
    > Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
       > Failed to transform react-native-reanimated-69-jsc.aar (project :react-native-reanimated) to match attributes {artifactType=android-assets}.
          > Execution failed for JetifyTransform: C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\react-native-reanimated\android\react-native-reanimated-69-jsc.aar.
             > Transform's input file does not exist: C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\react-native-reanimated\android\react-native-reanimated-69-jsc.aar. (See https://issuetracker.google.com/issues/158753935)
    
    * 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 8s
    
    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.bat 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
    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/addon2/03 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/repository2/03 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/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/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
    Warning: �l�ment inattendu (URI : "", local : "base-extension"). Les �l�ments attendus sont <{}codename>,<{}layoutlib>,<{}api-level>
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:mergeDebugAssets'.
    > Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
       > Failed to transform react-native-reanimated-69-jsc.aar (project :react-native-reanimated) to match attributes {artifactType=android-assets}.
          > Execution failed for JetifyTransform: C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\react-native-reanimated\android\react-native-reanimated-69-jsc.aar.
             > Transform's input file does not exist: C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\react-native-reanimated\android\react-native-reanimated-69-jsc.aar. (See https://issuetracker.google.com/issues/158753935)
    
    * 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 8s
    
        at makeError (C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\execa\index.js:174:9)
        at C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\execa\index.js:278:16
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at async runOnAllDevices (C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
        at async Command.handleAction (C:\Users\ghars\OneDrive\Bureau\react-navigation-v6-mix\node_modules\@react-native-community\cli\build\index.js:192:9)
    info Run CLI with --verbose flag for more details.
EN

回答 2

Stack Overflow用户

发布于 2022-06-23 00:54:52

转到您的babel.config,并添加"plugins:‘react本机-恢复/插件’“。

您的babel.config.js文件应该如下所示

代码语言:javascript
复制
module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: ['react-native-reanimated/plugin'],
};

检查你的android/app/build.gradle,如果你有正确的配置,以应用反应-本机-矢量-图标。该配置应该如下所示:

代码语言:javascript
复制
project.ext.vectoricons = [
    iconFontNames: [ 'Ionicons.ttf' ] // Name of the font files you want to copy
]

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

尝试清理您的项目:使用以下命令。一个接一个地运行(注意,如果使用纱线,可以更改npm安装,而可以使用纱线安装)

代码语言:javascript
复制
watchman watch-del-all
rm -rf yarn.lock package-lock.json node_modules
rm -rf android/app/build
rm ios/Pods ios/Podfile.lock 
rm -rf ~/Library/Developer/Xcode/DerivedData
npm install && cd ios && pod update && cd ..
npm start -- --reset-cache

在终端中使用以下命令运行项目:

代码语言:javascript
复制
npx react-native run-android ... for android 

npx react-native run-ios ... for ios
票数 0
EN

Stack Overflow用户

发布于 2022-10-11 07:21:39

步骤1.在下面的路径'android\app\src\main\assets‘中创建一个文件夹“字体”。确保“字体”的“f”是小的。

第二步,复制'node_modules\react-native-vector-icons\Fonts‘中的所有文件,并在“android\src\main\\fonts”中通过它。

步骤3.从模拟器中删除现有的应用程序,然后再运行一次。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72723057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档