[ionic]解决Could not read build file capacitor/build.gradle as it does notexist.

出现场景

Ionic项目以前运行的好好的,今天编译android突然出现以下报错。

A problem occured configuring project ':capacitor android'.
> Could not read build file '/Users/ado/my/work/h5/ionic_demo/node_modules/@capacitor/android/capacitor/build.gradle' as it does not exist.

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insigns.

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occured configuring project ':capacitor android'.<1111 internal calls>
Caused by: org.gradle.api.resource.MissingResourceException: Could not read build file '/Users/ado/my/work/h5/ionic_demo/node_modules/@capacitor/android/capacitor/build.gradle' as it does not exist.
	...107 more

解决办法

首先检查node_module中的android模块的build.gradle是否存在,如果确实存在,只能重新生成。

  1. 删除node_module中的@capacitor依赖库。
  2. 使用命令npm install @capacitor/core @capacitor/cli重新生成@capacitor目录
  3. 在Android Studio中关闭项目,返回到Welcome的界面。将项目从左侧列表中移除,然后点击右侧的Open an Existing Project重新打开项目,再次编译就能正常识别build.gralde了。
    在这里插入图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值