Android 開發環境搭建以及工具(不斷更新)

 

學習android須要學習的編程知識

https://wiki.cyanogenmod.org/w/Doc:_Development_Resourcesphp

 

從http://source.android.com/source下載的網頁

http://pan.baidu.com/s/1sjoMt5rhtml

Android開發軟件Android Studio

http://www.android-studio.org/index.php前端

 

詳細顯示編譯過程

make -j4 showcommands

 一些經常使用的編譯目標

Here is a list of different make targets you can use to build different parts of the system:

    make sdk - build the tools that are part of an SDK (adb, fastboot, etc.)
    make snod - build the system image from the current software binaries
    make services
    make runtime
    make droid - make droid is the normal build.
    make all - make everything, whether it is included in the product definition or not
    make clean - remove all built files (prepare for a new build). Same as rm -rf out/<configuration>/
    make modules - shows a list of submodules that can be built (List of all LOCAL_MODULE definitions)
    make <local_module> - make a specific module (note that this is not the same as directory name. It is the LOCAL_MODULE definition in the Android.mk file)
    make clean-<local_module> - clean a specific module
    make bootimage TARGET_PREBUILT_KERNEL=/path/to/bzImage - create a new boot image with custom bzImage

一些經常使用的宏和函數

There are some helper macros and functions that are installed when you source envsetup.sh. They are documented at the top of envesetup.sh, but here is information about a few of them:

    croot - change directory to the top of the tree
    m - execute 'make' from the top of the tree (even if your current directory is somewhere else)
    mm - builds all of the modules in the current directory
    mmm <dir1> ... - build all of the modules in the supplied directories
    cgrep <pattern> - grep on all local C/C++ files
    jgrep <pattern> - grep on all local Java files
    resgrep <pattern> - grep on all local res/*.xml files
    godir <filename> - go to the directory containing a file

 

 介紹Android源碼下每一個目錄的做用

 https://wiki.cyanogenmod.org/w/Doc:_the_cm_sourcepython

從新編譯某個模塊

 

To rebuild only the module which you are changing (ie, the stuff in your current directory), you can usually do this:

mm -B 

將Android源碼導入Android Studio

https://wiki.cyanogenmod.org/w/Doc:_import_to_intellijlinux

 

Android調試工具

1. systrace  android

(用systrace調試display system:http://files.cnblogs.com/files/pengdonglin137/Systrace_for_Display_System-140420101020-phpapp02%281%29.pdf)
web

用法:systrace這個工具在Android源碼目錄下的external/chromium-trace/下,用法(使用-h參數能夠得到更詳細的幫助信息):shell

  •  ./systrace.py -e emulator-5554 -l        

                 gfx - Graphics
       input - Input
        view - View System
     webview - WebView
          wm - Window Manager
          am - Activity Manager
          sm - Sync Manager
       audio - Audio
       video - Video
      camera - Camera
         hal - Hardware Modules
         app - Application
         res - Resource Loading
      dalvik - Dalvik VM
          rs - RenderScript
      bionic - Bionic C Library
       power - Power Management
       sched - CPU Scheduling
         irq - IRQ Events
        freq - CPU Frequency
        idle - CPU Idle
        disk - Disk I/O
         mmc - eMMC commands
       workq - Kernel Workqueues
  memreclaim - Kernel Memory Reclaim


編程

  • ./systrace.py -e emulator-5554 gfx sched video -t 60 -o "`date +%y-%m-%d-%H-%M-%S`".html
  • 那麼如何在要調試的代碼中加入相應的systrace能夠識別的信息呢?

以media/libmedia/AudioTrack.cpp爲例:windows

#define ATRACE_TAG  ATRACE_TAG_ALWAYS  

// 表示一直會打開,若是是ATRACE_TAG_AUDIO,則須要在systrace中加入audio參數才能看到

#include <utils/Trace.h>

而後在須要調試的函數的入口(以AudioTrack::start)爲例:

 status_t AudioTrack::start()
 {
+    ATRACE_NAME("AudioTrack::start");
     status_t status = NO_ERROR;
     AutoMutex lock(mLock);
     if (mState == STATE_ACTIVE) {
或者

 status_t AudioTrack::start()
 {
+    ATRACE_CALL();
     status_t status = NO_ERROR;
     AutoMutex lock(mLock);
     if (mState == STATE_ACTIVE) {

 

2. dumpsys

3. pytimechart 

4. ftrace 和 trace_cmd

媒體文件從新識別

下面的命令能夠讓sdcard上的媒體文件從新識別,當使用adb push命令向手機裏放入媒體文件後,手機並不能當即識別這個媒體文件,須要重啓手機,下面的命令能夠不用重啓手機。

 

#! /bin/bash

adb shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///mnt/sdcard/

 

Android示例代碼學習

在android源代碼的cts目錄下有不少示例代碼,其中的程序都不是很複雜,值得學習一下。

media相關的: cts/tests/tests/media/src/android/media/cts

graphic相關的: cts/tests/tests/graphics/src/android/graphics/cts

 

ADB 工具

下載地址:https://developer.android.com/studio/releases/platform-tools.html

或者點擊這裏下載: windows版   Linux版

相關文章
相關標籤/搜索