stormlion227 / ImageCropper.Forms

Xamarin.Forms plugin to crop and rotate photos.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Null Reference Exception After taking photo on Android

shocker1099 opened this issue · comments

I downloaded and built the library and it works fine on iOS, but I"m getting a null reference exception on Android. It happens right after a photo is taken or chosen (so I never see the "use photo" screen). I'm targeting Android 8.0, but otherwise I haven't changed anything. Any thoughts?

Here's the exception from the log. I'll attach the full output as a file.

Unhandled Exception:

Java.Lang.RuntimeException: Unable to start activity ComponentInfo{com.stormlion.ImageCropperTest/com.theartofdev.edmodo.cropper.CropImageActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void android.support.v7.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)' on a null object reference

03-07 18:26:42.002 E/AndroidRuntime( 5357): FATAL EXCEPTION: main
03-07 18:26:42.002 E/AndroidRuntime( 5357): Process: com.stormlion.ImageCropperTest, PID: 5357
03-07 18:26:42.002 E/AndroidRuntime( 5357): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.stormlion.ImageCropperTest/com.theartofdev.edmodo.cropper.CropImageActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void android.support.v7.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)' on a null object reference
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2697)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2771)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.app.ActivityThread.access$900(ActivityThread.java:177)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1432)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.os.Handler.dispatchMessage(Handler.java:102)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.os.Looper.loop(Looper.java:135)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.app.ActivityThread.main(ActivityThread.java:5912)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at java.lang.reflect.Method.invoke(Native Method)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at java.lang.reflect.Method.invoke(Method.java:372)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
03-07 18:26:42.002 E/AndroidRuntime( 5357): Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void android.support.v7.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)' on a null object reference
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:410)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:323)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at com.theartofdev.edmodo.cropper.CropImageActivity.onCreate(CropImageActivity.java:58)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.app.Activity.performCreate(Activity.java:6178)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
03-07 18:26:42.002 E/AndroidRuntime( 5357): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2650)
03-07 18:26:42.002 E/AndroidRuntime( 5357): ... 10 more
Thread finished: #3
The thread 0x3 has exited with code 0 (0x0).
outputlog.txt

Which theme do you use?
Would you clean solution and rebuild again?

Experiencing the same issue, even with your test app.

May be this will helpful, I Experienced the same issue, i just put the 'if' condition for result checking for image cropping in OnActivityResult method in MainActivity.cs file in Android and all the others Activity put in else. In 'else' I put the azure login function.

Actually I was getting "Null Uri " exception cause of "AuthenticationAgentContinuationHelper.SetAuthenticationAgentContinuationEventArgs(requestCode, resultCode, data);" function , while cropping the code control also went to this function. that's why i put this one in a 'else' condition.

 `protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
  {
        
        base.OnActivityResult(requestCode, resultCode, data);
        if (requestCode == CropImage.CropImageActivityRequestCode)
        {
            Stormlion.ImageCropper.Droid.Platform.OnActivityResult(requestCode, resultCode, data);
        }
        else
        {
            AuthenticationAgentContinuationHelper.SetAuthenticationAgentContinuationEventArgs(requestCode, resultCode, data);

        }

    }`