user3543071
user3543071

Reputation: 11

How to create Android App with Cordova 3.4

Since yesterday, I have some problems with Cordova and Android. I can not create an functional Android App. iOS works.

In detail: I use a Mac (MacOS X 10.8.5) and have installed ADT 22.6.2 (with API 17/18/19) and added the sdk-tools to my 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

My configuration:

$ 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

My attempt to create an Cordova App:

$ 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$

What is going wrong? There is no directory „gen“.

If I try to import the project into ADT/Eclipse, I got the message:

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

and

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

Eclipse generates a folder called „gen“, but it is empty.

EDIT: Here is what I tried based on the input given in answers and comments:

I have installed Node.js and 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

I have done this as you described with CLI.

The Android SDK is in the system 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

Everything seems to be all right. Do you see any mistake? Do I need Apache Ant?

If I try to add android (without sudo), I have got the output shown in my question. Trying this as admin (with sudo), the result is the same.

With

$ cordova emulate android

I get:

...
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)........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

It takes a very long time . . . after 15 minutes I broke off. The log at Eclipse shows always returning the same messages.

But with

$ cordova run android

I am able to install and launch the app on my Android-device. But if I try to import the project into Eclipse, the file XY.java is shown with many errors.

Do you have any idea what could be the problem?

I am still able to work with my existing apps (iOS and Android), but I can not create a new one for Android.

Upvotes: 0

Views: 3980

Answers (1)

taruna-systematix
taruna-systematix

Reputation: 111

I am sharing with you the steps to create android PhoneGap app with cordova 3.4 version :-

1) Download and install Node.js.

2) Run this command on your terminal :-

$ sudo npm install -g cordova

3) Then create your project using following command :-

$ cordova create hello com.example.hello HelloWorld

4) Then before adding any platform , run the following command....Replace the path of android sdk with your system path :-

$ 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) Now add your platform using following command :-

 $ sudo cordova platform add android

6) Now you can successfully run your project on emulator using following command :-

 $ cordova emulate android

And its done now.

`

Upvotes: 2

Related Questions