Menu

#3 Building APK on Java 1.8 / sdk 25

1.0
open
nobody
None
2017-06-02
2017-05-29
No

Hello,
First of all, deep congrats for the project.

I'm able to compile the example and build its APK with attached build script with java 1.8 and sdk 25 (pretty recent).

The problem I face is: the APK misses manifest file and isn't considered valid when installing on Android. I attached my script in the home someone figures what is wrong with it.

May the force be with you and have fun,
JP.

1 Attachments

Discussion

  • Joao Paulo Schwarz Schuler

    Decided to paste the content of the file here to make it simpler to read:

    REM Run this file as administrator. If running from command line, run "cmd" as administrator.
    REM Adjust these paths to yours
    SET PATH=C:\Android\sdk\tools;C:\Android\sdk\platform-tools\;C:\Android\sdk\build-tools\25.0.2\;"C:\Program Files\Java\jdk1.8.0_102\bin\"
    SET APP_NAME=androidlcltest
    SET ANDROID_HOME=C:\Android\sdk\
    SET BUILD_TOOLS_LIB=C:\Android\sdk\build-tools\25.0.2\lib\
    SET APK_SDK_PLATFORM=C:\Android\sdk\platforms\android-25
    SET APK_PROJECT_PATH="C:\Program Files (x86)\laz4android\examples\androidlcl\android"
    PATH
    pause
    REM Create necessary directory Structure
    mkdir bin
    mkdir bin\classes
    mkdir gen
    mkdir gen\com
    mkdir gen\com\pascal
    mkdir gen\com\pascal\lcltest
    mkdir raw
    mkdir raw\lib
    mkdir raw\lib\armeabi
    
    REM Cleanup
    del bin\%APP_NAME%.ap_
    del bin\%APP_NAME%.apk
    del raw\lib\armeabi\*.so
    
    REM More directory preparation
    copy libs\armeabi\*.so raw\lib\armeabi\
    
    REM Resource compilation
    call aapt p -v -f -M AndroidManifest.xml -F bin\%APP_NAME%.ap_ -I %APK_SDK_PLATFORM%\android.jar -S res -m -J gen raw
    pause
    
    REM Java compiler
    call javac -source 1.6 -target 1.6 -verbose -encoding UTF8 -classpath %APK_SDK_PLATFORM%\android.jar -d bin\classes src\com\pascal\lcltest\LCLActivity.java
    pause
    
    REM Convert the java bytecode to dalvik bytecode
    ::REM For older SDKs: call dx --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes
    call java -Djava.ext.dirs=%BUILD_TOOLS_LIB% -jar %BUILD_TOOLS_LIB%\dx.jar --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes
    pause
    
    REM It seams that dx calls echo off
    @echo on
    REM Now build the unsigned APK
    del %APK_PROJECT_PATH%\bin\%APP_NAME%-unsigned.apk
    aapt add bin\%APP_NAME%-unsigned.apk bin\%APP_NAME%.ap_ bin\classes.dex
    pause
    
    REM If you dont have a key, create one with:
    REM keytool -genkey -v -keystore bin\LCLDebugKey.keystore -alias LCLDebugKey -keyalg RSA -validity 10000
    pause
    
    REM Signing the APK with a debug key
    jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore bin\LCLDebugKey.keystore -keypass senhas -storepass senhas -signedjar bin\%APP_NAME%-unaligned.apk bin\%APP_NAME%-unsigned.apk LCLDebugKey
    pause
    
    REM Align the final APK package
    zipalign -v 4 bin\%APP_NAME%-unaligned.apk bin\%APP_NAME%.apk
    REM FINISHED - If all good, your APK file should be here: bin\%APP_NAME%.apk
    
     
  • Joao Paulo Schwarz Schuler

    Hi,
    I finally have been able to build the APK. Please find attachment.

    I'm able to run in Android 4 but I'm not able to run on Android 7.

    Kind regards,
    JP.

     

Log in to post a comment.

MongoDB Logo MongoDB