vlang / vab

V Android Bootstrapper
MIT License
319 stars 29 forks source link

Can't find keytool #263

Closed milen-prg closed 1 year ago

milen-prg commented 1 year ago

OS: Windows 10 Pro 64bit

V version

vab doctor

C:\Users\mlap\Downloads\temp>vab doctor Warning: could not locate keytool: vab.java.jdk_keytool: no keytool.exe could be located in "C:\Program Files\Common Files\Oracle\Java\javapath_target_1556046" vab will not be able to sign any packages. It looks like you have a Java compiler (C:\Program Files\Common Files\Oracle\Java\javapath_target_1556046\javac.exe) but no keytool you probably have Java JRE installed but no JDK. Please install Java JDK >= 8 or provide a valid path via JAVA_HOME The detected sdkmanager seems outdated or incompatible with the Java version used. For vab to control it's own dependencies, please update sdkmanager found in: "C:\Users\mlap\AppData\Local\Android\sdk\tools\bin\sdkmanager.bat" or use a Java version that is compatible with your sdkmanager. You can set the SDKMANAGER env variable or try your luck with vab install auto. Please see https://stackoverflow.com/a/61176718/1904615 for more help.

vab Version 0.3.7 fff2efd Path "C:\Users\mlap.vmodules\vab" Base files "C:\Users\mlap.vmodules\vab\platforms\android" env JAVA_HOME=C:\Program Files\Java\jdk-19 Java JDK Version 19.0.0 Path "C:\Program Files\Java\jdk-19" Keytool "N/A" Android ENV sdkmanager "C:\Users\mlap\AppData\Local\Android\sdk\tools\bin\sdkmanager.bat" sdkmanager.version "0.0.0" Managable false SDK Path "C:\Users\mlap\AppData\Local\Android\sdk" Writable true APIs available ['33', '31', '25'] NDK Version 25.2.9519653 Path "C:\Users\mlap\AppData\Local\Android\sdk\ndk" Side-by-side true min API level available 19 max API level available 33 arm64-v8a ['33', '32', '31', '30', '29', '28', '27', '26', '24', '23', '22', '21'] armeabi-v7a ['33', '32', '31', '30', '29', '28', '27', '26', '24', '23', '22', '21', '19'] x86 ['33', '32', '31', '30', '29', '28', '27', '26', '24', '23', '22', '21', '19'] x86_64 ['33', '32', '31', '30', '29', '28', '27', '26', '24', '23', '22', '21'] Build API 33 Build-tools 33.0.1 Packaging Format apk Product Name "V Test App" Package ID "io.v.android" Output "" V Version 0.3.3 6e1e406 Path "C:\v"

    V full version: V 0.3.3 6e670ec.6e1e406
    OS: windows, Microsoft Windows 10 Pro v19045 64-bit
    Processor: 4 cpus, 64bit, little endian,

    getwd: C:\Users\mlap\Downloads\temp
    vexe: C:\v\v.exe
    vexe mtime: 2023-03-17 13:09:22

    vroot: OK, value: C:\v
    VMODULES: OK, value: C:\Users\mlap\.vmodules
    VTMP: OK, value: C:\Users\mlap\AppData\Local\Temp\v_0

    Git version: git version 2.37.3.windows.1
    Git vroot status: weekly.2023.11-18-g6e1e4062 (21 commit(s) behind V master)
    .git/config present: true

    CC version: Error: exec failed (CreateProcess) with code 2: The system cannot find the file specified.
     cmd: cc --version
    thirdparty/tcc status: thirdparty-windows-amd64 1e6e7c6f

What did you do?

C:\Users\mlap\Downloads\temp>vab .

I try to make apk from .v file, but error is returned.

What did you expect to see?

Successfully generated apk.

What did you see instead?

Warning: could not locate keytool: vab.java.jdk_keytool: no keytool.exe could be located in "C:\Program Files\Common Files\Oracle\Java\javapath_target_1556046" vab will not be able to sign any packages. It looks like you have a Java compiler (C:\Program Files\Common Files\Oracle\Java\javapath_target_1556046\javac.exe) but no keytool you probably have Java JRE installed but no JDK. Please install Java JDK >= 8 or provide a valid path via JAVA_HOME

I really have Java JRE 8 in "C:\Program Files\Common Files\Oracle\Java\javapath_target_1556046", but I have full new Java JDK in JAVA_HOME, detected from vab doctor (see above).

larpon commented 1 year ago

Strange. Does keytool or keytool.exe exist somewhere under C:\Program Files\Java\jdk-19? (Should reside in a bin directory)

milen-prg commented 1 year ago

Strange. Does keytool or keytool.exe exist somewhere under C:\Program Files\Java\jdk-19? (Should reside in a bin directory)

The keytool.exe indeed exists in: C:\Program Files\Java\jdk-19\bin

BUT, the vab, as see logs above, sees the: C:\Program Files\Common Files\Oracle\Java\javapath_target_1556046 with JRE 8, and there is no keytool, and not work, despite, it discover the JDK 19 by JAVA_HOME in C:\Program Files\Java\jdk-19 The problem is, that vba did not search keytool in this JDK, in JAVA_HOME path, but in C:\Program Files\Common Files\Oracle\Java\javapath_target_1556046.

Additionaly, even the C:\Program Files\Java\jdk-19\bin is in my system PATH, so the keytool is accessible from everywhere.

milen-prg commented 1 year ago

I find, that if in system PATH the: C:\Program Files\Java\jdk-19\bin is over the: C:\Program Files\Common Files\Oracle\Java\javapath the vab, works.

BUT, I try one of the v ui examples - calculator.v: vab calculator.v and it successfully generates v_test_app.apk

The calculator.v works fine - small GUI calculator ("v run calculator.v" or even "v calculator.v" to make exe), but when I install v_test_app.apk on emulator and on my smartphone and start it - only black screen appears.

milen-prg commented 1 year ago

Please, can you show some working example of v program, successfully converted to android apk?

larpon commented 1 year ago

@milen-prg you've discovered a regression in V's regex library that was introduced here some days ago. We're looking into it.

larpon commented 1 year ago

@milen-prg try and update V with v up and then rebuild vab with the updated v compiler.

Feel free to open a new issue if the problem persist.

larpon commented 1 year ago

@milen-prg with latest v and vab - this works for me locally with V UI: vab --device auto -f "-d no_load_styles" run ~/.vmodules/ui/examples/calculator_resizable.v For V UI you currently have to pass -f "-d no_load_styles". Otherwise you'll get errors like: folder: /.vui/, error: Read-only file system.

For a normal V example this works: vab --device auto run ~/v/examples/2048

milen-prg commented 1 year ago

@Larpon , I do not know, unfortunately the successfully generated v_test_app.apk file on some devices and emulator shows black screen, on others (most) - closes with message "keep stopping". May be some problem with my android SDK/NDK etc. (I place up the vab doctor log about this), for now vab do not work for me.

larpon commented 1 year ago

Try running it with the --log flag to capture log output. Like this: vab --device auto -f "-d no_load_styles" --log run ~/.vmodules/ui/examples/calculator_resizable.v

milen-prg commented 1 year ago

@Larpon , no log file was created. May be, because, the v_test_app.apk file is successfully created. But when I install this v_test_app.apk in emulator / smartphone, it again displays message "keeps stopping". I uppload this apk in zip archive if you want to try. v_test_app.zip

larpon commented 1 year ago

Thanks, I'll have a look at it soon