2. First Program!

Chapters

ARSA Framework starting with application wizard, user must do follow instruction.

            2.1 Go folder C:/arsa

            2.2 Copy folder ARSA_AppWiz100 to any location if you want. Make sure absolute path don't have space! 

            2.3 Rename a copies folder ARSA_AppWiz100 to your game name (F2 or right click -> rename ).

                        2.3.1 Folder name, play as rule of define variable (No space, first is alphabet) because ARSA Framework must use that name as name of android application display on real device and name of apk package.

            2.4 Run on emulator, Open vc++ project file.

                        2.4.1 [projectfolder]/win32/ARSA_AppWiz100.vcxproj (ARSA_AppWiz100_2008.vcproj for vs2008) 

If Visual Studio ask you want to convert project click Ok or Yes.

                        2.4.2 Build project

                                    A.) F7 or Build -> Build Solution, some machine shortcut is Ctrl+Shift+B

                        2.4.3 Run project on emulator

                                    A.) F5 or Debug -> Start Debugging

                        2.4.4 If you see gray color on screen hooray! you successes!!!

NOTE:

                        A.) Vc++ tell error same below.

error MSB8020: The build tools for Visual Studio 2012 (Platform Toolset = 'v110') cannot be found. To build using the v110 build tools, please install Visual Studio 2012 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Upgrade Solution...".

                                It's mean your version of vc++ not correct because original arsa app wiz compiled on vc++ 2012 but current vc++ on your machine is not, Solution: (Choose one)

                                     A1.) Looking Solution Explorer and right click at project name -> Upgrade VC++ Compiler and Libraries -> OK and try compile again.

                                     A2.) Go to change platform toolset in project properties by press Alt+F7 or click menu Project -> Properties look at Configuration Properties -> General -> Platform Toolset and set to current used version.

Table 1: Visual C++ Versions. (Support WindowXP)

Visual C++ 2015

v140_xp

Visual C++ 2014

v130_xp

Visual C++ 2013

v120_xp

Visual C++ 2012

v110_xp

                        B.) Cannot find arsa.h, Please re-check ARSA Framework path.

                        C.) If exit program then occurred break exception thrown, Uncheck Break when this exception type is thrown in warning dialog and click ignore.

           2.5 Run on real device.

                        2.5.1 Plug USB cable between your device and PC

                        2.5.2 Open vc++ project file for android device.

                                    [projectfolder]/android/android100.vcxproj (android100_2008.vcproj for vs2008).

                        2.5.3 Build project:

                                    F7 (Ctrl+Shift+B) or Build -> Build Solution

                        2.5.4 Run project on real device:

                                    Ctrl+Alt+F7 or Build -> Rebuild Solution

                        2.5.5 If you see gray color on real device hooray! you successes!!!

                        2.5.6 If error said, cannot find path of jdk, ant, sdk, ndk or arsa then open path.xml (same project folder), set invalid path that ARSA Framework cannot compile. Try find and correct the installed folder each program.

jdk="C:\Program Files (x86)\Java\jdk1.8.0_51"

ant="C:\ apache-ant-1.9.6"

sdk="C:\Program Files (x86)\Android\android-sdk"

ndk="C:\ android-ndk-r10e"

arsa="C:\arsa"

                             2.5.7 Project Target API:

                                A.) Checking project target in file project.properties ,looking at target that version must equal installed API 15:

                                      target=android-15

                                 B.) Checking AndroidManifest.xml ,try looking android:minSdkVersion, android:targetSdkVersion and changing to current version of project target from A.).

NOTE:

            A.) Error code.

Error code: 6

Checking license error, Try checking internet connection.

Error code: 6, filename

- File not found (check exist file or case sensitive)

- Checking internet connection (if load from cloud).

Error code: 7

Checking license error, Try disable firewall or proxy program.

Error code: 52

Checking license error, Server overload, Wait a minute and try run program again.

Unfortunately, <ProjectName> has stopped.

Program crash from device, Maybe call function from NULL pointer or cannot allocate memory before use.

            B.) If error when try build apk please see solution below but if not skip it.

                        B1.) Shown message in error log window.

BUILD FAILED

<android-sdk-folder>\tools\ant\build.xml:483: SDK does not have any Build Tools installed.

Don't understand or unknown -d flags

            Try update latest android SDK tool and platform tool.

                        B2.) Have you updated the Android SDK tools to 24.3.2? This seems to have caused the issue. Add following 4 lines to android-sdk-path/tools/ant/build.xml starting line 484 and hopefully it should solve.

<property name="aidl" location="${android.build.tools.dir}/aidl${exe}" />

<property name="aapt" location="${android.build.tools.dir}/aapt${exe}" />

<property name="dx" location="${android.build.tools.dir}/dx${bat}" />

<property name="zipalign" location="${android.build.tools.dir}/zipalign${exe}" />

Credit:

               http://stackoverflow.com/questions/30812770/ant-jar-error-execute-failed...

            2.6 Explain a program

                        #include <arsa.h> // must include

                        int main( int argc, char* args[] ) // standard c main function

                        {

                                    arsa_EasyStart( ); // start ARSA Framework

                                    return 0; // everything ok return 0

                        }

NOTE: Must enter redeem code! when call arsa_EasyStart( ). Get the redeem code, send email to arsa@sarosworld.com subject: get arsa redeem code

            2.7 Android Rotation Sensor

                        In general latest smart device can flip landscape and portrait. Landscape can swap in all device type e.g. phone or tablet but portrait done in tablet only.

                        2.7.1 Open AndroidManifest.xml on Solution Explorer.

                        2.7.2 Look at keyword android:screenOrientation and edit value is

                        2.7.3 Landscape (default)

                                    Landscape

sensorLandscape

                        2.7.4 Portrait 

                                    portrait

