我正在从以前创建的角度应用程序创建移动应用程序。我使用过this教程,该教程说明了如何使用cordova从angular创建本地应用程序。我执行了以下步骤:
cordova create mobile
创建了cordova应用,该应用在<myprojectpath>/mobile
中创建了cordova项目www
,该链接重定向到应用程序的dist文件夹sudo
权限,否则无法执行操作)cordova requirements
检查了需求,以查看是否缺少任何内容cordova run android
(使用了sudo
权限,否则无法执行此操作)它给了我以下错误:
“ path”参数必须为字符串类型。收到类型对象
在错误发生之前提供以下信息
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/home/<usr>/Android/Sdk (DEPRECATED)
No target specified and no devices found, deploying to emulator
No emulator specified, defaulting to Pixel_API_28
添加--verbose
给了我以下内容:
The "path" argument must be of type string. Received type object
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
at validateString (internal/validators.js:112:11)
at Object.dirname (path.js:1129:5)
at /var/www/html/employee_portal/mobile/platforms/android/cordova/lib/emulator.js:294:37
at _fulfilled (/var/www/html/employee_portal/mobile/node_modules/q/q.js:854:54)
at /var/www/html/employee_portal/mobile/node_modules/q/q.js:883:30
at Promise.promise.promiseDispatch (/var/www/html/employee_portal/mobile/node_modules/q/q.js:816:13)
at /var/www/html/employee_portal/mobile/node_modules/q/q.js:624:44
at runSingle (/var/www/html/employee_portal/mobile/node_modules/q/q.js:137:13)
at flush (/var/www/html/employee_portal/mobile/node_modules/q/q.js:125:13)
at processTicksAndRejections (internal/process/task_queues.js:75:11)
我已经检查了一些关于stackoverflow的问题,这些问题指向与离子相关的类似问题,例如undefined path error和path error after upgrade,但是我无法使用这些解决方案解决它们。我不确定为什么会这样,因为当我运行cordova build
时,它创建的apk没有任何问题。
我也尝试过删除node_modules
文件夹,并在我的mobile
文件夹中运行npm install,但是没有帮助。
我不确定为什么会导致此错误以及如何解决该问题
cordova requirements
的结果:
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-29,android-28,android-27
Gradle: installed /opt/gradle/gradle-5.2.1/bin/gradle
平台版本:
Installed platforms:
android 8.1.0
Available platforms:
browser ^6.0.0
electron ^1.0.0
ios ^5.0.0
osx ^5.0.0
windows ^7.0.0
我的cordova项目的package.json :
{
"name": "helloworld",
"displayName": "HelloCordova",
"version": "1.0.0",
"description": "A sample Apache Cordova application that responds to the deviceready event.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"ecosystem:cordova"
],
"author": "Apache Cordova Team",
"license": "Apache-2.0",
"dependencies": {
"cordova-android": "^8.1.0"
},
"devDependencies": {
"cordova-plugin-whitelist": "^1.3.4"
},
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {}
},
"platforms": [
"android"
]
}
}
答案 0 :(得分:0)
已解决:深入研究后,我发现Cordova无法启动模拟器,这就是为什么我寻找解决方法并得到here的原因,该问题要求手动启动使用android studio仿真器,然后运行构建。像魅力一样工作。