gradle - Disable ART runtime (vmSafeMode) and dex2oat for an Android Library targeting SDK 22+? -
so, disable art runtime, add android:vmsafemode="true" application's manifest tag.
the issue having develop android library, , not have application tag.
this means debugging extremely slow when using instant run (dex2oat has run on everything), or when using library using instant run.
i attempted use manifestplaceholders = [vmsafemodeenabled: "true"]
in build.gradle, has no effect.
anyone have insights?
similarly,
dexoptions { predexlibraries false }
yielded no difference in results. still seeing dex2oat taking significant amount of time on each app startup.
of course, of these options work fine on applications, not @ library/sdk development.
as mention on comment, believe you're mixing concepts i'll take time explain them separately.
instant run
that feature of ide (that android studio) , compatible (in different amounts) way devices running api 15. affects code used during debug/development of application.
it works forcing debug version of app multidex
, dynamic loading code change on usb new dex file. final compiled code (regardless of library or application) never changed feature.
see here: https://developer.android.com/studio/run/index.html#instant-run
instant run supported when deploy debug build variant, use android plugin gradle version 2.0.0 or higher, , set minsdkversion 15
art
that current runtime android runs. core system reads byte code apk , turns processor instructions.
see here: https://source.android.com/devices/tech/dalvik/
art , dalvik compatible runtimes running dex bytecode, apps developed dalvik should work when running art
so there're edge cases differences, if check link (https://developer.android.com/guide/practices/verifying-apps-art.html) you'll see dealing native code , wouldn't make difference java libraries.
that means long code targets corrects apis, makes no difference runtime executing code they're compatible runtimes.
vmsafemode
on art, disables aot compiler. normal user perspective time during installation play store shows "installing". moment when art doing several pre-processing on app ready executed processor. time happens during usb debugging, if disabled, have execute on fly.
predexlibraries
this tells build system (gradle) pre-process libraries. helpful in cases whenever it's going build apk, library processed. if you're building library, every time change code have re-processed anyway.
to problem
with concepts in place, point incoherence following comment below:
while 1 disable instant run, if there library setup art compilation dependency, causes issues. can't tell people not use instant run when issue not inherently within it.
- a library never compiled runtime dependency. might depend on api level (which methods can call) or device feature (needs gps or accelerator). runtime (art , dalvik) compatible , execute same code same result (art being more efficient/faster).
- also, explained, instant run feature of android studio during development/debugging. after library have been packed
aar
file , other developers using, makes no difference if instant run used or not.
with , original problem in mind. can see due way instant run works, developing library can have reverse effect wanted it. library potentially spread around app , change force new full build, taking longer.
also can see how disabling ahead-of-time compilation on art change dev-debug time, for much.
to finalise
i hope clear , solution problem is:
- if instant run taking long, disable on androidstudio. not influence other developers.
- i don't believe make big difference, if insist, can add
vmsafemode
"sample app" while developing library, , library still work on other apps developed other developers without issues. - predexlibraries expected have little impact when developing library