Override android:vmSafeMode attribute for debug builds -


while trying optimize build , deployment speed debugging app found large chunk of time spent executing /system/bin/dex2oat during installation. art ahead of time compiler.

i found when targeting api 22 can stop art aot compilation:

<application     ...     android:vmsafemode="true">  </application> 

i saw noticeable deployment speed improvement, have concerns possible side effects of making change. must cause small runtime performance hit, there other consequences of enabling android:vmsafemode option?

is possible override attribute, debug builds, in gradle build file? or creating debug specific manifest file solution?

the best way enable android:vmsafemode debug build using debug manifest complement contents of main androidmanifest.xml.

to add this, create new file …/app/src/debug/androidmanifest.xml , add following xml:

<manifest  xmlns:android="http://schemas.android.com/apk/res/android">   <application android:vmsafemode="true" /> </manifest> 

after adding debug manifest , installing app should inspect device logcat output ensure vmsafemode flag being correctly applied when dex2oat process executed. argument --compiler-filter=interpret-only. output reports time taken dex2oat process execute can compare before , after making change.

i/dex2oat﹕ /system/bin/dex2oat --zip-fd=6 --zip-location=/data/app/com.testing.sample.myapp-1/base.apk --oat-fd=7 --oat-location=/data/dalvik-cache/arm/data@app@com.testing.sample.myapp-1@base.apk@classes.dex --instruction-set=arm --instruction-set-features=div --runtime-arg -xms64m --runtime-arg -xmx512m --compiler-filter=interpret-only --swap-fd=8 i/dex2oat﹕ dex2oat took 1.258ms (threads: 4) arena alloc=0b java alloc=2mb native alloc=502kb free=7mb 

it possible use aapt tool check if apk has vmsafemode enabled:

aapt list -a myapkfile.apk ... a: android:vmsafemode(0x010102b8)=(type 0x12)0xffffffff ... 

i have not seen reports of bugs caused removing ahead-of-time compilation. however, possible application may expose issues not visible before making change due reduction in performance.

it possible intensive processing may slower factor of many times. if app fits category best not remove ahead-of-time compilation.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -