2
votes

I am attempting to run "cordova build android" through phonegap CLI with Terminal on my Mac.

First I downloaded the Android SDK.

Then I set up the project and added android.

Then I attempted "cordova build android" and received the following error:

Error: An error occurred while building the android project. Please install Android target 17 (the Android newest SDK). Make sure you have the latest Android tools installed as well. Run "android" from your command-line to install/update any missing SDKs or tools.

So I ran "android" and installed everything related to target 17.

Then I attempted "cordova build android" again and receive the following compile errors:

-compile: [javac] Compiling 3 source files to /Users/johnmacadam/Desktop/com.test.hello/platforms/android/bin/classes [javac] /Users/johnmacadam/Desktop/com.test.hello/platforms/android/src/com/ZZZ.java:20: ';' expected [javac] package com.humorthatworks.501ways; [javac] ^ [javac] /Users/johnmacadam/Desktop/com.test.hello/platforms/android/src/com/ZZZ.java:25: expected [javac] public class 501Ways extends CordovaActivity [javac] ^ [javac] /Users/johnmacadam/Desktop/com.test.hello/platforms/android/src/com/ZZZ.java:25: expected [javac] public class ZZZ extends CordovaActivity [javac] ^ [javac] /Users/johnmacadam/Desktop/com.test.hello/platforms/android/src/com/ZZZ.java:25: expected [javac] public class ZZZ extends CordovaActivity [javac] ^ [javac] /Users/johnmacadam/Desktop/com.test.hello/platforms/android/gen/com/ZZZ/BuildConfig.java:2: ';' expected [javac] package com.ZZZ; [javac] ^ [javac] /Users/johnmacadam/Desktop/com.test.hello/platforms/android/gen/com/ZZZ/R.java:8: ';' expected [javac] package com.ZZZ; [javac] ^ [javac] 6 errors

BUILD FAILED /Users/johnmacadam/Documents/adt-bundle/sdk/tools/ant/build.xml:720: The following error occurred while executing this line: /Users/johnmacadam/Documents/adt-bundle/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.

Any ideas/suggestions?

3

3 Answers

6
votes

In your config.xml you can't have a widget id with number as a first character after a dot.

For example: com.42myapp.test or com.myapp.42test won't work as well as 42com.myapp.test. It will trigger an error from the compiler.

The error will occur only for android platform, iOS handle it well.

0
votes

Turns out my problem was starting the project with a number... Java couldn't handle a number as the first character and would throw an error when attempting to compile.

0
votes

In my case, I'm using Ionic Framework, I forgot about Java convetions for package name and I made the mistake of using the identified _200 for my project when doing:

ionic start _200

Hapilly, starting a new project with a proper package identifier worked just fine:

ionic start blah