gdgfresno / androidify-yourself

Androidify Yourself app for 2017 Valley DevFest, based on the GDG Riga event app
https://vdf2017-3a9f6.firebaseapp.com/participants/
MIT License
1 stars 0 forks source link

While trying to share avatar onRequestPermissionsResult leads to NPE #4

Open MrCsabaToth opened 4 years ago

MrCsabaToth commented 4 years ago

Seeing this in App Store crash reports. Call stack:

java.lang.RuntimeException: 
  at android.app.ActivityThread.deliverResults (ActivityThread.java:4589)
  at android.app.ActivityThread.handleSendResult (ActivityThread.java:4631)
  at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:49)
  at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1893)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:192)
  at android.app.ActivityThread.main (ActivityThread.java:7169)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:504)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
Caused by: java.lang.NullPointerException: 
  at android.net.Uri$StringUri.<init> (Uri.java:490)
  at android.net.Uri$StringUri.<init> (Uri.java:480)
  at android.net.Uri.parse (Uri.java:452)
  at com.valleydevfest.androidify.PlaceholderFragment.share (PlaceholderFragment.java:172)
  at com.valleydevfest.androidify.PlaceholderFragment.onRequestPermissionsResult (PlaceholderFragment.java:156)
  at androidx.fragment.app.FragmentActivity.onRequestPermissionsResult (FragmentActivity.java:768)
  at android.app.Activity.dispatchRequestPermissionsResult (Activity.java:9095)
  at android.app.Activity.dispatchActivityResult (Activity.java:8945)
  at android.app.ActivityThread.deliverResults (ActivityThread.java:4582)

https://play.google.com/console/u/0/developers/7696534728259995393/app/4972777259653312467/vitals/crashes/ce0e7156/details?installedFrom=PLAY_STORE&days=30

Screenshot_2020-09-04_22-27-58

besides those there is also:

MrCsabaToth commented 4 years ago

Here is the share, line 172 is the Uri imageURI = Uri.parse(imagePath);:

    Bitmap bitmap = BitmapUtils.combineDrawables(getResources(), head, body, legs);

    String imagePath = MediaStore.Images.Media.insertImage(
        requireActivity().getContentResolver(), bitmap,
        getResources().getString(R.string.android_avatar), null
    );
    Uri imageURI = Uri.parse(imagePath);
    startShareActivity(imageURI);

This might be a permission issue? Maybe it's the new ScopedStorage related permission changes? https://developer.android.com/about/versions/10/privacy/changes#scoped-storage https://developer.android.com/training/data-storage#scoped-storage ? I wonder if as a workaround reverting target SDK level to API 28 would help. I assume that with the new permissions I cannot simply get a URI of the file.

MrCsabaToth commented 4 years ago

https://stackoverflow.com/questions/53913401/mediastore-images-media-insertimage-is-returning-null-when-trying-to-get-image-u

Maybe I should look into FileProvider. Also check if the file permissions are handled well.

MrCsabaToth commented 4 years ago

Also check