Skip to content

Commit 7d48fcd

Browse files
committed
special external storage permission
- bump SDL to 2.32.0 - bump NDK to r27c - bump AGP to 8.8.0 - bump Gradle to 8.10.2 - bump CMake to 3.31.5 - bump targetSdkVersion to 34 - add GitHub Actions Release support (Debug) - add Special External Storage Permission support - fix "oot.otr not found" error on first launch - drop Android 4 support
1 parent b5a4986 commit 7d48fcd

File tree

19 files changed

+314
-267
lines changed

19 files changed

+314
-267
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: generate-release
2+
on:
3+
workflow_dispatch:
4+
jobs:
5+
build-android:
6+
runs-on: ubuntu-24.04
7+
steps:
8+
- uses: actions/checkout@v4
9+
with:
10+
submodules: true
11+
- name: Install dependencies
12+
run: sudo apt-get install -y ninja-build
13+
- name: Build SoH
14+
run: |
15+
./gradlew assembleDebug
16+
mv app/build/outputs/apk/debug/app-debug.apk soh.apk
17+
- name: Create release
18+
uses: svenstaro/upload-release-action@v2
19+
with:
20+
repo_token: ${{ secrets.GITHUB_TOKEN }}
21+
tag: ${{ github.ref }}
22+
file: soh.apk

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ google-services.json
3232

3333
# Android Profiling
3434
*.hprof
35+
36+
# vscode
37+
.vscode

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "app/jni/src/libultraship"]
22
path = app/jni/src/libultraship
3-
url = https://github.com/Waterdish/libultraship.git
3+
url = https://github.com/robertkirkman/libultraship.git

