add debug information to android linking errors

This commit is contained in:
Taner Sener 2021-02-15 00:36:06 +00:00
parent d8c6c6a192
commit b21aad94d3

View File

@ -41,7 +41,11 @@ public class NativeLoader {
private static void loadLibrary(final String libraryName) { private static void loadLibrary(final String libraryName) {
if (isTestModeDisabled()) { if (isTestModeDisabled()) {
try {
System.loadLibrary(libraryName); System.loadLibrary(libraryName);
} catch (final UnsatisfiedLinkError e) {
throw new Error(String.format("FFmpegKit failed to start on %s.", getDeviceDebugInformation()), e);
}
} }
} }
@ -141,7 +145,7 @@ public class NativeLoader {
loadLibrary(ffmpegLibrary + "_neon"); loadLibrary(ffmpegLibrary + "_neon");
} }
nativeFFmpegLoaded = true; nativeFFmpegLoaded = true;
} catch (final UnsatisfiedLinkError e) { } catch (final Error e) {
android.util.Log.i(FFmpegKitConfig.TAG, String.format("NEON supported armeabi-v7a ffmpeg library not found. Loading default armeabi-v7a library.%s", Exceptions.getStackTraceString(e))); android.util.Log.i(FFmpegKitConfig.TAG, String.format("NEON supported armeabi-v7a ffmpeg library not found. Loading default armeabi-v7a library.%s", Exceptions.getStackTraceString(e)));
nativeFFmpegTriedAndFailed = true; nativeFFmpegTriedAndFailed = true;
} }
@ -170,7 +174,7 @@ public class NativeLoader {
loadLibrary("ffmpegkit_armv7a_neon"); loadLibrary("ffmpegkit_armv7a_neon");
nativeFFmpegKitLoaded = true; nativeFFmpegKitLoaded = true;
AbiDetect.setArmV7aNeonLoaded(); AbiDetect.setArmV7aNeonLoaded();
} catch (final UnsatisfiedLinkError e) { } catch (final Error e) {
android.util.Log.i(FFmpegKitConfig.TAG, String.format("NEON supported armeabi-v7a ffmpegkit library not found. Loading default armeabi-v7a library.%s", Exceptions.getStackTraceString(e))); android.util.Log.i(FFmpegKitConfig.TAG, String.format("NEON supported armeabi-v7a ffmpegkit library not found. Loading default armeabi-v7a library.%s", Exceptions.getStackTraceString(e)));
} }
} }
@ -180,4 +184,33 @@ public class NativeLoader {
} }
} }
static String getDeviceDebugInformation() {
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("brand: ");
stringBuilder.append(Build.BRAND);
stringBuilder.append(", model: ");
stringBuilder.append(Build.MODEL);
stringBuilder.append(", device: ");
stringBuilder.append(Build.DEVICE);
stringBuilder.append(", api level: ");
stringBuilder.append(Build.VERSION.SDK_INT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
stringBuilder.append(", abis: ");
stringBuilder.append(FFmpegKit.argumentsToString(Build.SUPPORTED_ABIS));
stringBuilder.append(", 32bit abis: ");
stringBuilder.append(FFmpegKit.argumentsToString(Build.SUPPORTED_32_BIT_ABIS));
stringBuilder.append(", 64bit abis: ");
stringBuilder.append(FFmpegKit.argumentsToString(Build.SUPPORTED_64_BIT_ABIS));
} else {
stringBuilder.append(", cpu abis: ");
stringBuilder.append(Build.CPU_ABI);
stringBuilder.append(", cpu abi2s: ");
stringBuilder.append(Build.CPU_ABI2);
}
return stringBuilder.toString();
}
} }