Capacitor: Gradle timeout waiting to lock dependencies-accessors

新手上路,请多包涵

我想用 react + ionic + capacitor 构建移动应用程序,我按照文档所说的步骤安装了各种依赖,sync了项目,也添加了 Android 构建文件夹。但是,当我运行 ionic capacitor run android -l --host=<ip> 时,程序一直报如下错误:

ionic capacitor run android -l --host=192.168.50.119
? Which device would you like to target? Pixel 5 API 30 (emulator) (Pixel_5_API_30)
> capacitor sync android
[capacitor] ✔ Copying web assets from build to android/app/src/main/assets/public in 793.75ms
[capacitor] ✔ Creating capacitor.config.json in android/app/src/main/assets in 6.25ms
[capacitor] ✔ copy android in 837.42ms
[capacitor] ✔ Updating Android plugins in 5.20ms
[capacitor] [info] Found 4 Capacitor plugins for android:
[capacitor]        @capacitor/app@1.1.1
[capacitor]        @capacitor/haptics@1.1.4
[capacitor]        @capacitor/keyboard@1.2.2
[capacitor]        @capacitor/status-bar@1.0.8
[capacitor] ✔ update android in 100.97ms
[capacitor] [info] Sync finished in 0.95s
> react-scripts start
[react-scripts] Attempting to bind to HOST environment variable: 192.168.50.119
[react-scripts] If this was unintentional, check that you haven't mistakenly set it in your shell.
[react-scripts] Learn more here: https://cra.link/advanced-config
[react-scripts] (node:10756) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
[react-scripts] (Use `node --trace-deprecation ...` to show where the warning was created)
[react-scripts] (node:10756) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
[react-scripts] Starting the development server...
[react-scripts] 

[INFO] Development server running!
       
       Local: http://localhost:8100
       
       Use Ctrl+C to quit this process

> capacitor run android --no-sync --target Pixel_5_API_30
[react-scripts] You can now view where-now in the browser.
[react-scripts]   http://192.168.50.119:8100
[react-scripts] Note that the development build is not optimized.
[react-scripts] To create a production build, use npm run build.
[react-scripts] assets by chunk 1.82 MiB (id hint: vendors) 48 assets
[react-scripts] + 29 assets
[react-scripts] cached modules 6.02 MiB (javascript) 32.4 KiB (runtime) [cached] 409 modules
[react-scripts] webpack 5.70.0 compiled successfully in 2653 ms
[react-scripts] Files successfully emitted, waiting for typecheck results...
[react-scripts] Issues checking in progress...
[react-scripts] No issues found.
[capacitor] ✖ Running Gradle build - failed!
[capacitor] [error] 
[capacitor]         FAILURE: Build failed with an exception.
[capacitor]         
[capacitor]         * What went wrong:
[capacitor]         Gradle could not start your build.
[capacitor]         > Could not create service of type DependenciesAccessorsWorkspaceProvider using DependencyManagementBuildSessionScopeServices.createDependenciesAccessorsWorkspace().
[capacitor]         > Timeout waiting to lock dependencies-accessors (/Volumes/Data/Develop/Ionic/where-now/android/.gradle/7.0/dependencies-accessors). It is currently in use by another Gradle instance.
[capacitor]         Owner PID: unknown
[capacitor]         Our PID: 6361
[capacitor]         Owner Operation: unknown
[capacitor]         Our operation:
[capacitor]         Lock file: /Volumes/Data/Develop/Ionic/where-now/android/.gradle/7.0/dependencies-accessors/dependencies-accessors.lock
[capacitor]         
[capacitor]         * Try:
[capacitor]         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.
[capacitor]         
[capacitor]         * Get more help at https://help.gradle.org
[capacitor]         
[capacitor]         BUILD FAILED in 1m 4s
[capacitor]         
[ERROR] An error occurred while running subprocess capacitor.
        
        capacitor run android --no-sync --target Pixel_5_API_30 exited with exit code 1.
        
        Re-running this command with the --verbose flag may provide more information.

我尝试使用网上说的 ./gradlew --stop 来停止 gradle 进程并且删除了 ./.gradle 文件夹下 *.lock,重启了电脑,重新创建了好几次项目,但还是报错。

有哪位大佬能告诉我哪里出错了吗?万分谢谢!

PS: 我的代码使用的就是 ionic start 创建的模板代码,没有任何改动,也没有安装任何插件。

阅读 2.8k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题