Bug 1300

Summary: AndroidVersion doesn't work if android.os.Build is in the classpath
Product: [JogAmp] Gluegen Reporter: diegoperez
Component: coreAssignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: normal CC: gouessej
Priority: P4    
Version: 2.4.0   
Hardware: All   
OS: all   
Type: DEFECT SCM Refs:
f24a8b675a0b3d7e73870c46239792a31cf81491
Workaround: ---

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.
Comment 3 Sven Gothel 2019-03-26 22:13:16 CET
Thank you Diego, merged.