Skip to content

Commit 045cc04

Browse files
committed
android fixes
source files updates and fixed build.sh to auto build on Linux. readme updated. gitignores updated.
1 parent e7b83fb commit 045cc04

File tree

8 files changed

+74
-63
lines changed

8 files changed

+74
-63
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
OpenBOR.elf
55
meta.xml
66
/engine/version.h
7+
/engine/version.txt
78
/engine/resources/Info.plist
89
engine/releases/
910
/engine/ide/vs/.vs/
@@ -17,7 +18,6 @@ tools/win-sdk/*
1718
tools/psp-sdk/*
1819
tools/devkitpro/*
1920
!tools/devkitpro/devkitPro.7z
20-
engine/android/app/src/main/assets/bor.pak
2121
/openbor_vs
2222
engine/ios/Build
2323
**/.DS_Store

engine/android/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
/build
77
/keystore.properties
88
*.jks
9+
/app/local.properties
10+
/app/src/main/assets/*.pak

engine/android/README

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##############################################
2-
# Msmalik681 Windows 64 bit Build instructions
2+
# Windows 64 bit Build instructions
33
##############################################
44

55
First Download and install JAVA JDK 11. once installed open a command promt window and type "java -version" if it confirms you have java 11 installed.
@@ -9,14 +9,12 @@ Now download the Android SDK but be sure to get the "command line tools only" pa
99
Finally go to the android folder in the source code and run build.bat. If it is the first time it will take time to download everything.
1010

1111
############################################
12-
# Msmalik681 Linux 64 bit Build instructions
12+
# Linux 64 bit Build instructions
1313
############################################
1414

15-
make sure you have java 11 installed check in terminal with "java --version" you can use openjdk 11.
15+
run openbor/engine/android/build.sh it will download everything needed and build openbor debug apk.
1616

17-
(Optional) Download Android SDK but be sure to get the "command line tools only" and extract to "~/.android" now youo should have the path "~/.android/cmdline-tools/sdkmanager".
18-
19-
Finally go to the android folder in the source code and run ./build.sh it will take a time to download everything if this is the first run.
17+
incase the downloads are broken download "commandlinetools-linux-13114758_latest.zip" and "openjdk-17.0.1_linux-x64_bin.zip" extract both to "~/.android" before you run build.sh.
2018

2119
#########################
2220
# Custom Apk instructions
@@ -106,5 +104,5 @@ Anyway for debugging and development, you can
106104
# Development Notes
107105
###################
108106

109-
* Minimum SDK (API Level) is 16 at the moment
107+
* Minimum SDK (API Level) is 21 at the moment
110108
* Support building for two architectures (with included pre-built libraries) arm64-v8a, and armeabi-v7a.

engine/android/app/local.properties

Lines changed: 0 additions & 8 deletions
This file was deleted.

engine/android/build.sh

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,73 @@
22
#
33
# build the android apk !
44
#
5+
#set build version, android home temp variable and build
6+
export ANDROID_SDK_ROOT="$HOME/.android"
7+
export ANDROID_HOME="$ANDROID_SDK_ROOT"
8+
export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/21.4.7075529"
9+
export JAVA_HOME="$ANDROID_HOME/jdk-17.0.1"
10+
11+
# function to try to download files
12+
downloader()
13+
{
14+
DL_NAME=$1
15+
DL_URL=$2
16+
DL_MD5=$3
17+
DL_PATH=$ANDROID_HOME
18+
19+
for i in {1..5}
20+
do
21+
22+
if [ $i == 5 ]; # tried 5 times now give up!
23+
then
24+
echo "error: failed to download $DL_NAME now aboting"
25+
exit
26+
fi
27+
28+
if [ ! -f $DL_PATH/$DL_NAME ];
29+
then
30+
wget --no-check-certificate $DL_URL -O $DL_PATH/$DL_NAME
31+
fi
32+
33+
if md5sum $DL_PATH/$DL_NAME | grep -i $DL_MD5 > /dev/null;
34+
then
35+
cd $DL_PATH
36+
tar -xf $DL_NAME -C "$ANDROID_HOME"
37+
break
38+
else
39+
rm $DL_PATH/$DL_NAME
40+
fi
41+
done
42+
}
43+
44+
545

646
# make sdk directory if missing
7-
if [ ! -d ~/.android ];
47+
if [ ! -d $ANDROID_HOME ];
848
then
949
cd ~/
10-
mkdir .android
50+
mkdir $ANDROID_HOME
1151
fi
1252

13-
#get sdk if missing
14-
if [ ! -d ~/.android/cmdline-tools ];
53+
#get command line tools if missing
54+
if [ ! -d "$ANDROID_HOME/cmdline-tools" ];
1555
then
16-
cd ~/.android
17-
18-
for i in {1..5}
19-
do
20-
21-
if [ $i == 5 ];
22-
then
23-
echo "error: failed to download cmdline-tools.tar.xz"
24-
exit
25-
fi
26-
27-
if [ ! -f ~/.android/cmdline-tools.tar.xz ];
28-
then
29-
wget --no-check-certificate "https://onedrive.live.com/download?cid=CFF1642CDA1859A3&resid=CFF1642CDA1859A3%21654&authkey=ANAEsZyPlQwHLMQ" -O ~/.android/cmdline-tools.tar.xz
30-
fi
31-
32-
if md5sum ~/.android/cmdline-tools.tar.xz | grep -i d7edd7ea7900fece56ffcfc37400e5be > /dev/null;
33-
then
34-
tar -xf ~/.android/cmdline-tools.tar.xz
35-
break
36-
else
37-
rm ~/.android/cmdline-tools.tar.xz
38-
fi
39-
done
56+
downloader commandlinetools-linux-13114758_latest.tar.gz "https://app.box.com/index.php?rm=box_download_shared_file&shared_name=8amw5xzga9lfuv8rfad4bit5cgx2w94g&file_id=f_1875969786508" 29f56e9f159d02b33dd3ccd72a3a63ce
4057
fi
4158

42-
59+
#get JDK 17 if missing
60+
if [ ! -d "$JAVA_HOME" ];
61+
then
62+
downloader openjdk-17.0.1_linux-x64_bin.tar.gz "https://app.box.com/index.php?rm=box_download_shared_file&shared_name=5r0urbd5f9i2xvmgd2nnw9xpuvpo4atr&file_id=f_1875964794936" bfb0c5653a3171a7e9430f81f70b3ec1
63+
fi
4364

4465
#sign all licenses
4566
if [ ! -d ~/.android/licenses ];
4667
then
47-
cd ~/.android
68+
cd "$ANDROID_HOME"
4869
bash cmdline-tools/bin/sdkmanager --sdk_root=./ --licenses
4970
fi
5071

51-
#set build version, android home temp variable and build
52-
export ANDROID_SDK_ROOT=~/.android
53-
export ANDROID_HOME=$ANDROID_SDK_ROOT
54-
export ANDROID_NDK_HOME=~/.android/ndk/21.4.7075529
55-
export JAVA_HOME=/home/malik/Desktop/jdk-17.0.1
5672

5773
cd $(dirname $(readlink -f $0))
5874
cd ../

engine/sdl/menu.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,19 @@ static void drawMenu()
517517
s_screen* Image = NULL;
518518

519519
putscreen(vscreen,bgscreen,0,0,NULL);
520+
#ifdef ANDROID
521+
char no_paks[MAX_FILENAME_LEN] = "No Mods In Paks Folder:\n";
522+
strcat(no_paks, paksDir);
523+
char no_paks_2[MAX_FILENAME_LEN];
524+
strncpy(no_paks_2,no_paks,44);
525+
no_paks_2[44]='\0';
526+
char *pak_out = no_paks + 44;
527+
strcpy(no_paks,pak_out);
528+
if(dListTotal < 1) printText((isWide ? 30 : 8), (isWide ? 33 : 24), RED, 0, 0, no_paks_2);
529+
if(dListTotal < 1) printText((isWide ? 30 : 8), (isWide ? 43 : 34), RED, 0, 0, no_paks);
530+
#else
520531
if(dListTotal < 1) printText((isWide ? 30 : 8), (isWide ? 33 : 24), RED, 0, 0, "No Mods In Paks Folder!");
532+
#endif
521533
for(list = 0; list < dListTotal; list++)
522534
{
523535
if(list < MAX_MODS_NUM) //Kratus (13-03-21) avoid engine "close" bug

engine/sdl/sdlport.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,7 @@ int main(int argc, char *argv[])
100100
packfile_mode(0);
101101

102102
#ifdef ANDROID
103-
if(strstr(SDL_AndroidGetExternalStoragePath(), "org.openbor.engine"))
104-
{
105-
strcpy(rootDir, "/mnt/sdcard/OpenBOR/");
106-
strcpy(paksDir, "/mnt/sdcard/OpenBOR/Paks");
107-
strcpy(savesDir, "/mnt/sdcard/OpenBOR/Saves");
108-
strcpy(logsDir, "/mnt/sdcard/OpenBOR/Logs");
109-
strcpy(screenShotsDir, "/mnt/sdcard/OpenBOR/ScreenShots");
110-
}
111-
else
112-
{
103+
113104
strcpy(rootDir, SDL_AndroidGetExternalStoragePath());
114105
strcat(rootDir, "/");
115106
strcpy(paksDir, SDL_AndroidGetExternalStoragePath());
@@ -120,7 +111,7 @@ int main(int argc, char *argv[])
120111
strcat(logsDir, "/Logs");
121112
strcpy(screenShotsDir, SDL_AndroidGetExternalStoragePath());
122113
strcat(screenShotsDir, "/ScreenShots");
123-
}
114+
124115
dirExists(rootDir, 1);
125116
chdir(rootDir);
126117
#endif

engine/source/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void *checkAlloc(void *ptr, size_t size, const char *func, const char *file, int
258258
"\n* Shutting Down *\n\n");
259259
writeToLogFile("Out of memory!\n");
260260
writeToLogFile("Allocation of size %i failed in function '%s' at %s:%i.\n", size, func, file, line);
261-
#if LINUX && !DARWIN
261+
#if LINUX && !DARWIN && !ANDROID
262262
writeToLogFile("Memory usage at exit: %u\n", mallinfo2().arena);
263263
#else
264264
writeToLogFile("Memory usage at exit: %u\n", getUsedRam(BYTES));

0 commit comments

Comments
 (0)