我正在使用带有 React Native 的 Android 应用程序的 Photo Editor SDK。当从图库中选择任一照片或使用相机拍摄时,应用程序崩溃。在 Android 8.1、5 和 6 上测试。我们使用的是 PESDK 库的 v5 和 targetSdkVersion 27。在 MainActivity 我们有
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PESDK_EDITOR_REQUEST && resultCode == Activity.RESULT_OK) {
String resultPath = data.getStringExtra(ImgLyIntent.RESULT_IMAGE_PATH);
//...
}
}
它在 data.getStringExtra() 行上崩溃。这是堆栈跟踪:
Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=12345678, result=-1, data=Intent { (has extras) }} to activity {com.***/com.***.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.ClassLoader java.lang.Class.getClassLoader()' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:4440)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4484)
at android.app.ActivityThread.-wrap19(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1743)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6753)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.ClassLoader java.lang.Class.getClassLoader()' on a null object reference
at ly.img.android.sdk.models.state.manager.SettingsList.<init>(SettingsList.java:93)
at ly.img.android.sdk.models.state.manager.SettingsList$1.createFromParcel(SettingsList.java:44)
at ly.img.android.sdk.models.state.manager.SettingsList$1.createFromParcel(SettingsList.java:41)
at android.os.Parcel.readParcelable(Parcel.java:2851)
at android.os.Parcel.readValue(Parcel.java:2745)
at android.os.Parcel.readArrayMapInternal(Parcel.java:3114)
at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:273)
at android.os.BaseBundle.unparcel(BaseBundle.java:226)
at android.os.BaseBundle.getString(BaseBundle.java:1118)
at android.content.Intent.getStringExtra(Intent.java:7139)
at com.***.MainActivity.onActivityResult(MainActivity.java:46)
at android.app.Activity.dispatchActivityResult(Activity.java:7312)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4436)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4484)
at android.app.ActivityThread.-wrap19(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1743)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6753)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
NPE 从库中抛出。我只是按照教程进行操作,我不知道我做错了什么。任何帮助,将不胜感激。