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();
|
GdxNativesLoader.load();
|
||||||
FreeType.initFreeType();
|
FreeType.initFreeType();
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
AndroidMissingNativesHandler.errorMsg = e.getMessage();
|
AndroidMissingNativesHandler.error = e;
|
||||||
Intent intent = new Intent(this, AndroidMissingNativesHandler.class);
|
Intent intent = new Intent(this, AndroidMissingNativesHandler.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
|
|||||||
@@ -23,25 +23,60 @@ package com.shatteredpixel.shatteredpixeldungeon.android;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class AndroidMissingNativesHandler extends Activity {
|
public class AndroidMissingNativesHandler extends Activity {
|
||||||
|
|
||||||
public static String errorMsg = "";
|
public static Throwable error;
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(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);
|
TextView text = new TextView(this);
|
||||||
text.setText("Shattered Pixel Dungeon cannot start because some of its code is missing!\n\n" +
|
String message = "ShatteredPD failed to access some of its internal code and cannot start!\n\n" +
|
||||||
"This usually happens when the Google Play version of the game is installed from somewhere outside of Google Play.\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):";
|
||||||
"If you're unsure of how to fix this, please email the developer (Evan@ShatteredPixel.com), and include this error message:\n\n" +
|
|
||||||
errorMsg);
|
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.setTextSize(16);
|
||||||
text.setTextColor(0xFFFFFFFF);
|
text.setTextColor(0xFFFFFFFF);
|
||||||
text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/pixel_font.ttf"));
|
text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/pixel_font.ttf"));
|
||||||
|
|||||||
Reference in New Issue
Block a user