[SB 2.20] APK corrupted *without* debugger enabled
Posted: Tue Nov 14, 2017 11:21 pm
Code: Select all
;Constant definitions
#ButtonWidth = 320
#ButtonHeight = 200
Enumeration hWnd
#hWndMain
EndEnumeration
Enumeration hGadget
#hGadget_Button_Main_Inventura_Nova
#hGadget_Button_Main_Inventura_Nastavi
#hGadget_Button_Main_Inventura_Izlist
EndEnumeration
If OpenWindow(#hWndMain, 0, 0, 0, 0, "", #PB_Window_Background)
Define.i MainWindowWidth, MainWindowHeight
MainWindowWidth = WindowWidth(#hWndMain)
MainWindowHeight = WindowHeight(#hWndMain)
ButtonGadget(#hGadget_Button_Main_Inventura_Nova, MainWindowWidth / 2 - (#ButtonWidth / 2), 10, #ButtonWidth, #ButtonHeight, "Nova inventura")
ButtonGadget(#hGadget_Button_Main_Inventura_Nastavi, MainWindowWidth / 2 - (#ButtonWidth / 2), 20 + #ButtonHeight, #ButtonWidth, #ButtonHeight, "Nastavi inventuru")
ButtonGadget(#hGadget_Button_Main_Inventura_Izlist, MainWindowWidth / 2 - (#ButtonWidth / 2), 30 + #ButtonHeight * 2, #ButtonWidth, #ButtonHeight, "Izlistaj inventuru")
EndIf
When compiled WITHOUT debugging option checked, apk cannot be installed but reports being corrupted. Android 7.0 (vanilla), Motorola G5+.
Here's the error from adb:
Solution (workaround?) for Windows:adb wrote:Failed to install .\xxx.apk: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Package /data/app/vmdl171308109.tmp/base.apk has no certificates at entry AndroidManifest.xml]
1.) Go to your JDK installation folder -> bin (in my case C:\Program Files\Java\jdk1.8.0_144\bin) and run command
Code: Select all
keytool -genkeypair -v -keystore NAME.keystore -alias NAME -keyalg RSA -keysize 2048 -validity 10000
Code: Select all
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: YOUR NAME
What is the name of your organizational unit?
[Unknown]: YOUR NAME
What is the name of your organization?
[Unknown]: YOUR NAME
What is the name of your City or Locality?
[Unknown]: YOUR NAME
What is the name of your State or Province?
[Unknown]: YOUR NAME
What is the two-letter country code for this unit?
[Unknown]: YOUR NAME
Is CN=YOUR NAME, OU=YOUR NAME, O=YOUR NAME, L=YOUR NAME, ST=YOUR NAME, C=YOUR NAMEcorrect?
[no]: yes
Generating 2.048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10.000 days
for: CN=YOUR NAME, OU=YOUR NAME, O=YOUR NAME, L=YOUR NAME, ST=YOUR NAME, C=YOUR NAME
Enter key password for <YOUR NAME>
(RETURN if same as keystore password):
Re-enter new password:
[Storing NAME.keystore]
3.) Go to build-tools folder, copy your apk and rename it somehow, for example, YOURAPP_Unsigned.apk
4.) This might require repetition of step; run:
Code: Select all
zipalign.exe -f -v 4 YOURAPP_Unsigned.apk YOURAPP.apk
5.) Finally, copy that keystore from JDK folder in step 1. to build-tools folder (I didn't want to mess with PATH variable).
Code: Select all
apksigner.bat sign --ks NAME.keystore --ks- key-alias NAME YOURAPP.apk
HTH,
Bruno