-
-
Notifications
You must be signed in to change notification settings - Fork 464
Fixes crash on Android API < 16 #511
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
Conversation
|
Thanks for doing this! Were you able to build and test this? If you app is compiled with an SDK below 16 wouldn't compilation fail because the field doesn't even exist? |
|
@bretthoerner thanks for your time :) Yes, I think compilation will fail if you set compileSdkVersion to 15, but you normally want to compile with the latest SDK to have the posibility of calling new SDK methods, but guarded in version checks, like this PR does. Honestly, I didn't built the module. I tried to generate a snapshot using jitpack, but I think it doesn't recognize the modules. When I have more time, I'll try to test it properly :) |
|
Cool, if I get time I'll try it in an emulator with an old API. |
|
Thanks @Syhids. After checking the official documentation, I can confirm that Usually, libraries also define a minimum SDK - If an app tries to include a library with a higher minimum version than the app itself, compilation will fail. |
|
Yeah, we compile/test against 16. But if we can lower the requirements this easily then I don't see a reason not to. How would we declare the minimum in the POM? |
| if (memInfo != null) { | ||
| deviceMap.put("free_memory", memInfo.availMem); | ||
| deviceMap.put("memory_size", memInfo.totalMem); | ||
| if (Build.VERSION.SDK_INT >= 16) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Build.VERSION_CODES.JELLY_BEAN instead of the plain (magic) number 16 here. Other than that, it looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Thanks :)
|
@bretthoerner Good question, I briefly checked, and could not find a straightforward answer how to set the minimum SDK when using Maven. With Gradle, it would be I can check again in the coming days. In the meantime, once my comment is addressed, this PR should be merged as it definitely avoids a crash on SDK 15 and below. |
|
Great, thanks to both of you. |
|
@Syhids if you can make that change I'll merge, thanks! |
Fixes GH-510