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版

相关文章
相关标签/搜索