Android Tutorial Tutorial - How to sign apk with non-B4A keystore

Here is my first tutorial for the community!

This tutorial will show you how to sign a B4A generated apk with a non-B4A keystore. I needed a way to do this for myself since I had some apps out created using AppInventor that I remade using B4A. On to the tut:

1. When you are ready to publish, You need to use B4ABuilder to compile an unsigned apk.
"C:\Program Files (x86)\Anywhere Software\Basic4Android\B4ABuilder.exe" -Task=Build -NoSign=True -Obfuscate=true
2. Go to \Main\Objects\bin and find the file called "temp.ap_". This is your app. Rename this file accordingly (i.e. "myapp.apk").
3. Copy your keystore file to the same directory as myapp.apk.
4. To make life easier, navigate to your android sdk folder and copy this file: \android-sdk\tools\zipalign.exe to the same folder as your apk and keystore.
5. Open Windows Command Prompt. Navigate to the folder where myapp.apk, keystore, and zipalign are
6. In Command Prompt type: jarsigner -verbose -keystore mykeystore.ks myapp.apk username
Change "mykeystore.ks" to your keystore's file name. Change "myapp.apk" to your app's file name. Change "username" to the username used in your keystore.
7. Enter your password when asked.
8. When it's finished, type this: zipalign -v 4 myapp.apk myapp_aligned.apk
9. You're done! myapp_aligned.apk is the file you'll need to upload to the market
 
Last edited:

walterf25

Expert
Licensed User
Longtime User
Signing apps without b4A keystore

Hi all, JonPM's tutorial is great, but there's an easier way to do it without having to go into a command prompt, just download the apptomarket located here
M. Hossein Amerkashi's Blog | My Blog Site
install this app on your desktop, once you've done this and you are ready to sign your app, in b4a under project menu, choose compile (without signing), this creates the temp.ap_ file under Object\bin folders, rename that file to the name of your app, (myapp.apk) copy that renamed file and paste it into the myapks folder inside the apptomarket folder, launch apptomarket app, and now you are ready to use your already created keystore, if you do't have one you can create one, this app is very easy to use, you can follow the tutorial video in the link provided above, good luck!

:sign0089:
Walter
 

JonPM

Well-Known Member
Licensed User
Longtime User
Hey walter, I used to use AppToMarket before when I used AI. However, I don't really like relying on a separate app to sign mine. If all else fails, the method I posted above will work 100% of the time.
 

airblaster

Active Member
Licensed User
Longtime User
Seems like I have to go the batch way then.
I'll try automating it a bit more with custombuildaction.
 

cthomas4579

Member
Licensed User
Longtime User
App Did Not Install

I used this method to pull together my .apk file but ran into a problem. Everything above seemed to work just fine. And prior to using this I was able to compile and run my app on my phone using the bridge. Worked great! When I attempt to side load my .apk file - (Send to my phone attached in email with developer mode on and attempt to install) It says "App did not install" Its a VERY basic app. I'm a beginner, simple app that creates an email subject, body and to, calls the email program up and fills in.

I created my temp.ap_ file using Release (not debug)
and again, through the bridge the app installs and runs perfectly.

Just wanna get this together so I could send the .apk to another phone and install without hickup..

Side note - I have checked the setting to allow install of apps from unknown sources

One more side note - Does anybody know how to get rid of the B4A Example Name that appears on my app? I changed Application Label in Project attributes thinking that would solve it but hasn't. This is my first app in this software
 
Last edited:

ondesic

Active Member
Licensed User
Longtime User
I thought this was fixed with 2.52. I thought I read in the release notes that you could now input an alias.
 
Last edited:

siddsg

Member
Licensed User
Longtime User
Hi Jon,
I followed the steps you mentioned, however at the command prompt, on giving the jarsignor command, am getting an error "'jarsigner' is not recognized as operable program or batch file."

What else needs to be done?
 

ttsolution

Member
Licensed User
Longtime User
Dear all,

I'm trying to build apk guided by the Tutorial (in the top). But I wonder about the username

6. In Command Prompt type: jarsigner -verbose -keystore mykeystore.ks myapp.apk username
Change "mykeystore.ks" to your keystore's file name. Change "myapp.apk" to your app's file name. Change "username" to the username used in your keystore.

But when I Create keystore file with Private Sign Key there is no textbox to put username, just 04 textbox below

1. First and last name
2. Organization
3. Country
4. Password

Where can i find the username

Many thanks for your help

Jonh,
 

MaFu

Well-Known Member
Licensed User
Longtime User
If you create a keystore with Basic4android, the username (= alias name) is always "b4a".
You can change it in the ini file found at C:\Users\<username>\AppData\Roaming\Anywhere Software\Basic4android
 
Top