Android tips - yszheda/wiki GitHub Wiki

References

Hardware specs

CPU

adb shell getprop ro.product.cpu.abi

number of cpu cores

cat /sys/devices/system/cpu/present
cat /sys/devices/system/cpu/possible

Memory


adb shell am dumpheap your.package.name /sdcard/heap-original.hprof
adb pull /sdcard/heap-original.hprof .
$ANDROID_SDK/platform-tools/hprof-conv heap-original.hprof heap-converted.hprof

static long getNativeHeapAllocatedSize(JNIEnv *env)
{
    jclass clazz = env->FindClass("android/os/Debug");
    if (clazz)
    {
        jmethodID mid = env->GetStaticMethodID(clazz, "getNativeHeapAllocatedSize", "()J");
        if (mid)
        {
            return env->CallStaticLongMethod(clazz, mid);
        }
    }
    return -1L;
}

static long getNativeHeapSize(JNIEnv *env)
{
    jclass clazz = env->FindClass("android/os/Debug");
    if (clazz)
    {
        jmethodID mid = env->GetStaticMethodID(clazz, "getNativeHeapSize", "()J");
        if (mid)
        {
            return env->CallStaticLongMethod(clazz, mid);
        }
    }
    return -1L;
}

DDMS

dumpNativeHeap

GPU

adb shell dumpsys

GPU monitor

Busybox

warnings as errors

static cannot use -fsanitize=address

-llsan not found

modutils-24.c query_module undefined

Static linking against glibc, can't use --gc-sections

SDK

ConstraintLayout

Cross compile

Enable NEON

error: only position independent executables (PIE) are supported.

Lib

OpenCV

OpenBLAS

Relocations in generic ELF (EM: 40)

Android.mk

AndroidManifest.xml

The file name must end with .xml or .png

Launch or kill APP

adb shell am start -n com.package.name/com.package.name.ActivityName
adb shell am kill com.package.name/com.package.name.ActivityName