[SOLVED] [LAMW] How to sign a Gradle .apk
lazarus / 43-Android
----------------------------------------------------------------------
pasquale · 2021-01-10 14:34
Hello,
I would like to know if and how it is possible to sign a Gradle .apk
without using a Google developer account password.
So far I have managed to configure LAMW and build my myapp-
armeabi-v7a-release-unsigned.apk in the
C:\LAMWProjects\MyApp\build\outputs\apk\release folder.
After I execute gradle-local-apksigner.bat, I can find myapp-
armeabi-v7a-release-unsigned-aligned.apk in the above mentioned
release folder. There's no file named myapp-armeabi-v7a-release.apk or
the like (I mean, without the word "unsigned" in its name).
In another forum, Segator said: "No, you don't need a Google account,
but at least you need to sign your app and a Google account is not
needed for that."
If I use Ant as an .apk builder, then myapp-release.apk is built
correctly (without any Google developer account password) and it can
run in the emulator without any problems. Is this only possible with
Ant or am I missing something?
Do you need to buy a digital certificate to sign your apps in the same
way as for MS Windows apps? Or can it be done free of charge?
Again, my question is, is it possible to sign a Gradle .apk without
using a Google developer account password?
Any help will be greatly appreciated.
----------------------------------------------------------------------
jmpessoa · 2021-01-11 04:51
SOLVED!!!
Please, update the LAMW or simply the file "androidwizard_intf.pas"
ref:
https://github.com/jmpessoa/lazandroidmodulewizard/tree/master/android
_wizard
Maybe, using LAMW Manager or some git client or simply copying.... [to
LAMW folder ".....\android_wizard"]
Then re-install the "lazandroidwizardpack.lpk"
[".....\android_wizard"] before you create a new project!
Hint: Close any LAMW project [and open a default lazarus project]
before re-install a LAMW package....
Thank you!!!
----------------------------------------------------------------------
pasquale · 2021-01-11 06:48
Quote from: jmpessoa on January 11, 2021, 05:51:50 am
SOLVED!!!
Please, update the LAMW or simply the file "androidwizard_intf.pas"
ref:
https://github.com/jmpessoa/lazandroidmodulewizard/tree/master/android
_wizard
Maybe, using LAMW Manager or some git client or simply copying.... [to
LAMW folder ".....\android_wizard"]
Then re-install the "lazandroidwizardpack.lpk"
[".....\android_wizard"] before you create a new project!
Hint: Close any LAMW project [and open a default lazarus project]
before re-install a LAMW package....
Thank you!!!
Thanks.
I have copied and pasted the file "androidwizard_intf.pas" overwriting
the old one, unistalled the package "lazandroidwizardpack.lpk" and
reinstalled it.
The signing procedure seemed to complete successfully because I no
longer got the "Keystore password for signer #1:" message in the DOS
window (which now closed up automatically at the end of the
procedure). Unfortunately, the release version was not built in the
release folder. I only got the two unsigned packages.
Try to believe (using 123456 as a password).
----------------------------------------------------------------------
jmpessoa · 2021-01-11 11:29
Please, try in new project....
And use the files just "as is" .... maybe can find some error...
Here all my tests using the files just "as is" works!
And I repeated a test just now!
(see picture )
Quotethe DOS window (which now closed up automatically at the end of
the procedure).
Here it continue open...
----------------------------------------------------------------------
pasquale · 2021-01-11 13:40
Quote from: jmpessoa on January 11, 2021, 12:29:18 pmPlease, try in
new project....
And use the files just "as is" .... maybe can find some error...
Here all my tests using the files just "as is" works!
And I repeated a test just now!
(see picture )
Quotethe DOS window (which now closed up automatically at the end of
the procedure).
Here it continue open...
Thank you very much for your patience. I must find out what is wrong
with the LAMW configuration on my computer.
I've created a brand-new project and captured each single screen.
Please find attached a PDF file with all of the screenshots.
Thanks again.
----------------------------------------------------------------------
pasquale · 2021-01-11 13:45
Attached you will also find the updated version of
androidwizard_intf.pas that I took from my LAMW folder for you to
check, in case I made some mistakes when I overwrote the old version.
Thanks
----------------------------------------------------------------------
jmpessoa · 2021-01-11 17:48
Your "androidwizard_intf.pas" is OK.
Please, try in new project....
And use the files just "as is" ..... don't change the generated
files...
Maybe we can't use "underline" char in project name or in "Default
Package name"....
Please try using a default project name.... (like "AppLAMWProject9"
and "org.lamw" )
Or maybe in "keytool_input.tx" file we can't use "underline" char
like "Esposito_Software"
----------------------------------------------------------------------
pasquale · 2021-01-11 18:47
Quote from: jmpessoa on January 11, 2021, 06:48:36 pmYour
"androidwizard_intf.pas" is OK.
Please, try in new project....
And use the files just "as is" ..... don't change the generated
files...
Maybe we can't use "underline" char in project name....
Please try using a default project name.... (like "AppLAMWProject9")
Or maybe in "keytool_input.tx" file we can't use "underline" char
like "Esposito_Software"
Nope, even with "untouched" files or removing the undescores, the
result is exactly the same.
At this point, I think there can be two possible reasons: (1) the
installation of LAMW went wrong and some files were not installed
correctly; (2) there are some requirements needed to sign the .apk
(e.g. the possession of some registration key) that I don't have.
I'll keep on trying.
----------------------------------------------------------------------
jmpessoa · 2021-01-11 19:37
Quote(2) there are some requirements needed to sign the .apk (e.g. the
possession of some registration key) that I don't have.
No. I don't have, too.
I just noted that in "Step 3" picture You don't have a
"Installing....." message, Why?
Please, create a simple gradle project and send me.... "as is"....
Thank you.
----------------------------------------------------------------------
pasquale · 2021-01-11 20:42
Quote from: jmpessoa on January 11, 2021, 08:37:39 pmQuote(2) there
are some requirements needed to sign the .apk (e.g. the possession of
some registration key) that I don't have.
No. I don't have, too.
I just noted that in "Step 3" picture You don't have a
"Installing....." message, Why?
Please, create a simple gradle project and send me.... "as is"....
Thank you.
Attached you will find the sources of a gradle project. Consider that
I had to delete some folders not to exceed the size limit for the
attachments.
----------------------------------------------------------------------
jmpessoa · 2021-01-12 15:30
You don't send me a new project "as is"....
(that is, all defaults.... and don't compile it!)
But I noted some small differences with my LAMW install...
Maybe you can update using LAMW manager:
from here:
https://github.com/DanielOliveiraSouza/LAMW4Windows-installer
QuoteHow to update LAMW framework
Go to folder C:\lamw_manager
Right-click lamw_manager.bat and select Run as administrator
Please send me the "print screen" of your LAMW "Paths Settings"
"Tools" --> "" "[LAMW] ...." --> "Paths Settings ..."
Thank you!
----------------------------------------------------------------------
pasquale · 2021-01-12 15:37
Quote from: jmpessoa on January 12, 2021, 04:30:25 pm
You don't send me a new project "as is"....
(that is, all defaults.... and don't compile it!)
But I noted some small differences with my LAMW install...
Maybe you can update using LAMW manager:
from here:
https://github.com/DanielOliveiraSouza/LAMW4Windows-installer
QuoteHow to update LAMW framework
Go to folder C:\lamw_manager
Right-click lamw_manager.bat and select Run as administrator
Please send me the "print screen" of your LAMW "Paths Settings"
"Tools" --> "" "[LAMW] ...." --> "Paths Settings ..."
Thank you!
Here it is. Are the paths OK?
----------------------------------------------------------------------
jmpessoa · 2021-01-12 16:05
Yes! The paths are OK!
So, I don't understand why this difference:
My Project *.lpi
Quote
Your Project *.lpi don't have "-FDC:...........", why? weird ....
Quote
Maybe if you click OK in the "Setting Paths" can solve this issue...
My premise is the radio "NDK Version" don't was captured....
----------------------------------------------------------------------
pasquale · 2021-01-12 18:41
Quote from: jmpessoa on January 12, 2021, 05:05:22 pmYes! The paths
are OK!
So, I don't understand why this difference:
My Project *.lpi
Quote
Your Project *.lpi don't have "-FDC:...........", why? weird ....
Quote
Maybe if you click OK in the "Setting Paths" can solve this issue...
My premise is the radio "NDK Version" don't was captured....
I clicked on OK and now you can see the line
-FDC:\android\ndkr18b\toolchains\arm-linux-
androideabi-4.9\prebuilt\windows-x86_64\bin" in the .lpi file.
Unfortunately, this does not solve the problem.
So, the file gradle-local-apksigner.bat can create the two release
unsigned .apk files without any problems but it is unable to create
the release signed one.
This means that the problem could reside in the following line:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i apksigner
sign --ks newapp-release.keystore --ks-pass pass:123456 --key-pass
pass:123456 --out
C:\LAMWProjects\newapp\build\outputs\apk\release\newapp-release.apk
C:\LAMWProjects\newapp\build\outputs\apk\release\newapp-
armeabi-v7a-release-unsigned-aligned.apk
Please note that, if the app is built in Ant, the signed release .apk
is created correctly.
The problem could also reside in the file newapp-release.keystore
which is created by executing release-keystore.bat.
My conclusion: what I need to do now is detect all of the files that
come into play when release-keystore.bat and gradle-local-
apksigner.bat are executed. This is because I can do everything with
LAMW on my PC except sign a Gradle .apk. Presumably, the files used by
release-keystore.bat and gradle-local-apksigner.bat are either missing
or "outdated" on my computer so I need to reinstall them.
To jmpessoa: do you know which files are called by the two .bat files
to sign the .apk?
----------------------------------------------------------------------
jmpessoa · 2021-01-12 21:22
Quotedo you know which files are called by the two .bat files to sign
the .apk?
Yes! You can open/edit *.bat files using Notepad...
(right-click --> "Edit" and by pass the security question....)
----------------------------------------------------------------------
pasquale · 2021-01-13 06:25
Quote from: jmpessoa on January 12, 2021, 10:22:55 pm
Quotedo you know which files are called by the two .bat files to sign
the .apk?
Yes! You can open/edit *.bat files using Notepad...
(right-click --> "Edit" and by pass the security question....)
Thanks. Probably apksigner.jar needs an update. I'll try reinstalling
Java.
----------------------------------------------------------------------
jmpessoa · 2021-01-13 11:23
My Java 8 64bits config in picture.....
about "apksigner":
https://developer.android.com/studio/command-line/apksigner
----------------------------------------------------------------------
pasquale · 2021-01-13 11:59
Quote from: jmpessoa on January 13, 2021, 12:23:52 pm
My Java 8 64bits config in picture.....
about "apksigner":
https://developer.android.com/studio/command-line/apksigner
Attached you can see my Java folder, which was installed automatically
by LAMW Manager.
"apksigner sign" is the only part that does not work in the .bat file.
In fact, Lazarus is perfectly capable of creating a debug version that
can be installed in an Android emulator, and the two unsigned .apk
files are created correctly in the release folder.
There must be some problems with release-keystore.bat and/or
myappname-release.keystore.
----------------------------------------------------------------------
pasquale · 2021-01-13 20:33
Out of desperation, I uninstalled and reinstalled LAMW using LAMW
Manager. It took me hours.
In the end, I had exactly the same problem: I was unable to sign my
unsigned-aligned.apk
Well, Android is not my cup of tea. I'll just give up and look
elsewhere.
Thank you anyway for your time.
----------------------------------------------------------------------
jmpessoa · 2021-01-13 21:42
My Suggestion:
Instal the same (or very close) JAVA that I have in my system and
update your
LAMW "Settings Path" and update the java "Enviroment Variable" in your
system (JAVA_HOME, etc...)
if need.... (zulu-8 is an alternative JAVA)
----------------------------------------------------------------------
pasquale · 2021-01-14 22:34
Quote from: jmpessoa on January 13, 2021, 10:42:55 pm
My Suggestion:
Instal the same (or very close) JAVA that I have in my system and
update your
LAMW "Settings Path" and update the java "Enviroment Variable" in your
system (JAVA_HOME, etc...)
if need.... (zulu-8 is an alternative JAVA)
PROBLEM SOLVED!!!
The bug lay inside the file gradle-local-apksigner.bat which I had to
amend manually.
In order to solve the problem, I had to express the absolute path of
the file myapp-release.keystore (which became
C:\LAMWProjects\myapp\myapp-release.keystore.
So I had to change the following line:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i apksigner
sign --ks myapp-release.keystore --ks-pass pass:123456 --key-pass
pass:123456 --out
C:\LAMWProjects\myapp\build\outputs\apk\release\myapp-release.apk
C:\LAMWProjects\myapp\build\outputs\apk\release\myapp-
armeabi-v7a-release-unsigned-aligned.apk
into the following line:
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i apksigner
sign --ks C:\LAMWProjects\myapp\myapp-release.keystore --ks-pass
pass:123456 --key-pass pass:123456 --out
C:\LAMWProjects\myapp\build\outputs\apk\release\myapp-release.apk
C:\LAMWProjects\myapp\build\outputs\apk\release\myapp-
armeabi-v7a-release-unsigned-aligned.apk
Do you think this is a bug that should be fixed in LAMW?
Thanks
----------------------------------------------------------------------
jmpessoa · 2021-01-15 02:12
alive! congratulations!
QuoteDo you think this is a bug that should be fixed in LAMW?
Yes! I will apply that!
Thank you!
----------------------------------------------------------------------
pasquale · 2021-01-15 06:09
Quote from: jmpessoa on January 15, 2021, 03:12:04 am
alive! congratulations!
QuoteDo you think this is a bug that should be fixed in LAMW?
Yes! I will apply that!
Thank you!
Please let me know when the fix is ready, so I can update LAMW on my
PC.
Thanks.
----------------------------------------------------------------------
jmpessoa · 2021-01-15 12:51
Done!
Fixed "androidwizard_intf.pas" [folder .....\android_wizard]
----------------------------------------------------------------------
pasquale · 2021-01-15 13:15
Quote from: jmpessoa on January 15, 2021, 01:51:18 pm
Done!
Fixed "androidwizard_intf.pas" [folder .....\android_wizard]
Nope. Your update does not create the release .apk. I still have to
intervene manually.
In fact, the resultig .bat file does not contain the absolute path of
the keystore:
Quoteapksigner sign --ks applamwproject1-release.keystore --ks-pass
pass:123456 --key-pass pass:123456 --out C:\LAMWProjects\AppLAMWProjec
t1\build\outputs\apk\release\AppLAMWProject1-release.apk C:\LAMWProjec
ts\AppLAMWProject1\build\outputs\apk\release\AppLAMWProject1-armeabi-
v7a-release-unsigned-aligned.apk
----------------------------------------------------------------------
jmpessoa · 2021-01-15 14:03
My Test:
Quoteapksigner sign --ks C:\android\workspace\AppLAMWProject10\applamw
project10-release.keystore --ks-pass pass:123456 --key-pass
pass:123456 --out
C:\android\workspace\AppLAMWProject10\build\outputs\apk\release\AppLAM
WProject10-release.apk
C:\android\workspace\AppLAMWProject10\build\outputs\apk\release\AppLAM
WProject10-armeabi-v7a-release-unsigned-aligned.apk
You need re-install the package "lazandroidwizardpack.lpk" [folder
"............\android_wizard"]
----------------------------------------------------------------------
pasquale · 2021-01-15 14:34
Quote from: jmpessoa on January 15, 2021, 03:03:39 pm
My Test:
Quoteapksigner sign --ks C:\android\workspace\AppLAMWProject10\applamw
project10-release.keystore --ks-pass pass:123456 --key-pass
pass:123456 --out
C:\android\workspace\AppLAMWProject10\build\outputs\apk\release\AppLAM
WProject10-release.apk
C:\android\workspace\AppLAMWProject10\build\outputs\apk\release\AppLAM
WProject10-armeabi-v7a-release-unsigned-aligned.apk
You need re-install the package "lazandroidwizardpack.lpk" [folder
"............\android_wizard"]
Yes! Now it works!
I created a new app and this time the release .apk was compiled
correctly (see attached file).
You did a very good job. Congratulations!
Thank you very much.
Keep up the good work!
----------------------------------------------------------------------
rsu333 · 2021-01-16 04:47
This is useful information. Mostly play store ask many thing like key,
release apk etc and not accept apk in usually made other than Android
store. [I experience so]