Re: [tool] LoveToAndroid - .love to .apk without thinking
Posted: Fri Aug 05, 2016 10:25 pm
Wow this is amazing! Thanks so much no more head banging for me
Code: Select all
@echo off
rem get date and hope no participants compile at the same second
set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
rem echo hour=%hour%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
rem echo min=%min%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
rem echo secs=%secs%
rem set year=%date:~-2,2%
rem echo year=%year%
set month=%date:~3,2%
if "%month:~0,1%" == " " set month=0%month:~1,1%
rem echo month=%month%
set day=%date:~0,2%
if "%day:~0,1%" == " " set day=0%day:~1,1%
rem echo day=%day%
set datevar=%month%%day%%hour%%min%%secs%
rem rem make android ID and name unique so we can have multiple installs
rem restore original manifest and src subdir
copy tools\love-android-sdl2\original\AndroidManifest.xml tools\love-android-sdl2\
rd tools\love-android-sdl2\src\love /s/q
xcopy tools\love-android-sdl2\original\love tools\love-android-sdl2\src\love /e/i
rem replace id, name and src subdir
tools\sed-win\bin\sed -i "s/loveToAndroid Game/Game %datevar%/g" tools\love-android-sdl2\AndroidManifest.xml
tools\sed-win\bin\sed -i "s/love.to.android/love\.to\.android%datevar%/g" tools\love-android-sdl2\AndroidManifest.xml
tools\sed-win\bin\sed -i "s/love.to.android/love\.to\.android%datevar%/g" tools\love-android-sdl2\src\love\to\android\LtaActivity.java
move tools\love-android-sdl2\src\love\to\android tools\love-android-sdl2\src\love\to\android%datevar%
REM remove files sed creates (4 year old bug as of 2015)
del sed* /q
REM set variables
setlocal
set ANT_HOME=%~dp0\tools\ant
set JAVA_HOME=%~dp0\tools\jdk-win
set ANDROID_HOME=%~dp0\tools\android-win
set PATH=%PATH%;%ANT_HOME%\bin
REM cd and remove previoius output
del game.apk /q
cd tools\love-android-sdl2
rd gen /s/q
rd bin /s/q
REM easier game copying
IF EXIST ..\..\game.love (
del assets\game.love
copy ..\..\game.love assets\game.love
)
REM easier icon copying
IF EXIST ..\..\icon.png (
del res\drawable-xxhdpi\ic_launcher.png
copy ..\..\icon.png res\drawable-xxhdpi\ic_launcher.png
)
REM compile and move
call ant debug
copy bin\love_android_sdl2-debug.apk ..\..\game.apk
echo.
echo Press any key to close
pause >nul
Code: Select all
tools\sed-win\bin\sed -i "s/loveToAndroid Game/Game %datevar%/g" tools\love-android-sdl2\AndroidManifest.xml
Code: Select all
tools\sed-win\bin\sed -i "s/loveToAndroid Game/Blueberry Escape/g" tools\love-android-sdl2\AndroidManifest.xml
Code: Select all
android:label="loveToAndroid Game"
@scissors61: Here is successful output on 64bit Linuxscissors61 wrote:Code: Select all
/home/pedro/Desktop/guardar/software/love2apk/StartGamedev-160604-linux/tools/android-linux/tools/ant/build.xml:312: com.android.sdklib.build.ApkCreationException: Unable to get debug signature key
Code: Select all
$ ./make-apk.sh
rm: cannot remove 'game.apk': No such file or directory
rm: cannot remove 'bin': No such file or directory
Buildfile: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 24.3.4
[checkenv] Installed at /home/qubodup/StartGamedev-160804-linux/tools/android-linux
-setup:
[echo] Project Name: love_android_sdl2
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 19.1.0
[echo] Resolving Build Target for love_android_sdl2...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin
[mkdir] Created dir: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/res
[mkdir] Created dir: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/rsObj
[mkdir] Created dir: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/rsLibs
[mkdir] Created dir: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/gen
[mkdir] Created dir: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/classes
[mkdir] Created dir: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/dexedLibs
[echo] ----------
[echo] Resolving Dependencies for love_android_sdl2...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
[echo] ----------
[echo] Building Libraries with 'debug'...
[subant] No sub-builds to iterate on
-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.
-pre-compile:
-compile:
[javac] Compiling 7 source files to /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/classes
[javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
[javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
[javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
[javac] Note: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/src/org/libsdl/app/SDLActivity.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 3 warnings
-post-compile:
-obfuscate:
-dex:
[dex] input: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/classes
[dex] Converting compiled files and external libraries into /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/classes.dex...
-crunch:
[crunch] Crunching PNG Files in source dir: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/res
[crunch] To destination dir: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/res
[crunch] Processing image to cache: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/res/drawable-xxhdpi/ic_launcher.png => /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/res/drawable-xxhdpi/ic_launcher.png
[crunch] (processed image to cache entry /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/res/drawable-xxhdpi/ic_launcher.png: 80% size of source)
[crunch] Crunched 1 PNG files to update cache
-package-resources:
[aapt] Creating full resource package...
-package:
[apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[apkbuilder] Creating love_android_sdl2-debug-unaligned.apk and signing it with a debug key...
-post-package:
-do-debug:
[zipalign] Running zip align on final apk...
[echo] Debug Package: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/love_android_sdl2-debug.apk
[propertyfile] Creating new property file: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/build.prop
[propertyfile] Updating property file: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/build.prop
[propertyfile] Updating property file: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/build.prop
[propertyfile] Updating property file: /home/qubodup/StartGamedev-160804-linux/tools/love-android-sdl2/bin/build.prop
-post-build:
debug:
BUILD SUCCESSFUL
Total time: 10 seconds
Code: Select all
mv ~/.android/ ~/.android-bak/
Thank you for the response. I think as far as my small project is concerned changing the game name will suffice. I will follow up on changing the ID in future. thanks again.qubodup wrote:laperen: sure, I wrote some more details in the description of the android video on YouTube but let me make a more thorough explanation here.
It seems that if you install two apps with the same name, this can cause installation to fail on some systems unless you uninstall the previous version. I'm guessing it's a safety feature.
For this reason, for speedy development, I made the game name change constantly based on date/time.
I added a keyword to the manifest.xml (the file that defines things like name or orientation of the game), which is then replaced using the command line tool sed.
To change the name in the current version of make-apk.bat, as seen below:The important line for you is:Code: Select all
@echo off rem get date and hope no participants compile at the same second set hour=%time:~0,2% if "%hour:~0,1%" == " " set hour=0%hour:~1,1% rem echo hour=%hour% set min=%time:~3,2% if "%min:~0,1%" == " " set min=0%min:~1,1% rem echo min=%min% set secs=%time:~6,2% if "%secs:~0,1%" == " " set secs=0%secs:~1,1% rem echo secs=%secs% rem set year=%date:~-2,2% rem echo year=%year% set month=%date:~3,2% if "%month:~0,1%" == " " set month=0%month:~1,1% rem echo month=%month% set day=%date:~0,2% if "%day:~0,1%" == " " set day=0%day:~1,1% rem echo day=%day% set datevar=%month%%day%%hour%%min%%secs% rem rem make android ID and name unique so we can have multiple installs rem restore original manifest and src subdir copy tools\love-android-sdl2\original\AndroidManifest.xml tools\love-android-sdl2\ rd tools\love-android-sdl2\src\love /s/q xcopy tools\love-android-sdl2\original\love tools\love-android-sdl2\src\love /e/i rem replace id, name and src subdir tools\sed-win\bin\sed -i "s/loveToAndroid Game/Game %datevar%/g" tools\love-android-sdl2\AndroidManifest.xml tools\sed-win\bin\sed -i "s/love.to.android/love\.to\.android%datevar%/g" tools\love-android-sdl2\AndroidManifest.xml tools\sed-win\bin\sed -i "s/love.to.android/love\.to\.android%datevar%/g" tools\love-android-sdl2\src\love\to\android\LtaActivity.java move tools\love-android-sdl2\src\love\to\android tools\love-android-sdl2\src\love\to\android%datevar% REM remove files sed creates (4 year old bug as of 2015) del sed* /q REM set variables setlocal set ANT_HOME=%~dp0\tools\ant set JAVA_HOME=%~dp0\tools\jdk-win set ANDROID_HOME=%~dp0\tools\android-win set PATH=%PATH%;%ANT_HOME%\bin REM cd and remove previoius output del game.apk /q cd tools\love-android-sdl2 rd gen /s/q rd bin /s/q REM easier game copying IF EXIST ..\..\game.love ( del assets\game.love copy ..\..\game.love assets\game.love ) REM easier icon copying IF EXIST ..\..\icon.png ( del res\drawable-xxhdpi\ic_launcher.png copy ..\..\icon.png res\drawable-xxhdpi\ic_launcher.png ) REM compile and move call ant debug copy bin\love_android_sdl2-debug.apk ..\..\game.apk echo. echo Press any key to close pause >nul
If you game is called "Blueberry Escape", change it to:Code: Select all
tools\sed-win\bin\sed -i "s/loveToAndroid Game/Game %datevar%/g" tools\love-android-sdl2\AndroidManifest.xml
Alternatively, you can go to StartGamedev-160804-win/tools/love-android-sdl2/original/ and edit the AndroidManifest.xml file there, find the two lines that contain the following:Code: Select all
tools\sed-win\bin\sed -i "s/loveToAndroid Game/Blueberry Escape/g" tools\love-android-sdl2\AndroidManifest.xml
And replace "loveToAndroid Game" with your game name (be careful not to remove anything else, one " less and the file is brokenCode: Select all
android:label="loveToAndroid Game"
PS: as for the ID, this is a bit more tricky. You will have to replace every instance of love\.to\.android%datevar% in the script (use ctrl+f in notepad++ or another editor that is not notepad which is too basic to allow keeping track of ugly files) and make sure the right folders exist in StartGamedev-160804-win/tools/love-android-sdl2/src.
Try:scissors61 wrote:I followed your suggestions of deleting old files and renaming folders, but I still can't do anything... the same error you pointed out appears.
Code: Select all
sudo chmod -R 777 ~/.android
Code: Select all
cd ~/.android
keytool -keygen -v -keystore debug.keystore -alias androiddebugkey -storepass android
Code: Select all
export ANDROID_SDK_HOME="$PWD/tools/android-linux"
No problem, that's for the tutorial in which you write a game inside Game/.scissors61 wrote:Something that I notice is that start-game.sh doesn't start the game. Only a black screen appears.
Ok, looks like that might have been a command for an older Java.scissors61 wrote:Sadly, no results. Couldn't do your second suggestion, it says something like keygen is not an allowed option.
Code: Select all
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install openjdk-8-jre-headless
sudo apt-get install openjdk-8-jdk