Google added a new ART runtime with Android 4.4. How can I determine whether ART or Dalvik is the current runtime?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
final String vm = VMRuntime.getRuntime().vmLibrary();
and then compare vm with "libdvm.so" or "libart.so" to check if it is Dalvik or ART.
Reference: https://gitorious.org/cyandreamproject/android_frameworks_base/commit/4c3f1e9e30948113b47068152027676172743eb1
Update
At least, as early as June 2014 Google has released an official documentation on how to correctly verify the current runtime in use:
With that, now there is no need to go through reflection and simply check the corresponding system property:
One possible way is to read the respective
SystemProperty
through reflection.Sample:
Hope this helps.
For anyone needing a JNI version:
Or if you want to follow a code path closer to what shoe rat posted,
The Android docs actually give the following suggestion:
This seems accurate on my Nexus 4 w/ ART enabled (running Android 4.4.4). Nexus 5 on Dalvik returned
1.6.0
.I think you should be able to use System.getProperty with
java.vm.name
as the key. In the JavaDoc its value isDalvik
, which let's hope it isArt
orART
when using that runtime. It's worth a try...A simple solution :
On my Android 8.0 (API 26) phone, it returns Dalvik 2.1.0 .