Menu Home

android构建工具

Android Gradle: SDK License Agreements

* What went wrong: A problem occurred configuring project ‘:mi’. > Failed to notify project evaluation listener. > You have not accepted the license agreements of the following SDK components: [Android SDK Build-Tools 25]. Before building your project, you need to accept the license agreements and complete the installation of […]

Android:Build x264 for arm64

export NDK=$ANDROID_NDK export PREBUILT_ARM64=$NDK/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64 export X264_ANDROID_PREFIX_ARM64=$X264_BUILD_ROOT/output/arm64 function build_arm64 { ./configure \ –prefix=$X264_ANDROID_PREFIX_ARM64 \ –enable-static \ –enable-pic \ –host=aarch64-linux \ –cross-prefix=$PREBUILT_ARM64/bin/aarch64-linux-android- \ –sysroot=$PLATFORM_ARM64 make clean make make install echo “Build libx264 arm64 Finished !!!” } If you compile ffmpeg with libx264.a , you MUST use same NDK toolchains. Otherwise cannot link […]

Build WebRTC

First of All, You have evaded the “WALL”. God bless you. Host OS: Ubuntu 16.04 LTE Build Tools git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git Then add depot_tools to your PATH Checkout Source Set the target OS Here, I will build webrtc for Andorid platform. export GYP_DEFINES=”OS=android” Sync Source mkdir webrtc_android cd webrtc_android fetch […]

Android:Get Certificate SHA1 with JNI

#include <assert.h> #include <string.h> #include <stdio.h> #include <android/log.h> const char HexCode[]={‘0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’A’,’B’,’C’,’D’,’E’,’F’}; static void byte_array_to_hex_string(JNIEnv *env, const jbyteArray array, const jsize array_size, char *hex_string) { jbyte *sha1 = (*env)->GetByteArrayElements(env, array, NULL); for (int i = 0; i < array_size; i++) { hex_string[i * 2] = HexCode[((unsigned char)sha1[i]) / 16]; hex_string[i * […]

Android Studio: Change AAR Build Name

android.libraryVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith(‘.aar’)) { def fileName = “Your aar package name” output.outputFile = new File(outputFile.parent, fileName) } } } Rebuild your project, you will find the aar package file at build/outputs/aar

Android FW: make file 引用三方库

LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-subdir-Iaidl-files) LOCAL_JAVA_LIBRARIES := services telephony-common LOCAL_STATIC_JAVA_LIBRARIES := MyLib LOCAL_PACKAGE_NAME := Keyguard LOCAL_CERTIFICATE := platform LOCAL_PRIVILEGED_MODULE := true LOCAL_PROGUARD_FLAG_FILES := proguard.flags include $(BUILD_PACKAGE) include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := MyLib:libs/mylib-v8.jar include $(BUILD_MULTI_PREBUILT)

Android自定义系统属性

增加自定义属性涉及的文件: /build/toos/buildinfo.sh 比如这里增加了一个系统默认输入法的属性: echo “ro.product.IME.default=com.android.inputmethod.pinyin/.PinyinIME” 也可以加在device目录下的system.prop文件中,最终都会输出到build.prop rebuild出来的system.img中的build.prop就有了上面的属性。 通过下面的代码来访问这个自定义属性: String defaultIme = SystemProperties.get(“ro.product.IME.default”, “com.android.inputmethod.latin/.LatinIME”); 这里的SystemProperties为@hide类,所以需要在Android Source中使用上面的代码。 有了需要的属性后,就可以在Android机器中修改这个属性值了,但是需要注意一点: 如果是通过adb pull后再push到android机器的话,需要确保build.prop文件的权限为644,否则进不了系统。

Android控制生成ODEX

如果没有指定DISABLE_DEXPREOPT,那么user版将生成odex,其他版本不会生成odex文件。 相关文件在build/core/main.mk ifneq (true,$(DISABLE_DEXPREOPT)) ifeq ($(user_variant),user) ifeq ($(HOST_OS),linux) WITH_DEXPREOPT := true endif endif endif 如果user版不想生成odex,那么需要定义 DISABLE_DEXPREOPT := true 如果eng版要生成odex,那么需要定义 WITH_DEXPREOPT := true 如果想单独控制某一应用是否生成odex,可以在应用的Android.mk中定义 WITH_DEXPREOPT := true