React Native 离子电容器Android构建失败

oaxa6hgo  于 2023-03-24  发布在  React
关注(0)|答案(1)|浏览(222)

我有一个react ionic应用程序,我正试图转换为Android应用程序。我在IOS上这样做没有任何问题,但当我试图在Android Studio上运行应用程序时,它会失败并出现以下错误:

yarin@h-MacBook-Pro-sl-Yarin-2 project % npx cap run android
✔ Copying web assets from build to android/app/src/main/assets/public in 21.14ms
✔ Creating capacitor.config.json in android/app/src/main/assets in 574.33μs
[info] Inlining sourcemaps
✔ copy android in 68.90ms
✔ Updating Android plugins in 4.05ms
[info] Found 5 Capacitor plugins for android:
       @capacitor/app@4.1.1
       @capacitor/device@4.1.0
       @capacitor/haptics@4.1.0
       @capacitor/keyboard@4.1.1
       @capacitor/status-bar@4.1.1
✔ update android in 32.75ms
✔ Please choose a target device: › Google sdk_gphone64_arm64 (emulator-5554)
✖ Running Gradle build - failed!
[error] 
        > Configure project :app
        WARNING:Using flatDir should be avoided because it doesn't support any meta-data formats.
        
        > Configure project :capacitor-cordova-android-plugins
        WARNING:Using flatDir should be avoided because it doesn't support any meta-data formats.
        
        > Task :app:preBuild UP-TO-DATE
        > Task :app:preDebugBuild UP-TO-DATE
        > Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
        > Task :capacitor-android:preBuild UP-TO-DATE
        > Task :capacitor-android:preDebugBuild UP-TO-DATE
        > Task :capacitor-android:compileDebugAidl NO-SOURCE
        > Task :capacitor-app:preBuild UP-TO-DATE
        > Task :capacitor-app:preDebugBuild UP-TO-DATE
        > Task :capacitor-app:compileDebugAidl NO-SOURCE
        > Task :capacitor-cordova-android-plugins:preBuild UP-TO-DATE
        > Task :capacitor-cordova-android-plugins:preDebugBuild UP-TO-DATE
        > Task :capacitor-cordova-android-plugins:compileDebugAidl NO-SOURCE
        > Task :capacitor-device:preBuild UP-TO-DATE
        > Task :capacitor-device:preDebugBuild UP-TO-DATE
        > Task :capacitor-device:compileDebugAidl NO-SOURCE
        > Task :capacitor-haptics:preBuild UP-TO-DATE
        > Task :capacitor-haptics:preDebugBuild UP-TO-DATE
        > Task :capacitor-haptics:compileDebugAidl NO-SOURCE
        > Task :capacitor-keyboard:preBuild UP-TO-DATE
        > Task :capacitor-keyboard:preDebugBuild UP-TO-DATE
        > Task :capacitor-keyboard:compileDebugAidl NO-SOURCE
        > Task :capacitor-status-bar:preBuild UP-TO-DATE
        > Task :capacitor-status-bar:preDebugBuild UP-TO-DATE
        > Task :capacitor-status-bar:compileDebugAidl NO-SOURCE
        > Task :app:compileDebugAidl NO-SOURCE
        > Task :capacitor-android:packageDebugRenderscript NO-SOURCE
        > Task :capacitor-app:packageDebugRenderscript NO-SOURCE
        > Task :capacitor-cordova-android-plugins:packageDebugRenderscript NO-SOURCE
        > Task :capacitor-device:packageDebugRenderscript NO-SOURCE
        > Task :capacitor-haptics:packageDebugRenderscript NO-SOURCE
        > Task :capacitor-keyboard:packageDebugRenderscript NO-SOURCE
        > Task :capacitor-status-bar:packageDebugRenderscript NO-SOURCE
        > Task :app:compileDebugRenderscript NO-SOURCE
        > Task :app:generateDebugBuildConfig
        > Task :app:javaPreCompileDebug
        > Task :capacitor-android:writeDebugAarMetadata FAILED
        
        FAILURE: Build failed with an exception.
        
        * What went wrong:
        Execution failed for task ':capacitor-android:writeDebugAarMetadata'.
        > Failed to create parent directory
        '/Users/yarin/Desktop/dashboard/project/node_modules/@capacitor/android/capacitor/build' when creating directory
        '/Users/yarin/Desktop/dashboard/project/node_modules/@capacitor/android/capacitor/build/intermediates/aar_metadata/debug'

如果有人能帮我解决这个问题,我会很高兴的。不管我做了什么,它都不起作用

uxhixvfz

uxhixvfz1#

检查您的插件,其中一个仍然使用过时的代码“flatDir()”。您可能需要更新其中一个或多个插件。您可以使用npm outdate,看看哪些包需要升级。

相关问题