Hi
I ported an SDL game into an app using commandergenius. the build is successful, I have a signed app MainActivity-debug.apk and able to install it into the Andriod emulator.
In the emulator the app launches with a splash screen, data.zip is loaded then it fails.
This is the output from the emulator shell, logcat:
(Other information about the ported application, build, resources and emulator follow this logcat output)
I/SDL ( 1269): libSDL: Creating startup screen
I/Choreographer( 662): Skipped 166 frames! The application may be doing too much work on its main thread.
I/SDL ( 1269): libSDL: onWindowFocusChanged: true - sending onPause/onResume
I/SDL ( 1269): libSDL: Loading libraries
I/SDL ( 1269): libSDL: loaded GLESv2 lib
I/SDL ( 1269): libSDL: loading lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_native_helpers.so
D/dalvikvm( 1269): Trying to load lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_native_helpers.so 0xb2d186e0
D/dalvikvm( 1269): Added shared lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_native_helpers.so 0xb2d186e0
D/dalvikvm( 1269): No JNI_OnLoad found in /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_native_helpers.so 0xb2d186e0, skipping init
I/SDL ( 1269): libSDL: loading lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl-1.2.so
D/dalvikvm( 1269): Trying to load lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl-1.2.so 0xb2d186e0
D/dalvikvm( 1269): Added shared lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl-1.2.so 0xb2d186e0
I/SDL ( 1269): libSDL: loading lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_mixer.so
D/dalvikvm( 1269): Trying to load lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_mixer.so 0xb2d186e0
D/gralloc_goldfish( 1269): Emulator without GPU emulation detected.
D/dalvikvm( 1269): Added shared lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_mixer.so 0xb2d186e0
D/dalvikvm( 1269): No JNI_OnLoad found in /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_mixer.so 0xb2d186e0, skipping init
I/SDL ( 1269): libSDL: loading lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_image.so
D/dalvikvm( 1269): Trying to load lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_image.so 0xb2d186e0
D/dalvikvm( 1269): Added shared lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_image.so 0xb2d186e0
D/dalvikvm( 1269): No JNI_OnLoad found in /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_image.so 0xb2d186e0, skipping init
I/SDL ( 1269): libSDL: Trying to extract binaries from assets binaries-armeabi-v7a.zip
I/SDL ( 1269): libSDL: Trying to extract binaries from assets binaries-armeabi.zip
I/SDL ( 1269): libSDL: Trying to extract binaries from assets binaries.zip
I/SDL ( 1269): libSDL: Loading settings
I/SDL ( 1269): libSDL: Settings.Load(): enter
I/ActivityManager( 372): Displayed uk.co.interlinux.dsi/.MainActivity: +1s796ms (total +2s146ms)
D/dalvikvm( 1269): GC_CONCURRENT freed 288K, 11% free 2887K/3240K, paused 4ms+4ms, total 101ms
I/SDL ( 1269): android.os.Build.MODEL: sdk
I/SDL ( 1269): libSDL: We don't have permission to write to SD card, switching to the internal storage.
I/SDL ( 1269): libSDL: Settings.Load(): loading settings failed, running config dialog
I/SDL ( 1269): Device RAM size: 501 Mb, required minimum RAM: 50 Mb
I/SDL ( 1269): libSDL: Starting data downloader
I/SDL ( 1269): libSDL: Starting downloader
I/SDL ( 1269): Downloading data to: '/data/data/uk.co.interlinux.dsi/files'
I/SDL ( 1269): libSDL: loading lib /data/data/uk.co.interlinux.dsi/files/../lib/libapplication.so
D/dalvikvm( 1269): Trying to load lib /data/data/uk.co.interlinux.dsi/files/../lib/libapplication.so 0xb2d186e0
D/dalvikvm( 1269): Added shared lib /data/data/uk.co.interlinux.dsi/files/../lib/libapplication.so 0xb2d186e0
D/dalvikvm( 1269): No JNI_OnLoad found in /data/data/uk.co.interlinux.dsi/files/../lib/libapplication.so 0xb2d186e0, skipping init
I/SDL ( 1269): libSDL: loading lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_main.so
D/dalvikvm( 1269): Trying to load lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_main.so 0xb2d186e0
D/dalvikvm( 1269): Added shared lib /data/data/uk.co.interlinux.dsi/files/../lib/libsdl_main.so 0xb2d186e0
I/SDL ( 1269): Processing download data.zip
I/Choreographer( 1269): Skipped 30 frames! The application may be doing too much work on its main thread.
I/SDL ( 1269): Fetching file from assets: data.zip
I/SDL ( 1269): Reading from zip file 'data.zip'
I/SDL ( 1269): Reading from zip file 'data.zip' entry 'data/'
I/SDL ( 1269): Creating dir '/data/data/uk.co.interlinux.dsi/files/data/'
...
... more data continued ...
...
I/SDL ( 1269): Saving file '/data/data/uk.co.interlinux.dsi/files/data/score.gif'
I/SDL ( 1269): Saving file '/data/data/uk.co.interlinux.dsi/files/data/score.gif' done
I/SDL ( 1269): Reading from zip file 'data.zip' finished
I/SDL ( 1269): libSDL: Initializing video and SDL application
V/SDL ( 1269): GLSurfaceView_SDL::onWindowResize(): 480x800
V/SDL ( 1269): GLSurfaceView_SDL::EglHelper::start(): creating GL context
V/SDL ( 1269): Desired GL config: R5G6B5A0 depth 0 stencil 0 type GLES
V/SDL ( 1269): GL config 0: R5G6B5A0 depth 0 stencil 0 type 1 (GLES) caveat SLOW nr 1 pos 4 (0,0,0,0,0)
V/SDL ( 1269): GL config 1: R5G6B5A0 depth 16 stencil 0 type 1 (GLES) caveat SLOW nr 1 pos 5 (0,0,1,1,1)
V/SDL ( 1269): GL config 2: R8G8B8A0 depth 0 stencil 0 type 1 (GLES) caveat SLOW nr 1 pos 12 (8,8,8,8,8)
V/SDL ( 1269): GL config 3: R8G8B8A0 depth 16 stencil 0 type 1 (GLES) caveat SLOW nr 1 pos 13 (8,8,9,9,9)
V/SDL ( 1269): GL config 4: R8G8B8A8 depth 0 stencil 0 type 1 (GLES) caveat SLOW nr 1 pos 13 (8,9,9,9,9)
V/SDL ( 1269): GL config 5: R8G8B8A8 depth 16 stencil 0 type 1 (GLES) caveat SLOW nr 1 pos 14 (8,9,10,10,10)
V/SDL ( 1269): GL config 6: R0G0B0A8 depth 0 stencil 0 type 1 (GLES) caveat SLOW nr 1 pos 21 (16,17,17,17,17)
V/SDL ( 1269): GL config 7: R0G0B0A8 depth 16 stencil 0 type 1 (GLES) caveat SLOW nr 1 pos 22 (16,17,18,18,18)
V/SDL ( 1269): GLSurfaceView_SDL::EGLConfigChooser::chooseConfig(): selected 0: R5G6B5A0 depth 0 stencil 0 type 1 (GLES) caveat SLOW nr 1 pos 4 (0,0,0,0,0)
V/SDL ( 1269): GLSurfaceView_SDL::EglHelper::createSurface(): creating GL context
I/SDL ( 1269): libSDL: DemoRenderer.onSurfaceCreated(): paused false mFirstTimeStart true
I/SDL ( 1269): libSDL: DemoRenderer.onSurfaceChanged(): paused false mFirstTimeStart false w 480 h 800
I/libSDL ( 1269): Physical screen resolution is 480x800
I/SDL ( 1269): libSDL: setting envvar LANGUAGE to 'en_US'
D/SDL ( 1269): libSDL: Is running on OUYA: false
D/dalvikvm( 1269): GC_CONCURRENT freed 339K, 12% free 3033K/3444K, paused 25ms+2ms, total 133ms
D/dalvikvm( 1269): WAIT_FOR_CONCURRENT_GC blocked 108ms
I/dalvikvm-heap( 1269): Grow heap (frag case) to 8.023MB for 5242896-byte allocation
D/dalvikvm( 1269): GC_FOR_ALLOC freed <1K, 5% free 8153K/8568K, paused 53ms, total 54ms
I/libSDL ( 1269): Changing curdir to "/data/data/uk.co.interlinux.dsi/files"
I/libSDL ( 1269): Calling SDL_main("sdl")
I/libSDL ( 1269): param 0 = "sdl"
I/libSDL ( 1269): Application closed, calling exit(0)
I/WindowState( 372): WIN DEATH: Window{b33b3bf0 u0 SurfaceView}
I/ActivityManager( 372): Process uk.co.interlinux.dsi (pid 1269) has died.
W/ActivityManager( 372): Force removing ActivityRecord{b2f8b038 u0 uk.co.interlinux.dsi/.MainActivity t7}: app died, no saved state
W/InputDispatcher( 372): channel 'b33e0a10 uk.co.interlinux.dsi/uk.co.interlinux.dsi.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
E/InputDispatcher( 372): channel 'b33e0a10 uk.co.interlinux.dsi/uk.co.interlinux.dsi.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
W/InputDispatcher( 372): Attempted to unregister already unregistered input channel 'b33e0a10 uk.co.interlinux.dsi/uk.co.interlinux.dsi.MainActivity (server)'
I/WindowState( 372): WIN DEATH: Window{b33e0a10 u0 uk.co.interlinux.dsi/uk.co.interlinux.dsi.MainActivity}
Other information about the ported application, build, resources and emulator:
Emulator:
Android 4.4.2 is a basic Android platform.
ARM (armeabi-v7a) processor,
with the following hardware config:
hw.lcd.density=240
hw.ramSize=512
hw.sdCard=yes
vm.heapSize=48
Build:
- ndk - android-ndk-r8c
- sdk - android-sdk_r21-linux
- Ubuntu 12.04.4 LTS
- Java installed from apt-get repos
java version "1.6.0_31"
OpenJDK Runtime Environment (IcedTea6 1.13.3) (6b31-1.13.3-1ubuntu1~0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
- Ant installed from apt-get repos
Apache Ant(TM) version 1.8.2 compiled on December 3 2011
Environment variables:
PATH=/home/myuserid/andriod-dev/ndk/android-ndk-r8c:/home/myuserid/andriod-dev/sdk/android-sdk-linux/tools/
AppName="dsi"
AppFullName=uk.co.interlinux.dsi
AppVersionCode=100002
AppVersionName="1.00.07.01"
'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
AppDataDownloadUrl="!DSI Data Files|data.zip"
ResetSdlConfigForThisVersion=y
DeleteFilesOnUpgrade="y"
ReadmeText='^You may press "Home" now - the data will be downloaded in background'
LibSdlVersion=1.2
ScreenOrientation=p
VideoDepthBpp=16
NeedDepthBuffer=n
NeedStencilBuffer=n
NeedGles2=n
SwVideoMode=y
SdlVideoResize=y
SdlVideoResizeKeepAspect=n
InhibitSuspend=y
CreateService=n
CompatibilityHacks=y
CompatibilityHacksStaticInit=n
CompatibilityHacksTextInputEmulatesHwKeyboard=n
CompatibilityHacksPreventAudioChopping=n
CompatibilityHacksAppIgnoresAudioBufferSize=n
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
CompatibilityHacksSlowCompatibleEventQueue=n
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=n
CompatibilityHacksProperUsageOfSDL_UpdateRects=n
AppUsesMouse=n
AppNeedsTwoButtonMouse=n
RightMouseButtonLongPress=n
ShowMouseCursor=n
GenerateSubframeTouchEvents=n
ForceRelativeMouseMode=n
AppNeedsArrowKeys=y
AppNeedsTextInput=y
AppUsesJoystick=y
AppUsesSecondJoystick=n
AppUsesThirdJoystick=n
AppUsesAccelerometer=y
AppUsesGyroscope=n
MoveMouseWithGyroscope=n
AppUsesMultitouch=n
AppRecordsAudio=n
AccessSdCard=n
AccessInternet=n
ImmersiveMode=n
NonBlockingSwapBuffers=n
RedefinedKeys="SPACE RETURN PLUS MINUS TAB ESCAPE DELETE"
AppTouchscreenKeyboardKeysAmount=0
RedefinedKeysScreenKb="SPACE RETURN PLUS MINUS TAB ESCAPE DELETE"
RedefinedKeysScreenKbNames="SPACE RETURN PLUS MINUS TAB ESCAPE DELETE"
TouchscreenKeysTheme=0
RedefinedKeysGamepad="SPACE RETURN PLUS MINUS TAB ESCAPE DELETE"
StartupMenuButtonTimeout=0
HiddenMenuOptions=''
FirstStartMenuOptions=''
MultiABI='n'
AppMinimumRAM=50
CompiledLibraries="sdl_mixer sdl_image"
CustomBuildScript=y
AppCflags=''
AppLdflags=''
AppOverlapsSystemHeaders=
AppSubdirsBuild=''
AppBuildExclude=''
AppCmdline=''
MinimumScreenSize=s
AdmobPublisherId=n
AdmobTestDeviceId=
AdmobBannerSize=
#!/bin/sh
LOCAL_PATH=`dirname $0`
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
ln -sf libsdl-1.2.so $LOCAL_PATH/../../../obj/local/armeabi/libSDL.so
if [ \! -f dsi/configure ] ; then
sh -c "cd dsi && ./autogen.sh"
sh -c "./autogen.sh"
fi
if [ \! -f dsi/Makefile ] ; then
../setEnvironment.sh sh -c "cd dsi && ./configure --host=arm-linux-androideabi"
fi
make -C dsi && mv -f dsi libapplication.so
--- end ---
Application structure
Main src folder
../src/dsi
Data folder
../src/data
data.zip created in ../src using zip -r': zip -r data data/
ls AndroidData/
data.zip logo.png
Makefile.am
INCLUDES = -I$(top_srcdir) -I$(srcdir)
bin_PROGRAMS = DSI
#DSI_CFLAGS = -DDSI_DIR=\"$(DESTDIR)$(pkgdatadir)\" \
# -DDSI_DATA_DIR=\"$(DESTDIR)$(pkgdatadir)/data\" \
# -DDSI_SCORE_DIR=\"$(DESTDIR)$(localstatedir)/lib/games/dsi\" \
# -DDSI_PIXMAP_DIR=\"$(DESTDIR)$(datadir)/pixmaps\"
DSI_CFLAGS = -DDSI_DIR=\"$(DESTDIR)\" \
-DDSI_DATA_DIR=\"$(DESTDIR)data\" \
-DDSI_SCORE_DIR=\"$(DESTDIR)/lib/games/dsi\" \
-DDSI_PIXMAP_DIR=\"$(DESTDIR)/pixmaps\"
DSI_SOURCES = main.c rcfile.c sprite.c aliens.c intro.c rungame.c \
data.c hi_score.c final_score.c sound.c bombs.c shots.c level.c \
player.c
DSI_LDADD = -lSDL_mixer -lSDL_image
noinst_HEADERS = *.h
--- end ---
main.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_image.h>
#include "config.h"
#include "sound.h"
#include "structs.h"
#include "data.h"
#include "hi_score.h"
#include "final_score.h"
#include "sprite.h"
#include "rungame.h"
#include "intro.h"
#include "rcfile.h"
SDL_Surface *screen;
SDL_Surface *background;
int fullscreen;
char *rcfile;
static void _usage(void)
{
printf("Usage:\n %s [Option...]\n\n", PACKAGE_NAME);
printf(" -? \tshow this message\n");
printf(" -v \tprint version number\n");
printf(" -f \tfullscreen\n");
printf(" -m m \tbuiltin MOD music\n");
printf(" w \tbuiltin WAV music\n");
printf(" n \tno music\n");
printf(" -t <file>\tplay music file\n\n");
}
static int _get_rc_prefs(void)
{
FILE *f = NULL;
char *arg;
rcfile = dsi_rc_init("dsirc", 1);
if (rcfile == NULL)
return 0;
if ((f = dsi_open_prefs(rcfile, "[dsi-prefs]")) == NULL)
return 0;
if ((arg = dsi_get_tag_arg(f, "fullscreen")) != NULL)
{
int i = atoi(arg);
if (i == 1 || i == 0)
fullscreen = i;
}
if ((arg = dsi_get_tag_arg(f, "track-mode")) != NULL)
{
if (0 == strcmp(arg, "m"))
music_decoder = MPLAY_MOD;
else if (0 == strcmp(arg, "w"))
music_decoder = MPLAY_WAV;
else if (0 == strcmp(arg, "n"))
music_decoder = MPLAY_NONE;
}
if ((arg = dsi_get_tag_arg(f, "track-file")) != NULL)
{
if (*arg) {
music_file = malloc(strlen(arg)+1);
if (music_file)
{
strcpy(music_file, arg);
music_decoder = MPLAY_FILE;
}
}
}
fclose(f);
return 1;
}
static int _init_all(void)
{
int tally;
if ((background = LoadImage(DATAFILE("background.gif"), 0)) == NULL)
return -1;
if ((tally = rungame_init()) < 0)
return -1;
if (sprite_init(tally) < 0)
return -1;
if (sound_init() < 0)
return -1;
if (intro_init() < 0)
return -1;
if (hi_score_init() < 0)
return -1;
if (final_score_init() < 0)
return -1;
return 1;
}
static void _free_all(void)
{
rungame_free();
sprite_free();
intro_free();
hi_score_free();
final_score_free();
sound_free();
SDL_FreeSurface(background);
free(music_file);
}
int main(int argc, char *argv[])
{
int leave = 0, CarryScore = 0;
int opt;
music_decoder = MPLAY_WAV;
music_file = NULL;
SDL_Surface *image = NULL;
SDL_Joystick *joy = NULL;
//rcfile overrides defaults
_get_rc_prefs();
//Command line overrides rcfile
while ((opt = getopt(argc, argv, "fv?m:t:")) != -1) {
switch (opt) {
case 'f':
fullscreen = 1;
break;
case 'm':
if (0 == strcmp(optarg, "m"))
music_decoder = MPLAY_MOD;
else if (0 == strcmp(optarg, "w"))
music_decoder = MPLAY_WAV;
else if (0 == strcmp(optarg, "n"))
music_decoder = MPLAY_NONE;
else
{
printf("%s invalid option to -m '%s'\n",
PACKAGE_NAME, optarg);
_usage();
return 0;
}
break;
case 't':
strncpy(music_file, optarg, PATH_MAX);
music_file[PATH_MAX -1] = '\0';
music_decoder = MPLAY_FILE;
break;
case 'v':
printf("%s version is %s\n",
PACKAGE_NAME, PACKAGE_VERSION);
return 0;
default: /* '?' */
_usage();
return 0;
}
}
//Initialize the SDL library
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0 )
{
fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
exit(2);
}
//Open the audio device
if ( Mix_OpenAudio(11025, AUDIO_U8, 1, 512) < 0 )
{
fprintf(stderr,
"Warning: Couldn't set 11025 Hz 8-bit audio\n- Reason: %s\n",
SDL_GetError());
}
// seems to be a compile problem with GetNumMusicDecoders and getMusicDecoder
// else
// {
// //Detect music decoders
// int i, n;
// n = Mix_GetNumMusicDecoders();
// for (i = 0; i < n; ++i)
// {
// if (0 == strcmp(Mix_GetMusicDecoder(i), "MIKMOD"));
// music_decoder = MPLAY_MOD;
// }
// }
//Open the display device (if fullscreen -f flag selected
//at command line)
//Open the joy stick
#ifdef __LINUX__
if (SDL_NumJoysticks())
joy=SDL_JoystickOpen(0);
#endif
if(fullscreen == 1)
{
screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE|SDL_FULLSCREEN);
if ( screen == NULL )
{
fprintf(stderr, "Couldn't set 640x480 video mode: %s\n",
SDL_GetError());
exit(2);
}
}else
{
#ifdef __LINUX__
image = IMG_Load(DSI_PIXMAP_DIR "/alien.png");
#else
image = SDL_LoadBMP("/Alien.ICO");
#endif
if (image)
SDL_WM_SetIcon(image, NULL);
screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE);
if ( screen == NULL )
{
fprintf(stderr, "Couldn't set 640x480 video mode: %s\n",
SDL_GetError());
exit(2);
}
SDL_WM_SetCaption("DSI Space Invaders", "DSI");
}
//Initialize the random number generator
srand(time(NULL));
//Load the artwork
if (_init_all() > 0)
{
while (leave != RUN_QUIT)
{
if (leave == RUN_INTRO)
{
leave = intro_run();
}
if (leave == RUN_GAME)
{
CarryScore = 0;
leave = RunGame(&CarryScore);
}
if (leave == RUN_FINAL)
{
leave = final_score_view(CarryScore);
}
//if 'v' for view score is pressed in intro and after game
if (leave == RUN_SCORE)
{
leave = hi_score_view();
}
}
//Free the artwork
_free_all();
}
if(joy)
SDL_JoystickClose(joy);
Mix_CloseAudio();
SDL_Quit();
return 0;
}
I have used these online resources:
http://anddev.at.ua/src/porting_manual.txt
I also attempted this in a different project directory, the demo, alien.c did not run.
I'll try things and run changes as people might think necessary and report back.
This is the project I'm porting: https://sourceforge.net/projects/dspaceinvadors/
I am the lead developer, see REAME
https://sourceforge.net/p/dspaceinvadors/code/HEAD/tree/
Thank you.
Damian