[ionic]解决运行Android、IOS出现Could not find the web assets directory

简介: [ionic]解决运行Android、IOS出现Could not find the web assets directory

出现场景

使用Capacitor运行App时,出现以下提示。

adodeMacBook-Pro:ionic_app ado$ npx cap run android
✖ copy android - failed!
[error] Could not find the web assets directory: ./build.
        Please create it and make sure it has an index.html file. You can change
        the path of this directory in capacitor.config.ts (webDir option). You
        may need to compile the web assets for your app (typically npm run
        build). More info:
        https://capacitorjs.com/docs/basics/workflow#sync-your-project
✔ Updating Android plugins in 26.08ms
✖ update android - failed!
[error] Error: ENOENT: no such file or directory, open
        '/Users/ado/my/work/h5/ionic_app/android/app/src/main/assets/capacitor.plugins.json'

解决方案

这是因为还没有为app编译生成web资源文件,我们先使用ionic build编译一次

adodeMacBook-Pro:ionic_app ado$ ionic build
> react-scripts build
Creating an optimized production build...
Compiled successfully.

我们可以看到项目根目录出现了一个build文件夹,说明已经编译成功。

再次运行npx cap run android或者npx cap run ios即可成功运行。

相关文章
|
4月前
|
Windows
ionic4 checkout出的项目运行失败
ionic4 checkout出的项目运行失败
28 0
|
28天前
|
iOS开发 MacOS Perl
解决Xcode运行IOS报错:redefinition of module ‘Firebase‘和could not build module ‘CoreFoundation‘
解决Xcode运行IOS报错:redefinition of module ‘Firebase‘和could not build module ‘CoreFoundation‘
64 4
|
4月前
|
JSON Android开发 数据格式
android与Web服务器交互时的cookie使用-兼谈大众点评数据获得(原创)
android与Web服务器交互时的cookie使用-兼谈大众点评数据获得(原创)
67 2
|
4月前
|
Android开发
Android WindowFeature小探究,Android客户端Web页面通用性能优化实践
Android WindowFeature小探究,Android客户端Web页面通用性能优化实践
|
28天前
|
开发工具 iOS开发
解决Flutter运行报错Could not run build/ios/iphoneos/Runner.app
解决Flutter运行报错Could not run build/ios/iphoneos/Runner.app
76 2
|
28天前
|
iOS开发
解决Flutter运行IOS报错:Podfile is out of date
解决Flutter运行IOS报错:Podfile is out of date
33 1
|
29天前
|
开发工具 Android开发
解决Android Studio编译提示NDK is missing a “platforms“ directory
解决Android Studio编译提示NDK is missing a “platforms“ directory
94 1
|
10天前
|
iOS开发 Android开发 MacOS
从零到全能开发者:解锁Uno Platform,一键跨越多平台应用开发的神奇之旅,让你的代码飞遍Windows、iOS、Android、macOS及Web,技术小白也能秒变跨平台大神!
【8月更文挑战第31天】从零开始,踏上使用Uno Platform开发跨平台应用的旅程。只需编写一次代码,即可轻松部署到Windows、iOS、macOS、Android及Web(通过WASM)等多个平台。Uno Platform为.NET生态带来前所未有的灵活性和效率,简化跨平台开发。首先确保安装了Visual Studio或VS Code及.NET SDK,然后选择合适的项目模板创建新项目。项目结构类似传统.NET MAUI或WPF项目,包含核心NuGet包。通过简单的按钮示例,你可以快速上手并构建应用。Uno Platform让你的技术探索之旅充满无限可能。
16 0
|
4月前
|
iOS开发
iOS实时查看App运行日志
iOS实时查看App运行日志
79 0
|
9天前
|
数据库 开发者 Python
web应用开发
【9月更文挑战第1天】web应用开发
24 1
下一篇
DDNS