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 local.properties using ‘android update project’ or to inject it through the ANDROID_HOME environment variable.
The problem is because the local.properties file inside the cordova library project is incomplete. By default the local.properties file will contain the path for sdk.dir. In my case the file was empty. I just copied the local.properties 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 local.properties 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
Once imported check the xxxxxx-cordava.jar generated under bin directory
Step 2 – Import the application project
You don’t see the problem now
Today I tried creating my first Android application project via Eclipse. I use the Eclipse Luna version and trying to create an Android application project for target Android 4.4 release.
I launched the Eclipse icon by double click on the icon and start creating the project. After I provide all the details like application name, project name, package name, activity name etc… after I hit the finish button it keeps on loading.
I tried few changes in eclipse.ini file which is located in the eclipse installed directory by increasing the memory. But still the problem exists.
Something trigger my mind. I use Windows 7 and I installed eclipse inside Program Files folder and I know windows 7 using different permission levels to access anything inside program files folder.
Now I right click on the eclipse icon on desktop and I ran this time as ‘Run as administrator’ and tried creating the project. It works !!!!
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.
- JAVA JDK 8
- ANT 1.9.4
- Eclipse Luna
- Eclipse ADT Plugin 23.0
- Android SDK 23.0
- Setup Android AVD
- Node JS 0.10.31
- Phonegap 3.5.0