v2.4.0: improved debug info on missing Android natives
This commit is contained in:
committed by
Evan Debenham
parent
1c54043354
commit
ce5a66a15d
@@ -62,7 +62,7 @@ public class AndroidLauncher extends AndroidApplication {
|
||||
GdxNativesLoader.load();
|
||||
FreeType.initFreeType();
|
||||
} catch (Exception e){
|
||||
AndroidMissingNativesHandler.errorMsg = e.getMessage();
|
||||
AndroidMissingNativesHandler.error = e;
|
||||
Intent intent = new Intent(this, AndroidMissingNativesHandler.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
@@ -23,25 +23,60 @@ package com.shatteredpixel.shatteredpixeldungeon.android;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AndroidMissingNativesHandler extends Activity {
|
||||
|
||||
public static String errorMsg = "";
|
||||
public static Throwable error;
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
String versionName;
|
||||
try {
|
||||
versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
versionName = "???";
|
||||
}
|
||||
|
||||
int versionCode;
|
||||
try {
|
||||
versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
versionCode = 0;
|
||||
}
|
||||
|
||||
String installer;
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){
|
||||
installer = getPackageManager().getInstallSourceInfo(getPackageName()).getInstallingPackageName();
|
||||
} else {
|
||||
installer = getPackageManager().getInstallerPackageName(getPackageName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
installer = "???";
|
||||
}
|
||||
|
||||
TextView text = new TextView(this);
|
||||
text.setText("Shattered Pixel Dungeon cannot start because some of its code is missing!\n\n" +
|
||||
"This usually happens when the Google Play version of the game is installed from somewhere outside of Google Play.\n\n" +
|
||||
"If you're unsure of how to fix this, please email the developer (Evan@ShatteredPixel.com), and include this error message:\n\n" +
|
||||
errorMsg);
|
||||
String message = "ShatteredPD failed to access some of its internal code and cannot start!\n\n" +
|
||||
"Try downloading the game from an official source if you haven't already. You can also screenshot this debug info and send it to the developer (Evan@ShatteredPixel.com):";
|
||||
|
||||
message += "\n\nPackage: " + getPackageName();
|
||||
message += "\nVersion: " + versionName + " (" + versionCode + ")";
|
||||
message += "\nDevice: " + Build.MODEL;
|
||||
message += "\nInstaller: " + installer;
|
||||
while (error.getCause() != null){
|
||||
error = error.getCause();
|
||||
}
|
||||
message += "\nError: " + error.getMessage();
|
||||
text.setText(message);
|
||||
text.setTextSize(16);
|
||||
text.setTextColor(0xFFFFFFFF);
|
||||
text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/pixel_font.ttf"));
|
||||
|
||||
Reference in New Issue
Block a user