Hello, thank to the advices and hints given here, i’ve managed to sort out Android apk generation.
I’d like to add this to the wiki, but? where is the wiki ?
The closest subject i’ve found is the building instructions:
urho3d.github.io/documentation/H … lding.html
So, i post in this topic for the moment.
All instructions are for Linux environment.
[size=200]Android: building your own Urho3DPlayer package[/size]
We want to use Urho3DPlayer on Android, for AngelScript or Lua execution.
Before all, you will need to build the Urho3D library for Android.
This part is well explained in Urho3D documentation (short version: use cmake_gcc.sh).
We are going to use the first Lua demo (01_HelloWorld.lua).
As it’s just for packaging demo purpose, the simpler, the better.
[size=150]Preparing project files and directories[/size]
At first, create a new directory for hosting all the needed files.
~/projects/urho3d$ mkdir hello_droid
Now go to the root of Urho3D sources.
We are using ?rake? tool for generating a blank project.
Usage: rake scaffolding dir=/path/to/new/project/root [project=your-project-name] [target=your-target-name]' unless ENV['dir']
Default paramters, if nothing given on command-line:
project = ENV[‘project’] || 'Scaffolding’
target = ENV[‘target’] || ‘Main’
Notice that “rake scaffolding” simply copies the Urho3DPlayer.cpp and
Urho3DPlayer.h there as placeholders. Normally, you should replace these two
files with your own project source files. But for you case, you can leave them
because that is exactly what you want.
~/sources/Urho3D$ rake scaffolding dir=~/projects/urho3d/hello_droid/ project=hello_my_droid
New project created in /home/zakk/projects/urho3d/hello_droid
To build the new project, you may need to first define and export either 'URHO3D_HOME' or 'CMAKE_PREFIX_PATH' environment variable
Please see http://urho3d.github.io/documentation/_using_library.html for more detail. For example:
$ URHO3D_HOME=/home/zakk/sources/Urho3D; export URHO3D_HOME
$ cd /home/zakk/projects/urho3d/hello_droid
$ ./cmake_gcc.sh -DURHO3D_64BIT=1 -DURHO3D_LUAJIT=1
$ cd Build
Let’s go back in our project’s location:
~/projects/urho3d/hello_droid$ export URHO3D_HOME=/home/zakk/sources/Urho3D
~/projects/urho3d/hello_droid$ ./cmake_gcc.sh -DURHO3D_LUA=1
At the end of cmake_gcc.sh execution, you will see:
failed to create symbolic link ‘Source/Android/assets/CoreData’: No such file or directory
failed to create symbolic link ‘Source/Android/assets/Data’: No such file or directory
That’s okay. It’s your duty to fill Source with code and data.
Well let’s begin with creating ?Android? in the Source directory.
After that, some cleaning in ?Bin?: I choose to erase the symlinks to CoreData and Data (point to the Urho3D sources). CoreData and Data will be put directly in Android/assets, as ?true? directories.
~/projects/urho3d/hello_droid/Bin$ rm CoreData
~/projects/urho3d/hello_droid/Bin$ rm Data
Populating Source directory:
~/projects/urho3d/hello_droid/Source$ mkdir Android
~/projects/urho3d/hello_droid/Source$ mkdir Android/assets
~/projects/urho3d/hello_droid/Source$ mkdir Android/assets/CoreData
~/projects/urho3d/hello_droid/Source$ mkdir Android/assets/Data
~/projects/urho3d/hello_droid/Source$ mkdir Android/res
~/projects/urho3d/hello_droid/Source$ mkdir Android/src
I’ve copied the whole content of:
in res and src of hello_droid.
res/ : contains icons and paramaters (app behaviour, app name?).
src/ : Java sources used for doing the link with the NDK (the JNI).
assets/ : all that’s related with Urho3D (Lua scripts, data).
What to put in ?assets? ?
Scripts must go to Data/LuaScripts.
You must also modify Data/CommandLine.txt, for putting name and location of the script to launch with Urho3DPlayer.
~/projects/urho3d/hello_droid/Bin$ cat Source/Android/assets/Data/CommandLine.txt
You have to create or copy (which is easier) the file AndroidManifest.xml.
Its purpose is to be used as config file for ant. It’s a sort of Makefile generator.
Put it at the root of Android’s sources.
Now, we have:
~/projects/urho3d/hello_droid$ ls -1FX Source/Android/
[size=150]Creating ant environment[/size]
~/projects/urho3d/hello_droid/android-Build$ android update project -p . -t 1
Updated and renamed default.properties to project.properties
Added file ./proguard-project.txt
android update project will be necessary only one time.
Note that you must redo this operation if AndroidManifest.xml is modified.
For changing the APK filename:
Change first line of build.xml :
it becomes :
This will only change the APK filename. The name of the application (as seen on your phone screen) won’t be changed.
Neither will the unique name of the package. See the name with adb shell pm list packages -3. By default, it’s com.github.urho3d.
Now that we have everything configurated, we can build the Uhro player, and generating the package.
Scanning dependencies of target Main
[ 50%] Building CXX object CMakeFiles/Main.dir/Urho3DPlayer.cpp.o
[100%] Building C object CMakeFiles/Main.dir/home/zakk/sources/Urho3D/Source/ThirdParty/SDL/src/main/android/SDL_android_main.c.o
Linking CXX shared library libs/armeabi-v7a/libMain.so
Stripping libMain.so in library output directory
[100%] Built target Main
~/projects/urho3d/hello_droid/android-Build$ ls libs/armeabi-v7a/libMain.so -lh
-rwxr-xr-x 1 zakk zakk 6,8M 17 ao?t 20:18 libs/armeabi-v7a/libMain.so
[size=150]Creating the APK[/size]
~/projects/urho3d/hello_droid/android-Build$ ant debug
Now, we can send the package to an emulator, or an android-phone.
~/projects/urho3d/hello_droid/android-Build$ adb install -r bin/hello_droid-debug.apk
3595 KB/s (3446988 bytes in 0.936s)
For getting logs, and solve more easily the problems which will rise for sure:
$ adb logcat -c # just before launching your app. It cleans the logs.
$ adb logcat # then, launch your app.
Well, i hope that it will help somebody. I had myself serious troubles figuring out how to create an APK with Urho3D scripts. WIth that, it should be easier for you