Home > Enterprise >  How to sideload baseline profiles in android?
How to sideload baseline profiles in android?

Time:09-05

I read the official docs but just can't get it running. https://developer.android.com/topic/performance/baselineprofiles#measuring-baseline

My basline profiles are set up and I have my baseline-prof.txt file in the main folder.

Not sure on how to test it on my device now.

The docs say:

Next, let's sideload the Baseline Profile.

Note: This workflow is only supported on version Android 9 (API 28) to Android 11 (API 30).

# Unzip the Release APK first
unzip release.apk
# Create a ZIP archive
# Note: The name should match the name of the APK
# Note: Copy baseline.prof{m} and rename it to primary.prof{m}
cp assets/dexopt/baseline.prof primary.prof
cp assets/dexopt/baseline.profm primary.profm
# Create an archive
zip -r release.dm primary.prof primary.profm
# Confirm that release.dm only contains the two profile files:
unzip -l release.dm
# Archive:  release.dm
#   Length      Date    Time    Name
# ---------  ---------- -----   ----
#      3885  1980-12-31 17:01   primary.prof
#      1024  1980-12-31 17:01   primary.profm
# ---------                     -------
#                               2 files
# Install APK   Profile together
adb install-multiple release.apk release.dm

But when I start typing those commants in the Terminal it tells me right away:

unzip:  cannot find or open release.apk, release.apk.zip or release.apk.ZIP.

I have no clue how to do it and I'm not able to find any other source which explains it

EDIT The docs state: "Note: This workflow is only supported on version Android 9 (API 28) to Android 11 (API 30)." So I cannot sideload baseline profiles on my Android 12 device?

CodePudding user response:

Android 12 security updates restrict side-loading these, so yes. You cannot, as is clear from the docs.

Here's a handy-dandy Kotlin sample to help you easily, efficiently and seamlessly find out if your version is compatible or not.

val android_version = android.os.Build.VERSION.SDK_INT

// Let Kotlin demonstrate 
if (android_version in 9..11)
   print("Side-loading now")
else throw Exception("Oops! Wrong Android!")

Issue on Android 12 -(https://issuetracker.google.com/issues/232104540)

Issue on Android 13 -(https://issuetracker.google.com/issues/232104548)

CodePudding user response:

You can't currently on Android 12 .

If you are trying to see what your app performance feels like for a user download your app from the Play Store, you can tell the Android runtime to fully compile the app which is slightly better than Baseline Profiles by running

adb shell cmd package compile -m speed -f <YOUR_APPS_PACKAGE_NAME>

  • Related