sensorPortrait

NOTE: if compile with API 15: portait , sensorPortait because missing typo [r] :-P

                     2.7.5 Call function matching to rotation sensor (call before arsa_EasyStart )

arsa_SetPortrait();

arsa_SetLandscape();

            2.8 Android Launcher Icon

                        The launcher icon will display on android home screen. Size of icon depend on each folder in [your_project_folder]/android/res

                        User can make own icon with any graphics program and save to png or jpg file format.

Table 2: Launcher Icon Size.

Folder

Size (pixel)

drawable-mdpi

48x48

drawable-hdpi

72x72

drawable-xhdpi

96x96

drawable-xxhdpi

144x144

                        ARSA Framework default icon name is ic_launcher.png that mean every icon size must have same name but stay difference folders.

Additional Information:

Android Icon Size – Launcher and Google Play Store

http://tekeye.biz/2013/android-icon-size

            2.9 Custom path of ARSA Framework

                        Default ARSA Framework path is c:/arsa but if user want to install in other local disk drive following instruction.

                        2.9.1 Emulators

            A.) Go to project properties (Alt+F7) or Project ->Properties The look at Configuration Properties -> C/C++ ->General ->Additional Include Directories and changing c:/arsa to your path e.g. new installed location is d:/tools/arsa final paths are

d:/tools/arsa/include

d:/tools/arsa/include/irrlicht

d:/tools/arsa/include/cdx

            B.) Set lib path look at  Linker -> General -> Additional Library Directories and editing a new path instead old path.

d:/tools/arsa/lib/win32

                        2.9.2 Android device

            A.) Checking section 2.5.3 again.

            B.) Look at Solution Explorer (Ctrl+Alt+L) -> double click Android.mk at section ARSA Framework include & lib folder  changing c:/arsa to a new path e.g.

#################################

# ARSA Framework include & lib folder

#################################

ARSA_INC_FOLDER = d:/tools/arsa/include

ARSA_LIB_FOLDER = d:/tools/arsa/lib

            2.10 Android C/C++ code generation

                        2.10.1 C/C++ code generation  

                                    Double click Application.mk and edit value.

                        Use STL

# Uncomment this if you're using STL in your project

# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information

APP_STL := stlport_static

                        Set android cpu version (change string, all mean compiling in all cpu)

# all

# armeabi

# armeabi-v7a

# mip

# x86

APP_ABI := armeabi-v7a

                        Select compiler between gcc or clang (choose one of choices)

# use this to select gcc instead of clang

#NDK_TOOLCHAIN_VERSION := 4.9

# OR use this to select the latest clang version:

NDK_TOOLCHAIN_VERSION := clang

                        Force compiling with specify android SDK

# !!!MUST equal android:minSdkVersion in AndroidManifest.xml!!!

APP_PLATFORM:=android-19

                        2.10.2 Android API

                           If you want to changing android API level then double click project.properties and change number of API want you.

target=android-22

            2.11 Add another C/C++ file to compile.

                        Assume new filename is test.cpp and save same folder main.cpp

            A.) Emulator

                        Drag and drop test.cpp to solution explorer directly.

            B.) Android

                        Open Android.mk and look at MY_LOCAL_SRC_FILES add test.cpp after SDL_android_main.c but android NDK look at jni as root folder user must skip path back before adding a new file e.g.

MY_LOCAL_SRC_FILES = ../../main.cpp \

       $(ARSA_INC_FOLDER)/SDL_android_main.c \

       ../../test.cpp

            C.) Emulator use 3rd party library

                        1.) Set include and lib folder following 2.9.1 section

                        2.) add new lib by code

#ifdef__WIN32__ // only for win32

#pragmacomment(lib, "bullet.lib" )

#endif

                        or go to project properties -> Configuration Properties  -> Linker -> General -> Additional Dependencies then add bullet.lib and click ok.

            D.) Android use 3rd party library

                        1.) Look at MY_INCLUDE and add include folder e.g. c:/bullet/include is a new include folder

MY_INCLUDE = $(ARSA_INC_FOLDER) \

       $(ARSA_INC_FOLDER)/irrlicht \

       $(ARSA_INC_FOLDER)/cdx \

       c:/bullet/include

                        2.) Import static or shared library

include $(CLEAR_VARS)

LOCAL_MODULE := Bullet

LOCAL_SRC_FILES := c:/bullet/lib/$(TARGET_ARCH_ABI)/libBullet.a

include $(PREBUILT_STATIC_LIBRARY)

            LOCAL_MODULE is name of a new library     

            LOCAL_SRC_FILES is library name static is .a shared is .so

            $(TARGET_ARCH_ABI) is variant string depend on user set android cpu version see 2.10.1 section for more cpu detail. e.g. if set cpu as armeabi-v7a then folder is armeabi-v7a too.

            if build with static you must use

Include $(PREBUILT_STATIC_LIBRARY)

            But if want build from shared library instead.

Include $(PREBUILT_SHARED_LIBRARY)

                        3.) Add prebuild library to current project. That's depend on you build with static or shared (choose one of these options).

            Pre build static library

LOCAL_STATIC_LIBRARIES := Arsa Bullet

            Pre build shared library

LOCAL_LDLIBS := -lEGL -lGLESv1_CM -lGLESv2 -llog -landroid -lz Bullet

            2.12 Conclusion         

                        This chapter explain you about important procedure to starting first program both emulator and android device. User must carefully ARSA_AppWiz100 folder copy them not overwrite before write a new project. A one thing for including a third party library to your project user must checking support both win32 and android before use. If that lib only support in android you cannot debug in emulator but in opposite case support win32 only you cannot deploy to real device too. Finally, android NDK root folder start at jni folder make sure for add a new C/C++ file to project. Don't forget that.

Tags: