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

Crashes caused by newer system services being unavailable #120

Closed
LightWayUp opened this issue Jun 13, 2023 · 1 comment
Closed

Crashes caused by newer system services being unavailable #120

LightWayUp opened this issue Jun 13, 2023 · 1 comment
Assignees
Labels

Comments

@LightWayUp
Copy link

Bug description

The app crashes when:

  • On Android 10 and 11, in LinkSheet navigate to Settings > Apps > Preferred apps
  • On Android 9 and below, simply open LinkSheet

In functions, checks like if (AndroidVersion.AT_LEAST_API_31_S) are performed. However, fields are only annotated with @RequiresApi, which is a hint and does not prevent initialization.
Therefore, domainVerificationManager field in PreferredAppSettingsViewModel causes crash as Android can't find the class of the service:

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/content/pm/verify/domain/DomainVerificationManager;
(Obfuscated stack trace omitted)
Caused by: java.lang.ClassNotFoundException: android.content.pm.verify.domain.DomainVerificationManager
    ... 62 more

Similarly for roleManager field in MainViewModel:

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/app/role/RoleManager;
(Obfuscated stack trace omitted)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.app.role.RoleManager" on path: DexPathList[[zip file "/data/app/fe.linksheet.nightly-66axovlUfdaoJtmvjdnJCA==/base.apk"],nativeLibraryDirectories=[/data/app/fe.linksheet.nightly-66axovlUfdaoJtmvjdnJCA==/lib/x86_64, /system/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 62 more

There are more fields annotated this way in AppsWhichCanOpenLinksViewModel, but users can't reach that route below Android 12, so there's no impact there.

Version

Nightly

Previous version

0.0.31

Device

Android Emulator

Android version

Android 11

Application log or crash log

No response

Reproducible on latest nightly build

Yes

@1fexd
Copy link
Collaborator

1fexd commented Jun 14, 2023

Thanks for the very detailed bug report, I thought the Android Gradle plugin does some magic at compile time to transform code using this annotation, but apparently it does not.

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

No branches or pull requests

2 participants