app/build.gradle

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY');
1+
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY')
22
def buildAsApplication = !buildAsLibrary
33
if (buildAsApplication) {
44
apply plugin: 'com.android.application'
@@ -8,25 +8,21 @@ else {
88
}
99

1010
android {
11-
ndkPath "/home/waterdish/Android/Sdk/ndk/26.0.10792818" // Point to your own NDK
12-
compileSdkVersion 31
11+
ndkVersion '27.2.12479018'
12+
compileSdkVersion 34
1313
defaultConfig {
1414
if (buildAsApplication) {
1515
applicationId "com.dishii.soh"
1616
}
17-
minSdkVersion 18
18-
targetSdkVersion 31
17+
minSdkVersion 21
18+
//noinspection OldTargetApi
19+
targetSdkVersion 34
1920
versionCode 6
2021
versionName "1.3.0"
2122
externalNativeBuild {
22-
//ndkBuild {
23-
// arguments "APP_PLATFORM=android-23"
24-
// abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
25-
//}
2623
cmake {
27-
arguments "-DANDROID_APP_PLATFORM=android-23", "-DANDROID_STL=c++_static", "-DHAVE_LD_VERSION_SCRIPT=OFF",'-DUSE_OPENGLES=ON'
24+
arguments "-DANDROID_APPNAME=${applicationId}", "-DANDROID_APP_PLATFORM=android-21", "-DANDROID_STL=c++_static", "-DHAVE_LD_VERSION_SCRIPT=OFF", "-DUSE_OPENGLES=ON"
2825
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
29-
//abiFilters 'arm64-v8a'
3026
}
3127
}
3228
}
@@ -36,7 +32,14 @@ android {
3632
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3733
}
3834
}
39-
applicationVariants.all { variant ->
35+
buildFeatures {
36+
buildConfig = true
37+
}
38+
namespace 'com.dishii.soh'
39+
lint {
40+
abortOnError false
41+
}
42+
applicationVariants.configureEach { variant ->
4043
tasks["merge${variant.name.capitalize()}Assets"]
4144
.dependsOn("externalNativeBuild${variant.name.capitalize()}")
4245
}
@@ -45,27 +48,21 @@ android {
4548
jniLibs.srcDir 'libs'
4649
}
4750
externalNativeBuild {
48-
//ndkBuild {
49-
// path 'jni/Android.mk'
50-
//}
5151
cmake {
5252
path 'jni/CMakeLists.txt'
53-
version "3.25.1"
53+
version "3.31.5"
5454
}
5555
}
5656

5757
}
58-
lintOptions {
59-
abortOnError false
60-
}
61-
58+
6259
if (buildAsLibrary) {
6360
libraryVariants.all { variant ->
6461
variant.outputs.each { output ->
6562
def outputFile = output.outputFile
6663
if (outputFile != null && outputFile.name.endsWith(".aar")) {
67-
def fileName = "org.libsdl.app.aar";
68-
output.outputFile = new File(outputFile.parent, fileName);
64+
def fileName = "com.dishii.soh.aar"
65+
output.outputFile = new File(outputFile.parent, fileName)
6966
}
7067
}
7168
}
@@ -74,13 +71,13 @@ android {
7471

7572
dependencies {
7673
implementation fileTree(include: ['*.jar'], dir: 'libs')
77-
implementation 'androidx.core:core:1.7.0' // Use the latest version
78-
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
74+
implementation 'androidx.core:core:1.13.1'
75+
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
7976
}
8077

81-
task wrapper(type: Wrapper) {
82-
gradleVersion = '7.3'
78+
tasks.register('wrapper', Wrapper) {
79+
gradleVersion = '8.10.2'
8380
}
8481

85-
task prepareKotlinBuildScriptModel {
82+
tasks.register('prepareKotlinBuildScriptModel') {
8683
}
-58.1 KB
Binary file not shown.

app/gradle/wrapper/gradle-wrapper.properties

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

app/jni/src/soh/soh/Extractor/Extract.cpp

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ enum class ButtonId : int {
9595
};
9696

9797
#ifdef __ANDROID__
98-
const char* javaRomPath = NULL;
98+
static char javaRomPath[4096] = { 0 };
9999
bool fileDialogOpen = false;
100100

101101
//function to be called from C
@@ -108,7 +108,7 @@ void openFilePickerFromC(JNIEnv* env, jobject javaObject) {
108108
// Define the native method to handle the selected file path
109109
extern "C" void JNICALL Java_com_dishii_soh_MainActivity_nativeHandleSelectedFile(JNIEnv* env, jobject obj, jstring filePath) {
110110
const char* filePathStr = env->GetStringUTFChars(filePath, 0);
111-
javaRomPath = strdup(filePathStr); // save filepath to string
111+
snprintf(javaRomPath, sizeof(javaRomPath), "%s", filePathStr);
112112
fileDialogOpen = false;
113113
env->ReleaseStringUTFChars(filePath, filePathStr);
114114
}
@@ -248,7 +248,7 @@ void Extractor::GetRoms(std::vector<std::string>& roms) {
248248
// if (h != nullptr) {
249249
// CloseHandle(h);
250250
//}
251-
#elif unix && !defined(__ANDROID__)
251+
#elif unix
252252
// Open the directory of the app.
253253
DIR* d = opendir(mSearchPath.c_str());
254254
struct dirent* dir;
@@ -272,33 +272,6 @@ void Extractor::GetRoms(std::vector<std::string>& roms) {
272272
}
273273
}
274274
closedir(d);
275-
#elif defined(__ANDROID__)
276-
const char* androidAssetPath = SDL_AndroidGetExternalStoragePath();
277-
if (androidAssetPath == NULL) {
278-
printf("Error accessing Android assets directory: %s\n", SDL_GetError());
279-
return;
280-
}
281-
282-
// Use androidAssetPath for file operations
283-
// Example: List files in the directory
284-
DIR* dir;
285-
struct dirent* entry;
286-
287-
if ((dir = opendir(androidAssetPath)) != NULL) {
288-
while ((entry = readdir(dir)) != NULL) {
289-
if (entry->d_type == DT_REG) {
290-
char* filename = entry->d_name;
291-
// Check file extension and process accordingly
292-
if (strstr(filename, ".n64") || strstr(filename, ".z64") || strstr(filename, ".v64")) {
293-
std::string fullPath = std::string(androidAssetPath) + "/" + filename;
294-
roms.push_back(fullPath);
295-
}
296-
}
297-
}
298-
closedir(dir);
299-
} else {
300-
printf("Error opening directory: %s\n", androidAssetPath);
301-
}
302275
#else
303276
for (const auto& file : std::filesystem::directory_iterator(mSearchPath)) {
304277
if (file.is_directory())
@@ -358,29 +331,18 @@ bool Extractor::GetRomPathFromBox() {
358331
//Do nothing until a file is chosen
359332
SDL_Delay(250);
360333
}
361-
SDL_Log("%s",javaRomPath);
362-
selection.push_back(javaRomPath);
363-
364-
if (selection.empty()) {
365-
return false;
366-
}
367-
368-
mCurrentRomPath = selection[0];
369-
370-
if (javaRomPath) {
371-
free((void*)javaRomPath);
372-
javaRomPath = NULL;
373-
}
334+
SDL_Log("javaRomPath: %s", javaRomPath);
374335

336+
selection.push_back(javaRomPath);
375337
#else
376338
auto selection = pfd::open_file("Select a file", mSearchPath, { "N64 Roms", "*.z64 *.n64 *.v64" }).result();
339+
#endif
377340

378341
if (selection.empty()) {
379342
return false;
380343
}
381344

382345
mCurrentRomPath = selection[0];
383-
#endif
384346
mCurRomSize = GetCurRomSize();
385347
return true;
386348
}

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
com.gamemaker.game
44
-->
55
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
6-
package="com.dishii.soh"
76
android:versionCode="6"
87
android:versionName="1.3.0"
98
android:installLocation="auto">
@@ -54,8 +53,8 @@
5453
<!-- Allow access to the vibrator -->
5554
<uses-permission android:name="android.permission.VIBRATE" />
5655

57-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
5856
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
57+
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
5958

6059
<!-- if you want to capture audio, uncomment this. -->
6160
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
@@ -73,7 +72,8 @@
7372
android:allowBackup="true"
7473
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
7574
android:hardwareAccelerated="true"
76-
android:appCategory="game" >
75+
android:appCategory="game"
76+
android:requestLegacyExternalStorage="true">
7777

7878

7979
<!-- Example of setting SDL hints from AndroidManifest.xml:
@@ -84,7 +84,6 @@
8484

8585

8686
<activity android:name="MainActivity"
87-
android:label="@string/app_name"
8887
android:alwaysRetainTaskState="true"
8988
android:launchMode="singleInstance"
9089
android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"

app/src/main/assets/mods/custom_otr_files_go_here.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)