Skip to content

Instantly share code, notes, and snippets.

@derFunk
Created June 18, 2014 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derFunk/2f676b17eb5a26b89ba7 to your computer and use it in GitHub Desktop.
Save derFunk/2f676b17eb5a26b89ba7 to your computer and use it in GitHub Desktop.
Reliably Detect ART Runtime on Android KitKat
/**
* Checks if the device is using the (still experimental Android Runtime (ART))
* @return Returns true if ART is used on the device.
*/
public static boolean isART()
{
if (Build.VERSION.SDK_INT < 19) // Before KITKAT, as ART is only available since 4.4.x
return false ;
try{
String bootClassPath = System.getProperty("java.boot.class.path", "");
if (bootClassPath.contains("core-libart.jar")){
Log.d(TAG, "java.boot.class.path contains core-libart.jar - Using ART :(");
return true;
}
else {
Log.d(TAG, "java.boot.class.path does not contain core-libart.jar - Not using ART :)");
return false;
}
}
catch(Exception e){
android.util.Log.d(TAG, e.toString());
}
// If not found - return false because if when
// returning true, and there is no ART, it would
// be worse to display a popup "you cannot play, you're using ART",
// instead of crashing the app instantly
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment