diff --git a/.github/workflows/generate-release.yml b/.github/workflows/generate-release.yml new file mode 100644 index 000000000..6ea2b611f --- /dev/null +++ b/.github/workflows/generate-release.yml @@ -0,0 +1,22 @@ +name: generate-release +on: + workflow_dispatch: +jobs: + build-android: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Install dependencies + run: sudo apt-get install -y ninja-build + - name: Build SoH + run: | + ./gradlew assembleDebug -P elfBuildType=RelWithDebInfo + mv app/build/outputs/apk/debug/app-debug.apk soh.apk + - name: Create release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + file: soh.apk diff --git a/.gitignore b/.gitignore index 2dc11ba80..11977d54f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ google-services.json # Android Profiling *.hprof + +# vscode +.vscode diff --git a/.gitmodules b/.gitmodules index 6fbcd88a8..ca98791d6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "app/jni/src/libultraship"] path = app/jni/src/libultraship - url = https://github.com/Waterdish/libultraship.git + url = https://github.com/robertkirkman/libultraship.git diff --git a/app/build.gradle b/app/build.gradle index feadf82a9..01784ad98 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,4 +1,4 @@ -def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY'); +def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY') def buildAsApplication = !buildAsLibrary if (buildAsApplication) { apply plugin: 'com.android.application' @@ -8,25 +8,21 @@ else { } android { - ndkPath "/home/waterdish/Android/Sdk/ndk/26.0.10792818" // Point to your own NDK - compileSdkVersion 31 + ndkVersion '27.2.12479018' + compileSdkVersion 34 defaultConfig { if (buildAsApplication) { applicationId "com.dishii.soh" } - minSdkVersion 18 - targetSdkVersion 31 + minSdkVersion 21 + //noinspection OldTargetApi + targetSdkVersion 34 versionCode 6 versionName "1.3.0" externalNativeBuild { - //ndkBuild { - // arguments "APP_PLATFORM=android-23" - // abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' - //} cmake { - arguments "-DANDROID_APP_PLATFORM=android-23", "-DANDROID_STL=c++_static", "-DHAVE_LD_VERSION_SCRIPT=OFF",'-DUSE_OPENGLES=ON' + arguments "-DANDROID_APPNAME=${applicationId}", "-DANDROID_APP_PLATFORM=android-21", "-DANDROID_STL=c++_static", "-DHAVE_LD_VERSION_SCRIPT=OFF", "-DUSE_OPENGLES=ON", "-DCMAKE_BUILD_TYPE=$elfBuildType" abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' - //abiFilters 'arm64-v8a' } } } @@ -36,7 +32,14 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } - applicationVariants.all { variant -> + buildFeatures { + buildConfig = true + } + namespace 'com.dishii.soh' + lint { + abortOnError false + } + applicationVariants.configureEach { variant -> tasks["merge${variant.name.capitalize()}Assets"] .dependsOn("externalNativeBuild${variant.name.capitalize()}") } @@ -45,27 +48,21 @@ android { jniLibs.srcDir 'libs' } externalNativeBuild { - //ndkBuild { - // path 'jni/Android.mk' - //} cmake { path 'jni/CMakeLists.txt' - version "3.25.1" + version "3.31.5" } } } - lintOptions { - abortOnError false - } - + if (buildAsLibrary) { libraryVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith(".aar")) { - def fileName = "org.libsdl.app.aar"; - output.outputFile = new File(outputFile.parent, fileName); + def fileName = "com.dishii.soh.aar" + output.outputFile = new File(outputFile.parent, fileName) } } } @@ -74,13 +71,13 @@ android { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'androidx.core:core:1.7.0' // Use the latest version - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.core:core:1.13.1' + implementation 'androidx.constraintlayout:constraintlayout:2.2.0' } -task wrapper(type: Wrapper) { - gradleVersion = '7.3' +tasks.register('wrapper', Wrapper) { + gradleVersion = '8.10.2' } -task prepareKotlinBuildScriptModel { +tasks.register('prepareKotlinBuildScriptModel') { } diff --git a/app/gradle/wrapper/gradle-wrapper.jar b/app/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f2..000000000 Binary files a/app/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/app/gradle/wrapper/gradle-wrapper.properties b/app/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index e750102e0..000000000 --- a/app/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/app/jni/src/libultraship b/app/jni/src/libultraship index 03e683e1d..94f648a98 160000 --- a/app/jni/src/libultraship +++ b/app/jni/src/libultraship @@ -1 +1 @@ -Subproject commit 03e683e1d1be96ed714f0459f603e40ea1e82444 +Subproject commit 94f648a98eefd65d3d4617a30ebc761cb80fe0e0 diff --git a/app/jni/src/soh/soh/Extractor/Extract.cpp b/app/jni/src/soh/soh/Extractor/Extract.cpp index db5258076..31410461d 100644 --- a/app/jni/src/soh/soh/Extractor/Extract.cpp +++ b/app/jni/src/soh/soh/Extractor/Extract.cpp @@ -95,7 +95,7 @@ enum class ButtonId : int { }; #ifdef __ANDROID__ -const char* javaRomPath = NULL; +static char javaRomPath[4096] = { 0 }; bool fileDialogOpen = false; //function to be called from C @@ -108,7 +108,7 @@ void openFilePickerFromC(JNIEnv* env, jobject javaObject) { // Define the native method to handle the selected file path extern "C" void JNICALL Java_com_dishii_soh_MainActivity_nativeHandleSelectedFile(JNIEnv* env, jobject obj, jstring filePath) { const char* filePathStr = env->GetStringUTFChars(filePath, 0); - javaRomPath = strdup(filePathStr); // save filepath to string + snprintf(javaRomPath, sizeof(javaRomPath), "%s", filePathStr); fileDialogOpen = false; env->ReleaseStringUTFChars(filePath, filePathStr); } @@ -248,7 +248,7 @@ void Extractor::GetRoms(std::vector& roms) { // if (h != nullptr) { // CloseHandle(h); //} -#elif unix && !defined(__ANDROID__) +#elif unix // Open the directory of the app. DIR* d = opendir(mSearchPath.c_str()); struct dirent* dir; @@ -272,33 +272,6 @@ void Extractor::GetRoms(std::vector& roms) { } } closedir(d); -#elif defined(__ANDROID__) - const char* androidAssetPath = SDL_AndroidGetExternalStoragePath(); - if (androidAssetPath == NULL) { - printf("Error accessing Android assets directory: %s\n", SDL_GetError()); - return; - } - - // Use androidAssetPath for file operations - // Example: List files in the directory - DIR* dir; - struct dirent* entry; - - if ((dir = opendir(androidAssetPath)) != NULL) { - while ((entry = readdir(dir)) != NULL) { - if (entry->d_type == DT_REG) { - char* filename = entry->d_name; - // Check file extension and process accordingly - if (strstr(filename, ".n64") || strstr(filename, ".z64") || strstr(filename, ".v64")) { - std::string fullPath = std::string(androidAssetPath) + "/" + filename; - roms.push_back(fullPath); - } - } - } - closedir(dir); - } else { - printf("Error opening directory: %s\n", androidAssetPath); - } #else for (const auto& file : std::filesystem::directory_iterator(mSearchPath)) { if (file.is_directory()) @@ -358,29 +331,18 @@ bool Extractor::GetRomPathFromBox() { //Do nothing until a file is chosen SDL_Delay(250); } - SDL_Log("%s",javaRomPath); - selection.push_back(javaRomPath); - - if (selection.empty()) { - return false; - } - - mCurrentRomPath = selection[0]; - - if (javaRomPath) { - free((void*)javaRomPath); - javaRomPath = NULL; - } + SDL_Log("javaRomPath: %s", javaRomPath); + selection.push_back(javaRomPath); #else auto selection = pfd::open_file("Select a file", mSearchPath, { "N64 Roms", "*.z64 *.n64 *.v64" }).result(); +#endif if (selection.empty()) { return false; } mCurrentRomPath = selection[0]; -#endif mCurRomSize = GetCurRomSize(); return true; } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2a9ad2c0c..e88f14e60 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,7 +3,6 @@ com.gamemaker.game --> @@ -54,8 +53,8 @@ - + @@ -73,7 +72,8 @@ android:allowBackup="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:hardwareAccelerated="true" - android:appCategory="game" > + android:appCategory="game" + android:requestLegacyExternalStorage="true">