Skip to content

Instantly share code, notes, and snippets.

@flamendless
Created October 13, 2021 06:51
Show Gist options
  • Save flamendless/7debba641812c78052a60209b987e1d9 to your computer and use it in GitHub Desktop.
Save flamendless/7debba641812c78052a60209b987e1d9 to your computer and use it in GitHub Desktop.
Love to Android
(This guide is mainly for Windows Users. As for Linux/Mac OS users, this are fairly easy.)
Setting Up:
### Download the Following, place them in a convenient location like C:\AndroidDevelopment\
You will need the following:
Java Development Kit (JDK) Note: Download the one without Netbeans IDE.
Android SDK
Note: Once downloaded, open SDK Manager and Download:
* Tools
* Android SDK Platform-tools
* Android SDK Build-Tools Rev 19.1
* Google Play Services
* Android 4.4.2 (API 19 and 23 are the minimum versions)
* SDK Platform
* ARM EABI v7a System Image
* Google APIs
* Sources for Android SDK
* Extras
* Android Support Repository
* Google USB driver
Android NDK (DOWNLOAD r19c! (Stable) here)
Gradle
And then git clone the repo.
Configure your paths.
To add in System Paths: Right Click My Computer/This PC -> Properties -> Advance System Settings -> Environment Variables ->
Under System variables:
`Click New, then "Name", Path` (Paths are subject to change, depending on your directory)
+ new "ANDROID_HOME" -> C:\AndroidDevelopment\Android\sdk
+ new "ANDROID_NDK" -> C:\AndroidDevelopment\android-ndk-xxx\
+ new "ANDROID_SDK" -> C:\AndroidDevelopment\Android\sdk
Then double click PATH under System variables, add a new line, and directory for gradle
RUN test!
Navigate to the repo's root folder, i.e C:\AndroidDevelopment\love2d-admob-sdl2
Open local.properties file and edit
ndk.dir=C:\AndroidDevelopment\android-ndk-xxx\
sdk.dir=C:\AndroidDevelopment\Android\sdk
Open a command prompt, go in the repo's directory.
Run gradlew build
Wait for it to finish, it should run into any error. If so, please let me know. After it is finished successfully, you can see a .apk file in app/build/output/apk/, try that on your phone.
Adding your game!
You can put your game.love file inside /app/src/main/assets/ folder, if assets is not present, create one.
Open build.gradle file in /app/ and make relevant changes to defaultConfig
IMPORTANT:
in this example, we will use the package com.myawesome.flam, you ofcourse change that into your own.
Open AndroidManifest.xml in your app/src/main folder.
Edit the following:
<manifest package="com.myawesome.flam" <= very important, you can change that package, be consistent.
Under <application, change android:label into your game's name. Also change the one under the <activity.
also under that, change android:name into something like: MyAwesomeGameActivity
android:screenOrientation, either "portrait", "landscape", "sensorLandscape", etc.
change applicationId with your package name, ie com.myawesomegame.flam
Also, create that structure in /love/src/main/java/
So in my example, it would be /love/src/main/java/com/myawesomegame/flam/
inside that subdirectory, create the file MyAwesomeGameActivity.java. Open that file, and change the following:
after package into com.myawesomegame.flam
after public class , the name of your FILE and your android:label, which in this example is MyAwesomeGameActivity
Don't forget to save your changes.
Then run gradlew build again to see build and generate your apk :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment