[tool] LoveToAndroid - .love to .apk without thinking

Showcase your libraries, tools and other projects that help your fellow love users.
rayaman
Prole
Posts: 10
Joined: Sat May 17, 2014 6:18 pm

Re: [tool] LoveToAndroid - .love to .apk without thinking

Post by rayaman »

Wow this is amazing! Thanks so much no more head banging for me :)
laperen
Prole
Posts: 27
Joined: Tue Jul 26, 2016 1:15 am

Re: [tool] LoveToAndroid - .love to .apk without thinking

Post by laperen »

anyone have more detailed instructions on how to change the game name and id? I was editing the make-apk.bat. I was only able to change the apk name. changing anything else "that starts with sed" either made the apk assume there was no game, showing the super-toast screen, or outright refuse to run.
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: [tool] LoveToAndroid - .love to .apk without thinking

Post by qubodup »

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:

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
The important line for you is:

Code: Select all

tools\sed-win\bin\sed -i "s/loveToAndroid Game/Game %datevar%/g" tools\love-android-sdl2\AndroidManifest.xml
If you game is called "Blueberry Escape", change it to:

Code: Select all

tools\sed-win\bin\sed -i "s/loveToAndroid Game/Blueberry Escape/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

      android:label="loveToAndroid Game"
And replace "loveToAndroid Game" with your game name (be careful not to remove anything else, one " less and the file is broken :)

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.
Last edited by qubodup on Mon Aug 08, 2016 10:28 pm, edited 1 time in total.
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: [tool] LoveToAndroid - .love to .apk without thinking

Post by qubodup »

scissors61 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
@scissors61: Here is successful output on 64bit Linux

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
Your issue might be the result of other android dev activity. Try temporarily renaming or removing your ~/.android/ directory (solution from http://stackoverflow.com/questions/1115 ... pplication ):

Code: Select all

mv ~/.android/ ~/.android-bak/
Another idea: Try uninstalling (or temporarily renaming) your locally installed Android SDK.

Are you on 32 or 64 bit Linux?
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
laperen
Prole
Posts: 27
Joined: Tue Jul 26, 2016 1:15 am

Re: [tool] LoveToAndroid - .love to .apk without thinking

Post by laperen »

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:

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
The important line for you is:

Code: Select all

tools\sed-win\bin\sed -i "s/loveToAndroid Game/Game %datevar%/g" tools\love-android-sdl2\AndroidManifest.xml
If you game is called "Blueberry Escape", change it to:

Code: Select all

tools\sed-win\bin\sed -i "s/loveToAndroid Game/Blueberry Escape/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

      android:label="loveToAndroid Game"
And replace "loveToAndroid Game" with your game name (be careful not to remove anything else, one " less and the file is broken :)

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.
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.
User avatar
scissors61
Citizen
Posts: 76
Joined: Fri Jan 08, 2016 10:16 am

Re: [tool] LoveToAndroid - .love to .apk without thinking

Post by scissors61 »

Thanks @qubodup for your reply. I'm on Linux 32 bit. A long time ago, before even knowing löve, I unsuccessfully tried to learn Java programming for Android. By that time I could find the SDK for Linux 32 bit, and the files stayed. Right now I can't install SDK for Linux 32 again, but I thought that it was included in your package. 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.
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: [tool] LoveToAndroid - .love to .apk without thinking

Post by qubodup »

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.
Try:

Code: Select all

sudo chmod -R 777 ~/.android
(from http://stackoverflow.com/a/8783686/188159 )

Or:

Code: Select all

cd ~/.android
keytool -keygen -v -keystore debug.keystore -alias androiddebugkey -storepass android
(from http://stackoverflow.com/a/14078157/188159 )

Or add

Code: Select all

export ANDROID_SDK_HOME="$PWD/tools/android-linux"
under line 16 in make-apk.sh
(from http://stackoverflow.com/a/12362172/188159 )

Another thing to try: move or copy the startgamedev folder to your home or Desktop to shorten the path and try again (seems more of a possible DOS problem though ^^)

PS: yes, you don't have to install Android SDK for StartGameDev. Reading your post, I thought that you did install it just fro StartGameDev though. But when all the ANDROID_... variables are set, the other installation (if there is one) shouldn't be in the way.
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
User avatar
scissors61
Citizen
Posts: 76
Joined: Fri Jan 08, 2016 10:16 am

Re: [tool] LoveToAndroid - .love to .apk without thinking

Post by scissors61 »

Sadly, no results. Couldn't do your second suggestion, it says something like keygen is not an allowed option. Something that I notice is that start-game.sh doesn't start the game. Only a black screen appears.
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: [tool] LoveToAndroid - .love to .apk without thinking

Post by qubodup »

scissors61 wrote:Something that I notice is that start-game.sh doesn't start the game. Only a black screen appears.
No problem, that's for the tutorial in which you write a game inside Game/.
scissors61 wrote:Sadly, no results. Couldn't do your second suggestion, it says something like keygen is not an allowed option.
Ok, looks like that might have been a command for an older Java.

I learned a lot today. The package requires JDK and JRE 8 (1.8) when used on Linux unfortunately. But it would have been too nice if Linux portability would have been possible easily.

If you run java -version, you will probably see 1.7.

What I had to do to make this work on a 64bit Ubuntu 4.2.0-16-generic virtual machine:

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
and then make-apk.sh works.

It might be possible to download JDK from sun's website of the version you have, and replace the folders in tools/. No guarantees.
Last edited by qubodup on Fri Aug 12, 2016 7:57 am, edited 1 time in total.
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
User avatar
scissors61
Citizen
Posts: 76
Joined: Fri Jan 08, 2016 10:16 am

Re: [tool] LoveToAndroid - .love to .apk without thinking

Post by scissors61 »

It worked! I installed first JDK 8 on my system, and no luck. Then I did what you told me about downloading JDK from sun's website and replace the files in tools, and that did the trick! Thanks for your assistance and for this great tool.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests