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?
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)
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
I'm using firebase_admin with python 3.8
On my computer it works very well but when I package the application with buildozer it breaks, does not run after installed on Android.
1 - Is there a mdelo application that shows the use with kivy?
2 - Is the spec file missing something?
Nothing is missing all you need is to add the following modules in your
buildozer.spec
requests, openssl, urllib3, chardet, idna, jwt, cryptography, pyparsing, firebase_admin, PIL, google-auth, cachetools, pyasn1, pyasn1_modules, rsa, google-api-python-client, google-cloud-storage, google-cloud-firestore, google-api-core, protobuf, cachecontrol, gcloud, google-cloud, httplib2
and in permission allow internet accesses like this
android.permissions = INTERNET
and you can write in your terminal for viewing logs while your app is running on your phone
buildozer android debug deploy run logcat
but you will need to allow to see only python logs by doing this in your buildozer.spec
[buildozer]
# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 2
if you didn't understand there is a Youtuber named Erick Sandberg you should watch his video about deploying an android app
I'm porting android to a display device, and have nearly completed this. The device use the Freescale/NXP i.MX6 Dual Lite Soc. The Android version used is Android 8.0.0, and the build is based on the Board Support Packages from NXP/Freescale (link below).
https://www.nxp.com/support/developer-resources/software-development-tools/i.mx-developer-resources/android-os-for-i.mx-applications-processors:IMXANDROID?tab=Design_Tools_Tab
The OS builds fine, and the images (u-boot, boot.img, system.img, vendor.img) resuling from the "make" process works perfercly fine on the device. So my last step is basically to sign the images, and this is where I struggle to get stuff working.
I am following the the guide found here:
https://source.android.com/devices/tech/ota/sign_builds
After completing the steps, I use the now signed images found in the "signed-img.zip" file to flash the device (using the NXP Manufacturing Tool, and not Fast Boot). However, the device now fails to boot the Kernel, giving me an error that the DTB is missing.
Hit any key to stop autoboot: 0
boota mmc0
kernel # 14008000 (8183104)
ramdisk # 15000000 (2036048)
## Booting Android Image at 0x12000000 ...
Kernel load addr 0x14008000 size 7992 KiB
Kernel command line: console=ttymxc0,115200 init=/init video=mxcfb0:dev=ldb video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off vmalloc=128M androidboot.console=ttymxc0 consoleblank=0 ldo_active=on androidboot.hardware=sedevices cma=448M android.selinux=permissive android.dm_verify=disable androidboot.selinux=enforce androidboot.dm_verity=disable androidboot.storage_type=emmc loglevel=8 vt.global_cursor_default=0 buildvariant=userdebug androidboot.serialno=0b2861d4df668b47 androidboot.soc_type=imx6dl androidboot.storage_type=emmc
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree
resetting ...
I've narrowed the problem down to the very first step in the guide, where "make dist" is executed in the build directory. This produces a number of ZIP files in the "out/dist" folder, which is processed further in the following steps in the guide. I've tried flashing the device with the images produced in this step (found in the resulting "out/dist/*-img-*.zip" file), and this produces the exact same issue.
So my question is, what does really "make dist" do which cause the DTB to be missing in the "boot.img"? I would've expected it to use the already working "boot.img" found in "out/target/product//". But it instead seems to re-build this image, and in this case not include the DTB. As with so many other aspects of building Android from Source, the workings of "make dist" does not seem to be explained anywhere in the documentation.
I hope anyone with some experience in building Android from source knows something about this, because I seem to be royally stuck.
Just FYI; when I flash the "boot.img" produced after a normal "make", the output after U-boot is as follows:
Hit any key to stop autoboot: 0
boota mmc0
Error: blob decap job completed with errors 0x2000081A
In boota get fastboot lock status error. Set lock status
kernel # 14008000 (8183104)
ramdisk # 15000000 (2036754)
fdt # 14f00000 (40998)
## Booting Android Image at 0x12000000 ...
Kernel load addr 0x14008000 size 7992 KiB
Kernel command line: console=ttymxc0,115200 init=/init video=mxcfb0:dev=ldb video=mxcfb1:off video=mxcfb2:off video=mxcfb3:off vmalloc=128M androidboot.console=ttymxc0 consoleblank=0 ldo_active=on androidboot.hardware=sedevices cma=448M android.selinux=permissive android.dm_verify=disable androidboot.selinux=enforce androidboot.dm_verity=disable androidboot.storage_type=emmc loglevel=8 vt.global_cursor_default=0 buildvariant=userdebug androidboot.serialno=0b2861d4df668b47 androidboot.soc_type=imx6dl androidboot.storage_type=emmc
## Flattened Device Tree blob at 14f00000
Booting using the fdt blob at 0x14f00000
Loading Kernel Image ... OK
Using Device Tree in place at 14f00000, end 14f0d025
switch to ldo_bypass mode!
Starting kernel ...
It seem NXP/Freescale have modified the Build Scripts in their AOSP Board Support Package, and broken the DTB inclusion in the process. It may seem like they where happy when the output from the standard "make" process worked on their Dev Board, and never bothered checking if it was possible to create working signed Release images with it.
The mechanism to include a DTB in the dist package was in place (specifying the location of the DTB in BOARD_KERNEL_DTS), and was also used for their "make otapackage" target. However, that target only generates an unsigned (or signed with dev keys) OTA package, which can not be used with the signing scripts.
In order to make it work as it should, I had to make a small change in the main Makefile which specifies the location of the DTB defined in the BoardConfig.mk. The change was simple enough to make, but the hard part was figuring out where the problem was and how it was intended to work in the first place.
The following patch in "build/make/" fixes the issue, as long as a BoardConfig.mk ONLY specifies one DTB (which at least suits my needs):
diff --git a/core/Makefile b/core/Makefile
index a650565a1..92f3025a9 100644
--- a/core/Makefile
+++ b/core/Makefile
## -621,6 +621,19 ## ifdef INTERNAL_KERNEL_CMDLINE
INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
endif
+# NOTE! This script has a defect which cause the kernel DTB to be left out when ever 'make dist'
+# is executed. The following addition "fixes" this by adding the first dtb specified in the
+# BoardConfig.mk file. (I would guess in most cases there is never more than one!)
+ifdef dist_goal
+ifndef BOARD_KERNEL_DTS
+ifdef TARGET_BOARD_DTS_CONFIG
+DTS_BOARD=$(word 2, $(subst :, ,$(word 1, $(TARGET_BOARD_DTS_CONFIG))))
+BOARD_KERNEL_DTS="$(KERNEL_OUT)/$(DTS_BOARD)"
+$(info FIXUP: Defining BOARD_KERNEL_DTS:=[$(BOARD_KERNEL_DTS)] for BOOT packaging)
+endif
+endif
+endif
+
INTERNAL_MKBOOTIMG_VERSION_ARGS := \
--os_version $(PLATFORM_VERSION) \
--os_patch_level $(PLATFORM_SECURITY_PATCH)
i went to distribute.sh in python-for-android and then type then i type this command "./distribute.sh -m "kivy nmap" where nmap is thired party module for python but i am receiving this error ...
Call postbuild_python
Call postbuild_sdl
Call postbuild_pygame
Call postbuild_pyjnius
Call postbuild_android
Call postbuild_kivy
Run pymodules install
We want to install: nmap
Check if /usr/local/bin/virtualenv is present
Check if a virtual environment already exists
Installing virtualenv
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in venv/bin/python2.7
Also creating executable in venv/bin/python
Installing setuptools, pip, wheel...done.
Create a requirement file for pure-python modules
Install pure-python modules via pip in venv
/root/.buildozer/android/platform/python-for-android/build/venv/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
DEPRECATION: --download-cache has been deprecated and will be removed in the future. Pip now automatically uses and configures its cache.
Collecting nmap (from -r requirements.txt (line 1))
/root/.buildozer/android/platform/python-for-android/build/venv/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Could not find a version that satisfies the requirement nmap (from -r requirements.txt (line 1)) (from versions: )
No matching distribution found for nmap (from -r requirements.txt (line 1))
please solve this someone
Check if virtualenv is present
Tool virtualenv is missing
Install virtualenv.
Edit: Since you edited your question:
No matching distribution found for nmap (from -r requirements.txt (line 1))
There is no module named nmap on pypi (and therefore installable with pip). If your module isn't installable this way, you can't just put it in the requirements line. If this is the case, copy the module to your app dir and it will be included with the app.
I have just built Libgit2 (v0.20.0) for Android (target SDK version 18, debugging on a rooted device running Cyanogenmod 10.1.2, Android 4.2.2) and a simple function like getting the version number of Libgit2 works fine through the JNI. But when I use the git_clone function it stops right after the objects/info folder is created and returns this error:
Error -1 cloning repository - Failed to set permissions on '/storage/sdcard0/it/ptt/.git/objects/info': Operation not permitted
I have given the application the WRITE_EXTERNAL_STORAGE permission but I guess it still can't chmod unless owner of the file. When I use adb shell to check out the permission mode of the info folder I get:
d---rwxr-x system sdcard_rw 2014-05-15 09:31 info
And by using pwd.h functions I get the username that the c code (that is calling git_clone) is under to be u0_a92. How am I suppose to get pass this I suppose very Android related issue? Is there a simple way to stop Libgit2 from calling p_chmod or can I give it permissions to do so?
I ended up defining p_chmod as a method always returning true to get passed the error. In the bash script I use to build libgit2 I inserted the following lines that leaves the source files in an unmodified condition after building for android:
LIBGIT2_POSIX_PATH="$LIBGIT2_SOURCE_PATH/src/posix.h"
LIBGIT2_POSIX_BACKUP_PATH="$LIBGIT2_SOURCE_PATH/src/posix_original.h"
printf "#include \"always_success.h\"\nint always_success() { return 0; }" > "$LIBGIT2_SOURCE_PATH/src/always_success.c"
printf "int always_success();" > "$LIBGIT2_SOURCE_PATH/src/always_success.h"
cp $LIBGIT2_POSIX_PATH "$LIBGIT2_POSIX_BACKUP_PATH"
sed -i "s/^#define\sp_chmod(p, m).*$/#include \"always_success.h\"\n#define p_chmod(p, m) always_success()\nextern int always_success();\n/" $LIBGIT2_POSIX_PATH
# run the build process with cmake ...
# restore chmod manipulated source header
mv $LIBGIT2_POSIX_BACKUP_PATH $LIBGIT2_POSIX_PATH
There is probably a cleaner way to solve this but at least now I dont get that error anymore. Thanks to Carlos for his help!
UPDATE
Running adb shell mount | grep sdcard I could see that the sdcard which I am trying to clone the repository into uses the vfat file system which according to this forum thread doesn't support unix-style permissions.
Given an APK, is it possible to determine which version of Android platform it targets?
Use aapt:
aapt list -a package.apk | grep SdkVersion
You will see version numbers in hex. e.g.:
A: android:minSdkVersion(0x0101020c)=(type 0x10)0x3
A: android:targetSdkVersion(0x01010270)=(type 0x10)0xc
For this apk, minSdkVersion is 0x3 i.e. 3, and targetSdkVersion is 0xc i.e. 12.
simply use aapt dump badging my_apk_file.apk to get a lot of info about your apk.
grep filter by Version
aapt dump badging my_apk_file.apk|grep Version
Output with $ANDROID_SDK_ROOT/build-tools/30.0.3/aapt:
package: name=... versionCode=... versionName=... compileSdkVersion='29' compileSdkVersionCodename='10'
sdkVersion:'11'
targetSdkVersion:'29'
The apk for any installed app $app (eg com.google.android.apps.docs) can be retrieved from your device with:
adb pull $(adb shell dumpsys package $app | grep path: | cut -c11-) $app.apk
Use apktool
java -jar apktool.jar d app.apk
Then look in the generated apktool.yml file for this:
sdkInfo:
minSdkVersion: '11'
targetSdkVersion: '17'
You can match the SDK version to Android version here. In the above example minimum Android version is 3.0 and target version is 4.2.
You can use apkanalyzer, it is is included in the Android SDK Tools, more infos here https://developer.android.com/studio/command-line/apkanalyzer
Prints the minimum SDK version.
apkanalyzer -h manifest min-sdk myapk.apk
Prints the target SDK version
apkanalyzer -h manifest target-sdk myapk.apk
You can extract the APK and look in the manifest file for the platform target.
like derek said above
use the apktool to decompile the apk and check the manifest version
platform versions can be found here
If you don't have grep, you can use
aapt list -a package.apk >file.txt
and search for minSdkVersion and targetSdkVersion in file.txt.
If you want to find these info from your mobile device you can install My APK app which gives you good information about apps
You can get it at https://play.google.com/store/apps/details?id=com.andatsoft.myapk.fwa&hl=en
The app which you want to have these information about, must either installed on your mobile device or you must have the app apk on your mobile.
The fastest way to get APK information is to use this online tool :
https://www.sisik.eu/apk-tool
In my case, I opened the apk file on Android Studio. So I can check the version of android at AndroidManifest.xml.
if you want it programmatically try use PackageManager class:
public PackageManager getPackageArchiveInfo(String archiveFilePath, int flags)
then read ApplicationInfo field and targetSdkVersion in it;
You can run following command to just get the API level (integer):
aapt dump badging "your_apk.apk" | awk '/targetSdkVersion/{gsub("targetSdkVersion:''|''",""); print $1}'
The output you'll get will be as below, in case it was compiled against KitKat (API 19):
19
PS: aapt is located in folder <Android-Sdk>/build-tools/<build-tools-version>/.
To find the platform targets for an APK file, use apktool.
Follow these instructions:
Use the GitHub repo to install it https://ibotpeaches.github.io/Apktool/.
After installing then run the following command -> apktool d file.apk
open the file folder.
locate the file named apktool.yml
the information is found in the SDK info:
Image 1, Image 2
If you are using Nautilus, you can add a column provider and a property page provider for APK files. This will provide lots of informations, including SdkVersion.
Steps are explained on this link : http://bernaerts.dyndns.org/linux/76-gnome/324-gnome-nautilus-apk-column-property-provider-extension
Cheers.
You can use http://www.javadecompilers.com/apk to decomplier file apk and you can find it in Mandifest
Another bush util function:
function android-target-sdk-version {
aapt list -a $1 | grep targetSdkVersion | grep -o '....$' | awk '{print $1+0}'
}