0

从昨天开始,我在使用 Cordova 和 Android 时遇到了一些问题。我无法创建功能强大的 Android 应用程序。iOS 工作。

详细说明:我使用 Mac(MacOS X 10.8.5)并安装了 ADT 22.6.2(使用 API 17/18/19)并将 sdk-tools 添加到我的 PATH 中。

$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/adt/sdk/tools:/Applications /adt/sdk/platform-tools:/usr/local/MacGPG2/bin

我的配置:

$ node -v
v0.10.26
$ cordova -v
3.4.1-0.1.0
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on June 20 2012

我尝试创建一个 Cordova 应用程序:

$ cordova create XY com.wb.XY XY
Creating a new cordova project with name "XY" and id "com.wb.XY" at location "/.../XY"
$ cd XY
XY wb$ cordova platform add ios
Creating ios project...
XY wb$ cordova platform add android
Creating android project...
Creating Cordova project for the Android platform:
    Path: platforms/android
    Package: com.wb.XY
    Name: XY
    Android target: android-19
Copying template files...
Running: android update project --subprojects --path "platforms/android" --target android-19 --library "CordovaLib"
Resolved location of library project to: /.../XY/platforms/android/CordovaLib
Updated and renamed default.properties to project.properties
Updated local.properties
No project name specified, using Activity name 'XY'.
If you wish to change it, edit the first line of build.xml.
Added file platforms/android/build.xml
Added file platforms/android/proguard-project.txt
Updated project.properties
Updated local.properties
No project name specified, using project folder name 'CordovaLib'.
If you wish to change it, edit the first line of build.xml.
Added file platforms/android/CordovaLib/build.xml
Added file platforms/android/CordovaLib/proguard-project.txt

Project successfully created.

XY wb$ cordova platform list
Installed platforms: android 3.4.0, ios 3.4.1
Available platforms: amazon-fireos, blackberry10, firefoxos

XY wb$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
Fetching plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git" via git clone
Installing "org.apache.cordova.inappbrowser" for android
Installing "org.apache.cordova.inappbrowser" for ios
XY wb$

出了什么问题?没有目录“gen”。

如果我尝试将项目导入 ADT/Eclipse,我会收到以下消息:

Errors occurred during the build.
Errors running builder 'Android Resource Manager' on project 'XY'.
Errors running builder 'Android Pre Compiler' on project 'XY'.
Path must include project and resource name: /XY

/XY/gen already exists but is not a source folder. Convert to a source folder or rename it.

Eclipse 生成一个名为“gen”的文件夹,但它是空的。

编辑:这是我根据答案和评论中给出的输入尝试的:

我已经安装了 Node.js 和 Cordova 3.4:

$ node -v
v0.10.26
$ cordova -v
3.4.1-0.1.0
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on June 20 2012

正如您使用 CLI 描述的那样,我已经完成了此操作。

Android SDK 在系统路径中:

$ echo $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/adt/sdk/tools:/Applications/adt/sdk/platform-tools:/usr/local/MacGPG2/bin

一切似乎都很好。你看出什么错误了吗?我需要 Apache Ant 吗?

如果我尝试添加 android(不带 sudo),我会得到问题中显示的输出。以管理员身份尝试此操作(使用 sudo),结果是一样的。

$ cordova emulate android

我得到:

...
BUILD SUCCESSFUL
Total time: 5 seconds
WARNING : no emulator specified, defaulting to Android_Tablet
Waiting for emulator...
2014-04-26 14:16:53.848 emulator64-arm[84081:f07] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
emulator64-arm: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
Booting up emulator (this may take a while)........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

这需要很长时间。. . 15分钟后,我中断了。Eclipse 的日志显示总是返回相同的消息。

但随着

$ cordova run android

我可以在我的 Android 设备上安装和启动该应用程序。但是如果我尝试将项目导入 Eclipse,则会显示文件 XY.java 有很多错误。

你知道可能是什么问题吗?

我仍然可以使用我现有的应用程序(iOS 和 Android),但我无法为 Android 创建新的应用程序。

4

1 回答 1

2

我正在与您分享使用 cordova 3.4 版本创建 android PhoneGap 应用程序的步骤:-

1) 下载并安装 Node.js。

2)在您的终端上运行此命令:-

$ sudo npm install -g cordova

3)然后使用以下命令创建您的项目:-

$ cordova create hello com.example.hello HelloWorld

4)然后在添加任何平台之前,运行以下命令....用您的系统路径替换android sdk的路径:-

$ export PATH=${PATH}:/Users/taruna/Documents/adt-bundle-mac-x86_64-20131030/sdk/platform-tools:/Users/taruna/Documents/adt-bundle-mac-x86_64-20131030/sdk/tools

5) 现在使用以下命令添加您的平台:-

 $ sudo cordova platform add android

6)现在您可以使用以下命令在模拟器上成功运行您的项目:-

 $ cordova emulate android

现在完成了。

`

于 2014-04-25T11:55:31.363 回答