Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let annotation crashes on Android N devices #5

Closed
olsontl opened this issue Mar 16, 2016 · 6 comments
Closed

Let annotation crashes on Android N devices #5

olsontl opened this issue Mar 16, 2016 · 6 comments
Assignees

Comments

@olsontl
Copy link

olsontl commented Mar 16, 2016

Hey there,
Thought you'd like to know about this crash on Android N:

java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String[] com.canelmas.let.AskPermission.value()' on a null object reference
    at com.canelmas.let.RuntimePermissionRequest.proceed(RuntimePermissionRequest.java:61)
    at com.canelmas.let.RuntimePermissionRequest.proceed(RuntimePermissionRequest.java:52)
    at com.canelmas.let.LetAspect.ajc$inlineAccessMethod$com_canelmas_let_LetAspect$com_canelmas_let_RuntimePermissionRequest$proceed(LetAspect.java:1)
    at com.canelmas.let.LetAspect.annotatedMethods(LetAspect.java:57)

Here's the line of code where it crashed:
@AskPermission({ Manifest.permission.ACCESS_FINE_LOCATION })

Just thought I'd give you a heads up for when the full OS release actually comes out. Love the library!

@mendhak
Copy link

mendhak commented Mar 17, 2016

Same problem in my app, crashing on Android N devices. I am asking for:

@AskPermission({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.WRITE_EXTERNAL_STORAGE})

And the crash looks like this:

java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String[] com.canelmas.let.AskPermission.value()' on a null object reference
    at com.canelmas.let.RuntimePermissionRequest.proceed(RuntimePermissionRequest.java:61)
    at com.canelmas.let.RuntimePermissionRequest.proceed(RuntimePermissionRequest.java:52)
    at com.canelmas.let.LetAspect.ajc$inlineAccessMethod$com_canelmas_let_LetAspect$com_canelmas_let_RuntimePermissionRequest$proceed(LetAspect.java:1)
    at com.canelmas.let.LetAspect.annotatedMethods(LetAspect.java:57)
    at com.mendhak.gpslogger.ui.fragments.display.GenericViewFragment.requestToggleLogging(GenericViewFragment.java:98)
    at com.mendhak.gpslogger.ui.fragments.display.GpsSimpleViewFragment$1.onClick(GpsSimpleViewFragment.java:101)
    at android.view.View.performClick(View.java:5565)
    at android.view.View$PerformClick.run(View.java:22047)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5849)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:763)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)

@canelmas
Copy link
Owner

@olsontl @mendhak hey, thanks for reporting. I'm also able to reproduce the crash.

I believe the issue is related to the retention policy set to RetentionPolicy.CLASS for @AskPermission

To be honest, I don't really remember what was I really thinking when I changed it from Runtime to Class in the first place. I will fix it in a day.

But the thing is I'm having trouble understanding why it's working on pre-N and not on N.

@canelmas
Copy link
Owner

it should be fixed with 0.1.10

@olsontl
Copy link
Author

olsontl commented Apr 11, 2016

Looks good. Thanks!

@canelmas
Copy link
Owner

It seems that retention policies are not being honored in certain cases; which is fixed and should be expected with the upcoming new N releases.

You can check official issue here : https://code.google.com/p/android/issues/detail?id=203109

@mufumbo
Copy link

mufumbo commented Apr 9, 2018

this problem still happens on 0.1.11:

    Process: com.craftlog.android.cooking, PID: 14695
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.annotation.Annotation java.lang.reflect.Method.getAnnotation(java.lang.Class)' on a null object reference
        at com.canelmas.let.RuntimePermissionRequest.proceed(SourceFile:61)
        at com.canelmas.let.RuntimePermissionRequest.proceed(SourceFile:52)
        at com.canelmas.let.LetAspect.ajc$inlineAccessMethod$com_canelmas_let_LetAspect$com_canelmas_let_RuntimePermissionRequest$proceed(SourceFile:1)
        at com.canelmas.let.LetAspect.annotatedMethods(SourceFile:57)

it started happening after we disabled D8 compiler.

Do you think this library should never crash? Maybe a big-O try/catch will be necessary, regardless of android bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants