Skip to main content

Android Applications with Intellij IDEA - 1

This article applies to Android applications in Windows using IntelliJ IDEA development tools. Windows 7 was used in this example but the explanation will work for other recent versions of Windows.

It is quite a task learning how to use mobile application development tools. This page describes how to digitally sign your .apk file which is the Android application package file. In short, your Android program file.

Once you have created an APK file to launch it, simply copy to your device and use the Android file manager to install it. The picture below shows the digital signature keystore file, the unsigned APK file and the signed APK file.

The procedure of signing the APK file is quite straighforward but first you must ensure your Java JDK is properly installed and that the Java tools are accessible on your commandline (Windows command console - what used to be called the DOS window). Most important is that your PATH environmental variable (In Windows 7 find this at: Control Panel -> System->Advanced System Settings ->Environment Variables  ) should contain the path to the Java bin folder with an entry such as:

C:\Program Files (x86)\Java\jdk1.6.0_16\bin;

The rest of the story proceeds as follows:

Create key storage folder. In my case it is shown on right
"C:\Users\DELL\Documents\A-Courses\Android\IntelliJ IDEA\ca\Keytools\keys"

Change Directory to the key storage folder (created by yourself)
C:\Users\DELL>cd "C:\Users\DELL\Documents\A-Courses\Android\IntelliJ IDEA\ca\Keytools\keys"

Create key with the following command (note that you can select different  keystore names – in red)
C:\Users\DELL\Documents\A-Courses\Android\IntelliJ IDEA\ca\Keytools\keys>keytool  -genkey -alias maneno.keystore -keyalg RSA -validity 20000 -keystore maneno.keystore

The dialog that follows asks for several items as follows:

Note that some responses are optional. I have no idea which ones…
Passwords are not displayed when you enter them.
Enter keystore password:
Re-enter new password:
What is your first and last name?
  [Unknown]:  XXX YYYY
What is the name of your organizational unit?
  [Unknown]: VVV BBB
What is the name of your organization?
  [Unknown]:  UUU
What is the name of your City or Locality?
  [Unknown]:  Nakuru
What is the name of your State or Province?
  [Unknown]:  Nakuru
What is the two-letter country code for this unit?
  [Unknown]:  KE
Is CN= XXX YYYY, OU=Unknown, O=Unknown, L=Nakuru, ST=Nakuru, C=KE correct?
  [no]:  yes

Enter key password for
        (RETURN if same as keystore password):

Sign the .apk file (called Githeko201202.apk in this example)
C:\Users\DELL\Documents\A-Courses\Android\IntelliJ IDEA\ca\Keytools\keys>jarsign er -verbose -keystore maneno.keystore -signedjar Githeko1201_signed.apk Githeko201202.apk maneno.keystore

Provide the password you supplied in step 4 above.
Enter Passphrase for keystore:
  signing: res/layout/main.xml
  signing: AndroidManifest.xml
  signing: resources.arsc
  signing: classes.dex

End of story

At this point you should have the signed APK file in your target folder. Note that the names you use for the .keystore file and the .apk files will vary.

To run this application in your Android device, copy the signed APK file onto your device (I used the USB data cable) and use the "My Files" Android application to install it as follows:

  1. Browse to the device folder that contains the APK file you just copied.
  2. Select the APK file.
  3. My Files will ask: Do you want to install this application?
  4. Answer "Install"
  5. My Files responds: Application installed.
  6. If it responds: "Application not installed" it means it is most likely unsigned.
  7. End of Story.
Next time we will look at other challenging technical tasks  w.r.t. Android and IntelliJ IDEA.  IntelliJ IDEA is available both as a free application (Community Edition) and a commercial application. Unlike Eclipse which is really a nightmare for most people trying their hand at Android app development for the first time,  IntelliJ IDEA is relatively friendly. I guarantee your app will run before you reach retirement age. I can not offer that guarantee for Eclipse or for Netbeans. Sorry Eclipse gurus - it's the truth. 


Popular posts from this blog

How to Install RIOT Plugin for GIMP

Download the plugin from the download link titled "RIOT as plug-in for other applications"   Launch the Riot-plugin.exe file by double clicking.The installer installs all the files including Riot.exe, Riot.dll, and FreeImage.dll in the location where you installed GIMP  If GIMP is open, close it and re-launch it.To optimise an image, open it then save with menu File->Save for web with RIOT  You can set the target file size by selecting "Compress to size" button  on bottom right corner of optimised image pane and providing the size in kilobytes. Alternatively you can use a slider provided to allow you to change the quality while showing you a preview of the resulting image.


How to Install Packet Tracer 6.0.1 for Linux

This article is intended to help me remember the installation process for Cisco Packet Tracer 6 details of which seems to be hard to come by on the web.

1. Log in in to your Cisco Netspace account. Yes, you need to be logged in.
2. The "Download PT 6.0.1" link on is on the NetSpace home page.
3. Click this "Cisco Packet Tracer" link shown below the folder icon as shown in the figure below:

4. Select Cisco Packet Tracer 6.0.1
5. Select download location.
6. After completion of download, use your file manager to open that folder and rename the file to something such as "CPT6". It is a shell script so no file extension is required.
7. Change the file permissions to executable using command: sudo chmod 777 CPT6from a terminal window opened in the download directory. This assumes your downloaded file is renamed CPT6
8. Launch the file with command: ./CPT6 from the terminal window. You will get the message:

Self extracting archive...

Welcome to Packet Tracer 6.0…

Connecting USB 3G Modem to Safaricom in Linux Mint

This particular modem is a ZTE HSUPA MF637U modem. Click on images to see enlarged view. Let's get started:
OS is Linux Mint version 15. Yours may be older or newer.Plug in the modem to a free USB port and check that it recognises the modem as a drive in the File Manager whose icon is shown below third from left and the File Manager view is also shown with the modem listed as the "MODEM-SDSK" drive: Fig. 1. Linux Mint Desktop Panel

Fig 2. Linux Mint File Manager view showing listed drives at left and Application Manu at top. Click on image to see enlarged view.

3. Go to the Applications Menu shown in Fig. 2 and select Settings>Network Connections

Fig. 3. Network Connections dialogue. Click on image to see enlarged view.

4.  Select Add > Mobile Broadband then click  "Create"
5. Follow the wizard to select the device, country, billing plan, service provider and deafult settings.

Fig. 4. Safaricom default settings in Linux Mint. Click on image to see enlar…