Android: Added additional error messages for APK expansion file use.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java
index 0662e60..f2a42dd 100644
--- a/android-project/src/org/libsdl/app/SDLActivity.java
+++ b/android-project/src/org/libsdl/app/SDLActivity.java
@@ -703,8 +703,15 @@ public class SDLActivity extends Activity {
return null; // no expansion use if no patch version was set
}
- Integer mainVersion = Integer.valueOf(mainHint);
- Integer patchVersion = Integer.valueOf(patchHint);
+ Integer mainVersion;
+ Integer patchVersion;
+ try {
+ mainVersion = Integer.valueOf(mainHint);
+ patchVersion = Integer.valueOf(patchHint);
+ } catch (NumberFormatException ex) {
+ ex.printStackTrace();
+ throw new IOException("No valid file versions set for APK expansion files", ex);
+ }
try {
// To avoid direct dependency on Google APK expansion library that is
@@ -719,6 +726,7 @@ public class SDLActivity extends Activity {
ex.printStackTrace();
expansionFile = null;
expansionFileMethod = null;
+ throw new IOException("Could not access APK expansion support library", ex);
}
}
@@ -727,12 +735,14 @@ public class SDLActivity extends Activity {
try {
fileStream = (InputStream)expansionFileMethod.invoke(expansionFile, fileName);
} catch (Exception ex) {
+ // calling "getInputStream" failed
ex.printStackTrace();
- fileStream = null;
+ throw new IOException("Could not open stream from APK expansion file", ex);
}
if (fileStream == null) {
- throw new IOException();
+ // calling "getInputStream" was successful but null was returned
+ throw new IOException("Could not open stream from APK expansion file");
}
return fileStream;