Bug 1300 - AndroidVersion doesn't work if android.os.Build is in the classpath
Summary: AndroidVersion doesn't work if android.os.Build is in the classpath
Status: UNCONFIRMED
Alias: None
Product: Gluegen
Classification: JogAmp
Component: core (show other bugs)
Version: 2.4.0
Hardware: All all
: P4 normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2016-04-06 17:02 CEST by diegoperez
Modified: 2016-06-09 12:37 CEST (History)
1 user (show)

See Also:
Type: DEFECT
SCM Refs:
Workaround: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description diegoperez 2016-04-06 17:02:07 CEST
Sometimes android.os.Build might be in the classpath even if the system is not Android. This will cause the Android detection to fail.
The recommended way to detect when an app is running on Android is using the "java.vm.name" system property and checking if the value is equals to "Dalvik".
Comment 1 Julien Gouesse 2016-04-12 10:27:37 CEST
Hi

Does it work when Dalvik VM isn't used (i.e when Android Runtime is used instead)? How does the detection fail? Please can you be more accurate? Can you post a stack trace?
Comment 2 diegoperez 2016-06-09 12:37:20 CEST
Yes, "Dalvik" will be returned even when using ART.

The detection fails because android.os.Build might be sometimes in the classpath even if the system is not Android. In those cases, the library will incorrectly assume that is running in Android when it's not.

The PR (https://github.com/sgothel/gluegen/pull/33/files) updates the detection to use the "java.vm.name" property.