## Guide: Building love-native-android

A project to port LÖVE to Android handhelds
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

### Guide: Building love-native-android

This thread is intended to be a guide for how to build love-native-android as it is right now, for testing purposes.

This guide will assume no prior knowledge of Eclipse or Android development. If I forget this in some step, just tell me and I'll fix it. The goal is that anyone who want to test their LÖVE game on Android should be able to follow this guide.

If another similar guide exists somewhere, please tell me about it.

Step 1: Install Eclipse
On Ubuntu, it's simply sudo apt-get install eclipse. On any other OS, head over to eclipse.org and download the latest version. The one called "Classic Eclipse" is recommended by google.

Step 2: Get the Android SDK
If you're on Windows, there's an installer that is recommended.

Step 3: Get the ADT plugin for Eclipse
Start up Eclipse. Go to "Help" -> "Install new Software"
Where it says "Work with:", click on the arrow facing down to see what sources you have. The ADT plugin has some dependencies so you have to make sure there's somewhere it can get those from. If you don't see anything that does this, click on "Add..." and pick a name ("Indigo"), and under "Location" type "http://download.eclipse.org/releases/indigo" (assuming the version of Eclipse you are using is Indigo).
Then add another one ("Add..."), called "ADT plugin" with the location "https://dl-ssl.google.com/android/eclipse/". Now, you should see "Developer Tools" below. Mark that, and make sure "Contact all update sites during install to find required software" is marked, and hit "Next". Follow the instructions.
Once installed, click on the button that looks like an Android sitting on a box with a white arrow on it (it's called "Opens the Android SDK Manager"). Download at least one Android version. At the time of writing, API 8 (Android 2.2) is necessary to have.

If you want an Android Emulator, find the button in Eclipse that looks like an Android inside of a Android phone (it's called "Opens the Android Virtual Device Manager") Create an Android emulator, based on the Android version chosen before. LÖVE games don't really work in the emulator so it's a bit pointless.

Step 4: Get the love-native-android source
Head over to https://github.com/hagish/love-native-android and download it. The button says "zip".
Start up Eclipse, and hit "File"->"New" -> "Android Project". Give it a name, "LoveNative", and choose "Create project from existing source". Choose the location of the love-native-android source. Click OK.

Step 5: Get and apply the NDK
In Eclipe, right click on "LoveNative" and hit "Properties". Under "Builders", make sure there's one called "ndk-build". Mark it and hit "Edit". Make sure the "Location" looks at the file ndk-build inside the NDK (it probably doesn't). Also make sure the "Working Directory" looks at the folder "jni" inside your project. Hit "Ok".

Step 6: Build and run!
Right click on your project (LoveNative) and under Android Tools, choose Export Signed Application Package. Follow the instructions. Send the .apk file to your phone/tablet and test it!

Step 7: ???

Step 8: PROFIT!

Old version:

Code: Select all


[b]Step 1: Install Eclipse[/b]
On Ubuntu, it's simply sudo apt-get install eclipse. On any other OS, head over to eclipse.org and download the latest version. The one called "Classic Eclipse" is recommended by google.

[b]Step 2: Get the Android SDK[/b]
If you're on Windows, there's an installer that is recommended.

[b]Step 3: Get the ADT plugin for Eclipse[/b]
Start up Eclipse. Go to "Help" -> "Install new Software"
Where it says "Work with:", click on the arrow facing down to see what sources you have. The ADT plugin has some dependencies so you have to make sure there's somewhere it can get those from. If you don't see anything that does this, click on "Add..." and pick a name ("Indigo"), and under "Location" type "http://download.eclipse.org/releases/indigo" (assuming the version of Eclipse you are using is Indigo).
Then add another one ("Add..."), called "ADT plugin" with the location "https://dl-ssl.google.com/android/eclipse/". Now, you should see "Developer Tools" below. Mark that, and make sure "Contact all update sites during install to find required software" is marked, and hit "Next". Follow the instructions.
Once installed, click on the button that looks like an Android sitting on a box with a white arrow on it (it's called "Opens the Android SDK Manager"). Download an Android version, for example the latest (4.0.3 at the time of writing).
Find the button in Eclipse that looks like an Android inside of a Android phone (it's called "Opens the Android Virtual Device Manager") Create an Android emulator, based on the Android version chosen before.

[b]Step 4: Get the love-native-android source[/b]
Head over to https://github.com/hagish/love-native-android and download it. The button says "zip".
Start up Eclipse, and hit "File"->"New" -> "Android Project". Give it a name, "LoveNative", and choose "Create project from existing source". Choose the location of the love-native-android source. Click OK.

[b]Step 5: Change the source code to look for your .love file[/b]
Under "LoveNative" -> "jni", open "love.cpp". Look for these lines:
[code]
argv[1] = new char[strlen("/mnt/sdcard/love/iyfct")+1];
strcpy(argv[1], "/mnt/sdcard/love/iyfct");

Change them to wherever you want your .love file to be. Save and close.
In order to get your .love file in the emulator, I suggest opening up the Android web browser inside of the emulator and download a file manager, for example OI File Manager (just google it), as well as your .love, and use the file manager to place your .love where you want it. I suggest /mnt/sdcard/love/yourlovehere.love

Step 6: Get and apply the NDK
In Eclipe, right click on "LoveNative" and hit "Properties". Under "Builders", make sure there's one called "ndk-build". Mark it and hit "Edit". Make sure the "Location" looks at the file ndk-build inside the NDK (it probably doesn't). Also make sure the "Working Directory" looks at the folder "jni" inside your project. Hit "Ok".

Step 7: Build and run!
First, we need to change a little thing: In the folder "jni", open "Android.mk". On line 731, it says "LOCALCFLAGS := ...". Add "-fexceptions" to those flags. Save and close.
Right click on your project (LoveNative) and under "Run as..." choose "Android Application". It takes a while to compile all the stuff.

Step 8: ???
The app dies when you try to run it.
Note: In order to get it to install, you may need to give the emulator more memory. The app is 6 MB installed. To do this, right click on the project, under "Run As..." hit "Run Configurations". In the tab "Target", mark your Android emulator, and under "Additional Emulator Command Line Options" write "-partition-size 512".
However, this doesn't really matter since love-native-android doesn't support the OpenGLES version used by the emulator. If you, however, sign the app as an apk and install it on an actual Android phone, it should work now.

Step 9: PROFIT!
[/code]
Last edited by T-Bone on Fri May 25, 2012 5:22 pm, edited 12 times in total.

thelinx
The Strongest
Posts: 848
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

### Re: Building love-native-android

T-Bone wrote: Issue: The NDK gives a compilation error at this point when compiling devil

Code: Select all

/home/t-bone/android/hagish-love-native-android-2083f75-2/jni/devil-1.7.8/src-IL/src/il_utx.cpp: In function 'ILboolean ilLoadUtxF(void*)':
/home/t-bone/android/hagish-love-native-android-2083f75-2/jni/devil-1.7.8/src-IL/src/il_utx.cpp:50: error: exception handling disabled, use -fexceptions to enable
Seems like a fairly obvious solution.

T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

### Re: Building love-native-android

thelinx wrote:
T-Bone wrote: Issue: The NDK gives a compilation error at this point when compiling devil

Code: Select all

/home/t-bone/android/hagish-love-native-android-2083f75-2/jni/devil-1.7.8/src-IL/src/il_utx.cpp: In function 'ILboolean ilLoadUtxF(void*)':
/home/t-bone/android/hagish-love-native-android-2083f75-2/jni/devil-1.7.8/src-IL/src/il_utx.cpp:50: error: exception handling disabled, use -fexceptions to enable
Seems like a fairly obvious solution.
I tried it, didn't help. The terminal writes:

Code: Select all

make: exceptions: Filen eller katalogen finns inte
make: *** Ingen regel för att skapa målet "exceptions".  Stannar.

Translation:

Code: Select all

make: exceptions: The file or the calatogue does not exist
make: *** No rule for creating the goal "exceptions". Stopping.

Not sure if I'm doing it right though. What I do is to right click on the project, hit Properties, Builders, Edit ndk-build, and under arguments, I write "-fexceptions".

thelinx
The Strongest
Posts: 848
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

### Re: Building love-native-android

You're giving the argument to the make command, which is incorrect. I'm not sure how (in NDK), but you need to give the argument as a CFLAG (to the compiler).

Is Android.mk automatically generated? If not, try adding -fexceptions to line 731.

T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

### Re: Building love-native-android

thelinx wrote:You're giving the argument to the make command, which is incorrect. I'm not sure how (in NDK), but you need to give the argument as a CFLAG (to the compiler).

Is Android.mk automatically generated? If not, try adding -fexceptions to line 731.
You sir, are a genius.

kalle2990
Party member
Posts: 245
Joined: Sat Sep 12, 2009 1:17 pm
Location: Sweden

### Re: Guide: Building love-native-android

It appears that love-native-android cannot be compiled on Windows with the current version of the NDK.

When compiling on Windows, the compiler fails with this exception

Code: Select all

Unhandled exception filter called from program C:\Users\Patrik\android-ndk-r7b\\prebuilt\windows\bin\make.exe
ExceptionCode = c00000fd
ExceptionFlags = 0
ExceptionAddress = 420942
This has something to do with the NDK, and I found this issue tracker which has a little more information. There appears to be no solution yet though

T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

### Re: Guide: Building love-native-android

kalle2990 wrote:It appears that love-native-android cannot be compiled on Windows with the current version of the NDK.

When compiling on Windows, the compiler fails with this exception

Code: Select all

Unhandled exception filter called from program C:\Users\Patrik\android-ndk-r7b\\prebuilt\windows\bin\make.exe
ExceptionCode = c00000fd
ExceptionFlags = 0
ExceptionAddress = 420942
This has something to do with the NDK, and I found this issue tracker which has a little more information. There appears to be no solution yet though
No idea why this happens. If you want me to build one for you, just specify the name and location of your .love file

If you're worrying specifically about building love-native-android on Windows, I can't help you Sorry.

kalle2990
Party member
Posts: 245
Joined: Sat Sep 12, 2009 1:17 pm
Location: Sweden

### Re: Guide: Building love-native-android

T-Bone wrote: No idea why this happens. If you want me to build one for you, just specify the name and location of your .love file

If you're worrying specifically about building love-native-android on Windows, I can't help you Sorry.
It's fine, I was just going to experiment with a .love open dialog and implementing .love files so that they were connected to the application when clicking a downloaded file

I guess I'm going to wait a little with that untill Google fixes the compiler, or I might just download Eclipse to my virtual machine running Ubuntu. But thanks anyway

kalle2990
Party member
Posts: 245
Joined: Sat Sep 12, 2009 1:17 pm
Location: Sweden

### Re: Guide: Building love-native-android

I decided to update both my Ubuntu version and download Eclipse to my virtual box, so I got development up and running!

Just thought I'd give you a little progress update with the file selection,
• I have gotten launching from any file explorer working fine enough (will look into this some other day. Some file explorers has more advanced options for opening, like selecting multiple items from multiple menus. I think this has with .love files not keeping any mime-type, but I'm not sure.)
• When a file isn't selected, the default no-game screen is shown.
• (Next task) Replace the launcher activity with a .love chooser, should be much easier than figuring out the file mess I struggled with.
Also there seems to be a bug in projects where love.audio is included, making them un-openable from time to time.

T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

### Re: Guide: Building love-native-android

kalle2990 wrote:I decided to update both my Ubuntu version and download Eclipse to my virtual box, so I got development up and running!

Just thought I'd give you a little progress update with the file selection,
• I have gotten launching from any file explorer working fine enough (will look into this some other day. Some file explorers has more advanced options for opening, like selecting multiple items from multiple menus. I think this has with .love files not keeping any mime-type, but I'm not sure.)
• When a file isn't selected, the default no-game screen is shown.
• (Next task) Replace the launcher activity with a .love chooser, should be much easier than figuring out the file mess I struggled with.
Also there seems to be a bug in projects where love.audio is included, making them un-openable from time to time.
That's interesting to hear. Love-audio also crashes during gameplay sometimes (i.e. music/sounds stops playing).

I personally think that having semi-buggy launching from file explorers is fine, since running love-native-android this way is intended for developers and not end-consumers.

And one last thing: other than your first sentence, this post probably belongs in the other thread.

### Who is online

Users browsing this forum: No registered users and 13 guests