[Android] Android 11+ mandatory use of app-specific directory (obb)

- before migration to obb folder, run Forge first and let it download and install necessary files. If Forge is not running (after Android 11 update, white screen bug), disable storage permission and enable storage permission again for Forge. After succesful run, exit Forge then copy your existing Forge folder to Android/obb/forge.app (as suggested by CptKird).
This commit is contained in:
Anthony Calosa
2021-04-30 21:27:46 +08:00
parent 3d1c39da30
commit 6f13aa4724
2 changed files with 15 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="forge.app"
android:versionCode="1"
android:versionName="1.5.40" >
android:versionName="1.6.40" > <!-- versionName should be updated and it's used for Sentry releases tag -->
<uses-sdk
android:minSdkVersion="19"

View File

@@ -55,6 +55,7 @@ import forge.util.FileUtil;
import forge.util.ThreadUtil;
import io.sentry.Sentry;
import io.sentry.android.AndroidSentryClientFactory;
import io.sentry.event.BreadcrumbBuilder;
public class Main extends AndroidApplication {
AndroidAdapter Gadapter;
@@ -215,21 +216,28 @@ public class Main extends AndroidApplication {
if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
//fake init for error message
//set current orientation
String message = getDeviceName()+"\n"+"Android "+AndroidRelease+"\n"+"RAM "+ totalRAM+"MB" +"\n"+"LibGDX "+ Version.VERSION+"\n"+"Can't access external storage";
Sentry.getContext().recordBreadcrumb(
new BreadcrumbBuilder().setMessage(message).build()
);
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, true, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName()));
displayMessage(adapter, true, getDeviceName()+"\n"+"Android "+AndroidRelease+"\n"+"RAM "+ totalRAM+"MB" +"\n"
+"LibGDX "+ Version.VERSION+"\n"+"Can't access external storage");
displayMessage(adapter, true, message);
return;
}
String obbforge = Environment.getExternalStorageDirectory() + "/obbforge"; //if obbforge file exists in Phone Storage, use app-specific Obb directory as path
String assetsDir = FileUtil.doesFileExist(obbforge) ? getContext().getObbDir()+"/Forge/" : Environment.getExternalStorageDirectory()+"/Forge/";
String obbforge = Environment.getExternalStorageDirectory() + "/obbforge";
//if obbforge file exists in Phone Storage, Forge uses app-specific Obb directory as path, Android 11+ is mandatory even without obbforge
String assetsDir = (FileUtil.doesFileExist(obbforge) || Build.VERSION.SDK_INT > 29) ? getContext().getObbDir()+"/Forge/" : Environment.getExternalStorageDirectory()+"/Forge/";
if (!FileUtil.ensureDirectoryExists(assetsDir)) {
//fake init for error message
//set current orientation
String message = getDeviceName()+"\n"+"Android "+AndroidRelease+"\n"+"RAM "+ totalRAM+"MB" +"\n"+"LibGDX "+ Version.VERSION+"\n"+"Can't access external storage\nPath: " + assetsDir;
Sentry.getContext().recordBreadcrumb(
new BreadcrumbBuilder().setMessage(message).build()
);
Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation);
initialize(Forge.getApp(new AndroidClipboard(), adapter, "", false, true, totalRAM, isTabletDevice, AndroidAPI, AndroidRelease, getDeviceName()));
displayMessage(adapter, true, getDeviceName()+"\n"+"Android "+AndroidRelease+"\n"+"RAM "+ totalRAM+"MB" +"\n"
+"LibGDX "+ Version.VERSION+"\n"+"Can't access external storage\nPath: " + assetsDir);
displayMessage(adapter, true, message);
return;
}
boolean isPortrait;