AI apk 2 Market

I used this process to publish my application I AM HUB as well as an upgrade to it. I have explained the process in such a way that anyone should be able to do this now.

The credit for the original walkthrough goes to the folks at the referenced URL. However, I put in many hours on my first run to figure out how to make this work. There were a number of gaps that resulted in not being able to complete this process. So what I have done is taken my experience with this and prepared this guide so that everyone can benefit from the time I have put in getting the instructions to a point where anyone can do it. As already mentioned this intuitive guide helps fill some gaps left open by the original.

I have also added a little bonus that I think everyone will enjoy. Consider it my New Year’s present to you. Keep reading…

The following steps come from the original at:
http://www.androidworld.it/forum/app-inventor-91/%5Bhow-%5D-publish-app-created-app-inventor-android-market-4597/

The first time you go through this it can be a lengthy process, which will have some added time if you don’t’ have some or all of the preparation requirements. However, after doing this once and get oriented to the locations and process, subsequent conversions take no more than 5 minutes. Hopefully, my addendum guide will help everyone complete this process with no more frustration.

Preparation

  • Open (if you don’t already have one) a Google developer account
  • Download the AI apk that you will use to upload to the market
  • Make a backup of the apk. This step is self-explanatory.
  • Download the tools needed as referenced on the above URL (Auto-Sign v0.65.exe) which is attached to that thread and “apktool” which is mentioned but no download link is given. So here it is: http://code.google.com/p/android-apktool/. You will need the following 2 files, or whatever the latest version is listed. Look under featured on the right side.
    • One of the 3 apktool-install-, depending on OS (linux, macosx or windows)
    • Apktool 1.3.2
    • Extract the above two archives and combine them in one directory
  • Install 7zip (it’s free, http://www.7-zip.org/download.html)
  • Install the Java SDK
  • Install the AndroidSDK if you don’t already have it installed

Step 1
Creating the key

The only thing I want to point out here is when entering the command line you should change the following values

  • my-release-key.keystore to something more meaningful to your app/company (i.e. MyApp.keystore or MyCompany.keystore)
  • aliasname with the same approach as above
  • Make sure to save the .keystore, alias name and password that you set for this. You will need it to sign the new apk later on

The command you enter in the command prompt should look like this, but with the custom naming as described above. Enter it in the command prompt in the JDK \bin directory. The cert it generates will also appear here. You can copy the cert somewhere else for backup, but leave it here because you’ll be back to sign your apk with it.

keytool.exe -genkey -v -keystore mycompany.keystore -alias myalias -keyalg RSA -keysize 2048 -validity 10000

Step 2
Signing the apk

While you don’t need to customize the icon since AI supports adding an icon, you can do so if you choose to set a different one at this time. The more important piece of this step is the use of Auto-Sign.

The highlights from this step are:

  1. Open the apk using 7zip (right-click apk, click open archive) and delete the META-INF folder
  2. Close 7zip and rename the apk to Launcher.apk
  3. Extract the Auto-Sign files and copy Launcher.apk to Auto-Sign\update\app
  4. Run Auto-Sign v0.65.exe and select Launcher.apk from the drop down. It should look like this.
  5. Notice how Launcher.apk is green at the bottom left
  6. Click Auto-Sign
  7. You should get a confirmation message within seconds. Close it and hit Exit
  8. Browse to the folder where you dropped the renamed Launcher.apk. You should now see a file called, Launcher_signed.apk.
    1. You will be using this new signed file for the remainder of the process

Step 3
Edit the APK to be compatible with the Market

This part is very confusing in the original guide, and to top it off, the command line given is not correct. Here is a different version of step 3, put as simply as possible.

  1. In the command prompt browse to the directory where you extracted the apktool.
    1. You can also add the path to your OS system path so that you can run it from anywhere. I did this so I can work from one directory and limit moving files around
  2. However you choose to do it, make sure the signed apk is in the same directory where you are running this command.
    1. The syntax listed is: apktool d -s pre-nomeapk.apk
    2. You need to replace pre-nomeapk.apk with the name of your apk, which in this case is the signed apk. So you will enter the following:
      1. apktool d -s Launcher_signed.apk
    3. After you hit enter, you should get results that look like the following:
    4. In Windows explorer, open this directory and you will see a folder called, “Launcher_signed”. Backup this folder. Just select it and do, ctrl+c, ctrl+v. In case you run into problems, you don’t have to start over again.
    5. At this point you will edit the “AndroidManifest.xml” file. You can use Notepad.exe for that
      1. The first entry to add is: android:versionCode = “1”
      2. The second entry: android:versionName = “1.0”
        1. These deal with the version of your app. For more info see this link: http://developer.android.com/guide/publishing/versioning.html
      3. The source URL for this guide mentions some other items that can be changed, but I did not do any of them. The one that says to add a line is not needed, because it’s already there.
      4. Save the file and exit….WAIT…Here’s the little gift I mentioned…
      5. Since we now have access to the manifest, there is quite a bit that we can do here that is not supported by AI yet. The most important item that comes to mind, is screen orientation. If your app should always stick to the portrait orientation, add the following line.
        1. android:screenOrientation=”portrait” in the
          1. The above will set the app to portrait only.
          2. Here is how this line looks after the edit in my file:
            1. android:screenOrientation=”portrait”>
          3. For other orientation settings as well as other options in this file, visit this page: http://developer.android.com/guide/topics/manifest/activity-element.html
      6. Ok…now save the file and exit.
      7. Next step is to compile. Enter the following in the same location where you ran the apktool in step 2.2.1
        1. apktool b Launcher_signed
        2. In step 2.2.1 we pointed to the apk to decompile. Now we are pointing to the directory that was created, to compile the new apk.
        3. The results after running the command should look like this:
        4. Now the next step is another one that is confusing in the source guide. It does not tell you which apk to open and where to find it. And, if you look in the directory you just ran this command in, there is no new file here. So, here is the answer to that.
          1. Go back into the Launcher_signed directory that you just ran the compile on
          2. You will see a directory called “dist”. Open this directory
          3. And there is your new compiled apk. “Launcher_signed.apk”
          4. Make a backup and proceed to the next step.
        5. Using 7zip, open the archive as we did to an earlier version of the apk and delete the 2 files noted in the source guide. The names may not be the same, but the extensions will be.
          1. I did not have these files, but check for them just in case.
          2. Close the archive

Step 4
Sign, Verify and Rename

Now we go back to the \bin folder of the java sdk to sign, verify and rename the apk to the name of our app. It’s preferable not to publish an app called Launcher_Signed, unless of course that is the name of your app.

  1. Copy the new apk to the \bin folder of the java sdk
  2. In the command prompt, browse to that folder. It should still contain the self-signed cert you created at the start
  3. Enter the following command:
    1. jarsigner.exe -verbose -keystore MyValue.keystore Launcher_signed.apk MyAlias
      1. You did remember to make not of these value when you created the cert, right? If not, it’s not a big deal. Just redo step 1 to make a new cert.
    2. When you press enter you will be prompted for the following:
      1. Passphrase for keystore:
      2. After pressing enter it will sign the package. You’ll see it run through a serious of files, each line starting with “signing: “
    3. Now verify the signed apk. Enter the following in the same location as step 3
      1. jarsigner.exe -verify -verbose -certs Launcher_signed.apk
      2. It will take a second or two and when it’s done, look at the very last line. If all is good, it will show:
      3. Make a backup of this file.
  4. Final step is to rename the file to what your app is called.
    1. This is another missing piece in the original. There is no mention where the zipalign executable can be found. This is a part of the Android SDK and can be found in the \tools folder of the root of the android sdk install folder.
      1. Copy the signed Launcher_Signed.apk to this location
      2. From the command prompt, run the following:
        1. zipalign -v 4 Launcher_signed.apk NameOfYour.apk
        2. For my app I AM HUB, it looks like this
        3. zipalign -v 4 Launcher_signed.apk IAMHUB.apk
        4. After hitting enter, it will run through a serious of files and the last line should read, “Verification successful”.
        5. Open this location using Windows explorer and you should now see the file with the new name. In my case that is, “IAMHUB.apk”.
    2. You might get an error when uploading the apk to the market. On Firefox it looks like this
    3. On IE it shows a different error. Same thing when you upload an upgrade. However, it still works. Go back to the home page and you’ll see the draft published. Edit all the details and publish it to Market.
    4. Just one other thing to note. I found that IE seems to be better at setting up the app details. I had problems uploading graphics using Firefox, but IE uploaded with no issues. I didn’t try Chrome, but I would imagine it should work with no problems as well.
    5. You can get more info about the graphic requirements for the apps at this link:
      1. http://www.google.com/support/androidmarket/bin/answer.py?hl=en&answer=1078870

That’s all there is to it. Grab this file and use it to upload to the market. If you have any questions, let me know and I will try to assist.

Good luck and enjoy seeing your apps in the Android Market!

Please download my app “I AM HUB” from the market and give me a comment. I just updated to a new version with a completely redesigned UI.

Relevant URL summary

Original guide
http://www.androidworld.it/forum/app-inventor-91/%5Bhow-%5D-publish-app-created-app-inventor-android-market-4597/

Auto-Sign
Attached to original guide. You’ll need to create a free account on that forum.

Apktool
http://code.google.com/p/android-apktool/

Android SDK
http://developer.android.com/sdk/index.html

Java SDK
http://www.oracle.com/technetwork/java/javase/downloads/index.html

AndroidManifest.xml Information
http://developer.android.com/guide/topics/manifest/activity-element.html

App versioning info
http://www.google.com/support/androidmarket/bin/answer.py?hl=en&answer=1078870

You may also like...

  • zvzej

    Hi I’m the same as JesusyJackie Leon, I just want to say thanks to all your help by making this tutorial! I figure it out all my problems were do to making my bin folder and the tools folder accesible as a administrator!

  • Sepp Steiner

    confusing

  • very good