“cordova run ubuntu”产生不完全应用 [英] "cordova run ubuntu" produces incomplete application

查看:193
本文介绍了“cordova run ubuntu”产生不完全应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图为ubuntu平台构建和运行cordova项目。该项目只是在创建新项目时自动生成的默认值。这里是config.xml文件(我添加了一行包含指向图标的链接):

 <?xml version = '1.0'encoding ='utf-8'?> 
< widget id =com.gregory.exampleversion =0.0.1xmlns =http://www.w3.org/ns/widgetsxmlns:cdv =http:// cordova .apache.org / ns / 1.0>
< icon src =img / logo.png> < / icon>
< name>示例< / name>
< description>
响应deviceready事件的示例Apache Cordova应用程序。
< / description>
< author email =dev@cordova.apache.orghref =http://cordova.io>
Apache Cordova团队
< / author>
< content src =index.html/>
< plugin name =cordova-plugin-whitelistspec =1/>
< access origin =*/>
< allow-intent href =http:// * / */>
< allow-intent href =https:// * / */>
< allow-intent href =tel:*/>
< allow-intent href =sms:*/>
< allow-intent href =mailto:*/>
< allow-intent href =geo:*/>
< platform name =android>
< allow-intent href =market:*/>
< / platform>
< platform name =ios>
< allow-intent href =itms:*/>
< allow-intent href =itms-apps:*/>
< / platform>
< / widget>

当我在浏览器中查看index.html文件时,看到cordova标志,按钮,显示连接到设备。但是当我尝试使用CLI运行它,它不工作。



以下是我使用的命令:

  gregory @ gregory- 1001PXD:〜/ javascript $ sudo cordova create example com.gregory.example示例
创建一个新的cordova项目。
gregory @ gregory-1001PXD:〜/ javascript $ cd example /
gregory @ gregory-1001PXD:〜/ javascript / example $ sudo vi config.xml
gregory @ gregory-1001PXD:〜/ javascript / example $ sudo cordova platform添加ubuntu
添加ubuntu项目...
运行命令:/home/gregory/.cordova/lib/npm_cache/cordova-ubuntu/4.0.0/package/bin/ create / home / gregory / javascript / example / platforms / ubuntu com.gregory.example示例
创建Cordova项目:
项目路径:/ home / gregory / javascript / example / platforms / ubuntu
软件包名称:com.gregory.example
项目名称:示例

config.xml中缺少图标元素
在config.xml中发现了插件cordova-plugin-whitelist。安装到项目
通过npm $ b $ fetching插件cordova-plugin-whitelist @ 1为ubuntu安装cordova-plugin-whitelist

此插件仅适用于版本的cordova-android大于4.0。如果你有一个以前的平台版本,你做*不需要这个插件,因为白名单将内置。

gregory @ gregory-1001PXD:〜/ javascript / example $ sudo cordova build ubuntu
运行命令:/ home / gregory / javascript / example / platforms / ubuntu / cordova / build
构建桌面应用程序...
为了构建debian包,执行:
cd / home / gregory / javascript / example / platforms / ubuntu / native / com.gregory.example; debuild
gregory @ gregory-1001PXD:〜/ javascript / example $ sudo cordova run ubuntu
运行命令:/ home / gregory / javascript / example / platforms / ubuntu / cordova / run
构建桌面Application ...
为了构建debian包,执行:
cd /home/gregory/javascript/example/platforms/ubuntu/native/com.gregory.example; debuild
Build Successful。运行应用程序。
运行Cordova
启动应用程序。

但是它说启动应用程序后,会弹出一个空白的灰色窗口,出现在侧边栏是一个问号。这里发生了什么?

解决方案

当我按照某人的答案回答我的另一个问题时,问题解决了:



无法找到'ANDROID_HOME'环境变量。无法在PATH中找到android命令



具体来说,这是一个权限问题。我通过反复运行

修复它

  cordova build ubuntu 

没有 sudo,然后,当有一个权限错误时,我让非root用户访问相关的文件或文件夹, p>

  sudo chown -R gregory /home/gregory/.cordova/lib/npm_cache/cordova-android/4.1.1/package/。这样做了好几次后,build命令最终没有错误地执行,然后

  cordova运行ubuntu 

成功。


I'm trying to build and run a cordova project for the ubuntu platform. The project is just the default that is produced automatically when I create a new project. Here is the config.xml file (I added the line containing the link to the icon):

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.gregory.example" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<icon src="img/logo.png" > </icon>
    <name>Example</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
</widget>

When I view the index.html file in my browser, I see the cordova logo, and a flashing button that says "CONNECTING TO DEVICE." But when I try to run it using the CLI, it doesn't work.

Here are the commands I used:

gregory@gregory-1001PXD:~/javascript$ sudo cordova create example com.gregory.example Example
Creating a new cordova project.
gregory@gregory-1001PXD:~/javascript$ cd example/
gregory@gregory-1001PXD:~/javascript/example$ sudo vi config.xml 
gregory@gregory-1001PXD:~/javascript/example$ sudo cordova platform add ubuntu
Adding ubuntu project...
Running command: /home/gregory/.cordova/lib/npm_cache/cordova-ubuntu/4.0.0/package/bin/create /home/gregory/javascript/example/platforms/ubuntu com.gregory.example Example
Creating a Cordova Project:
 Project Path: /home/gregory/javascript/example/platforms/ubuntu
 Package Name: com.gregory.example
 Project Name: Example

missing icon element in config.xml
Discovered plugin "cordova-plugin-whitelist" in config.xml. Installing to the project
Fetching plugin "cordova-plugin-whitelist@1" via npm
Installing "cordova-plugin-whitelist" for ubuntu

This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.

gregory@gregory-1001PXD:~/javascript/example$ sudo cordova build ubuntu
Running command: /home/gregory/javascript/example/platforms/ubuntu/cordova/build 
Building Desktop Application...
In order to build debian package, execute: 
cd /home/gregory/javascript/example/platforms/ubuntu/native/com.gregory.example; debuild
gregory@gregory-1001PXD:~/javascript/example$ sudo cordova run ubuntu
Running command: /home/gregory/javascript/example/platforms/ubuntu/cordova/run 
Building Desktop Application...
In order to build debian package, execute: 
cd /home/gregory/javascript/example/platforms/ubuntu/native/com.gregory.example; debuild
Build Successful. Running the application.
Running Cordova
Launching the application.

But after it says "Launching the application," an empty gray window pops up, and the icon that appears in the sidebar is a question mark. What is happening here?

解决方案

This problem was solved when I followed someone's answer to another of my questions:

Failed to find 'ANDROID_HOME' environment variable. Failed to find 'android' command in your 'PATH'

Specifically, it was a permissions problem. I fixed it by repeatedly running

cordova build ubuntu

without sudo, and then, whenever there was a permissions error, I gave my non-root user access to the relevant file or folder, e.g.

sudo chown -R gregory /home/gregory/.cordova/lib/npm_cache/cordova-android/4.1.1/package/.npmignore

After doing this several times, the build command eventually executed without errors, and then

cordova run ubuntu

was successful.

这篇关于“cordova run ubuntu”产生不完全应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