diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 8ca63aab6..9675eba14 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -323,6 +323,8 @@ bool System_GetPropertyBool(SystemProperty prop) { } std::string GetJavaString(JNIEnv *env, jstring jstr) { + if (!jstr) + return ""; const char *str = env->GetStringUTFChars(jstr, 0); std::string cpp_string = std::string(str); env->ReleaseStringUTFChars(jstr, str); @@ -397,7 +399,9 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init langRegion = GetJavaString(env, jlangRegion); std::string externalDir = GetJavaString(env, jexternalDir); - std::string user_data_path = GetJavaString(env, jdataDir) + "/"; + std::string user_data_path = GetJavaString(env, jdataDir); + if (user_data_path.size() > 0) + user_data_path += "/"; library_path = GetJavaString(env, jlibraryDir) + "/"; std::string shortcut_param = GetJavaString(env, jshortcutParam); std::string cacheDir = GetJavaString(env, jcacheDir); diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index 7f301c992..9888a9fa1 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -296,7 +296,12 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C File sdcard = Environment.getExternalStorageDirectory(); String externalStorageDir = sdcard.getAbsolutePath(); - String dataDir = this.getFilesDir().getAbsolutePath(); + File filesDir = this.getFilesDir(); + String dataDir = null; + if (filesDir != null) { + // Null has been seen in Google Play stacktraces + dataDir = this.getFilesDir().getAbsolutePath(); + } String apkFilePath = appInfo.sourceDir; String cacheDir = getCacheDir().getAbsolutePath();