Today I face a strange problem while doing ‘ant clean’ after building the phonegap project.  The full error is as below.

\CordovaLib\build.xml:55: sdk.dir is missing. Make sure to generate using ‘android update project’ or to inject it through the ANDROID_HOME environment variable.

The problem is because the file inside the cordova library project is incomplete.  By default the file will contain the path for sdk.dir.  In my case the file was empty.  I just copied the from some other project and replaced here and the problem solved.

I was doing some Android project using phonegap where I was asked to release the signed APK using command line without any user input.  I use ‘ant’ utility to create the signed APK.  But ‘ant’ expects the key settings should be available before doing the release.

‘keytool’ is one such tool to create keys and that key can be used for ‘ant’ to create the APK.

keytool -genkey -noprompt -keystore mykeystore -storepass mystorepass -alias myfirstkey -keypass firstpass -dname “CN=net.jeema.sms, OU=web, O=JEEMA, L=Tirunelveli, S=Tamilnadu, C=IN” -validity 10000

You need to navigate to the android project folder and execute the above command.  This command will create a file ‘mykeystore’ in the directory and create the key ‘myfirstkey’ along with the password inside the file.

Basically for the first time it will create a keystore called ‘mykeystore’ with the password ‘mystorepass’.  When want to create the second key then the same keystore can be used.

Once the key is created input the key details in the which is available in the android project folder as below and save it.

Now, the ‘ant release’ command will pick the above key details and able to create the signed APK.  The APK will be available under the bin directory.

Today I got the error ‘CordovaActivity cannot be resolved’ in Eclipse while loading my existing Phonegap android application.  After few hours I figure out the problem myself.  When you load the Phonegap application in Eclipse it will load 2 projects, the first one is the Android application project and the second one is the Cordava Library project.

If you load both the projects then only you will get this error.  If you load first the library project and then the application project then you wont have this problem.

Step 1 – Import the Library project first

Import Library Project

Once imported check the xxxxxx-cordava.jar generated under bin directory

Step 2 – Import the application project

Import Application Project

You don’t see the problem now

For the past 2 days I struggled a lot to build my own android phonegap application and finally I got success. I thought of writing my experience in this page so that it can helpful for others.

Ok. Let’s start. I have a windows 7 fresh laptop with 64 bit configuration with no other specific software.

I am writing this blog on 31st August 2014 and below is the software list I would require. I believe I have all latest versions as of today.

  1. JAVA JDK 8
  2. ANT 1.9.4
  3. Eclipse Luna
  4. Eclipse ADT Plugin 23.0
  5. Android SDK 23.0
  6. Setup Android AVD
  7. Node JS 0.10.31
  8. Phonegap 3.5.0

Continue reading