quarta-feira, 7 de março de 2012

Create .apk file android eclipse


For testing on device, you can connect the device using USB and run from eclipse just as emulator.
If you need to distribute the app, then use the export feature: alt text
alt text
Then follow instructions. You will have to create a key in the process.

Android main.out.xml error


So it's been long time, I'm not doing Ruby anymore.
Now, for myself, I decided to create an Android application. At first, I wanted to create an Iphone application, but only people having a Mac can use the SDK... So let's use the Android SDK!
After doing the tutorial Hello World (see here), I started doing my application. And after a few minutes I had an error...
  1. [2010-03-09 11:32:04 - shiro]Error in an XML file: aborting build.  
  2. [2010-03-09 11:32:05 - shiro]res\layout\main.xml:0: error: Resource entry main is already defined.  
  3. [2010-03-09 11:32:05 - shiro]res\layout\main.out.xml:0: Originally defined here.  
  4. [2010-03-09 11:32:05 - shiro]D:\workspace\shiro\res\layout\main.out.xml:1: error: Error parsing XML: no element found  

For information, I'm using Eclipse. Why when I click on "run" I have this error ? Why Eclipse is creating a new file "main.out.xml" and then complain about it ? My application is really small, I didn't write any line of code in my main activity...

Well the error is simple, and it's not related to the application directly. It's a problem with Eclipse. To run the application, I must select the project (root folder) in the left column and then I can click on "run".

I had this error, because I was running the "main.xml". So Eclipse could not do anything with that.
Here is a noobie error, but it was difficult to find the solution...
I guess the next post will also concern Android application. It's always fun to discover new things :)

“Debug certificate expired on” Eclipse Android



Once in a while the SDK shows some hickups – usually easy to solve. As this one. Today i got this error message “Error generating final archive: Debug certificate expired on …” while building an apk file inside Eclipse to be run in the emulator on a machine which has not been used for a while.
android debug cert error2
If you are using IntelliJ 9 with the Android plugin the error message looks like this:
android debug cert error1
Well, the idea to just update all components to the current state and then to compile a project to check it out on this backup development system went from a 10 min cruise to the unexpected question “Whats wrong?”.
Looking at the error message it was clear that the build process wanted to use a certificate which timed out. The Android SDK is using certificates to sign all the apk files even ther files which run in the emulator (fair enough). The cert is usually valid for just 365 days which means that you get the same error next time shortly after forgetting how you’d solve it last time.
The simple solution is to just delete the file “debug.keystore” which is stored in your home directory under “~/.android” (OSX, Linux). A Windows Vista/7  user will find the file in the “C:\Users\<user<\.android folder.
android debug cert err3
After deleting the file just “clean” your project and build int from scratch and the error should be gone.
To prevent this brain training procedure for a while a decided to generate a key which lasts 1000 days instead of just the full year. Startup the OSX terminal app or the Linux terminal and go to the “.android” folder. Delete the old certificate file first. Then issue the following command from the command line:
keytool -genkey -keypass android -keystore debug.keystore -alias androiddebugkey -storepass android -validity 1000 -dname “CN=Android Debug,O=Android,C=US”
Now there should be a new certificate file sitting in the folder which lasts 1000 days – enough to really forget how you solved this issue last time around