跳到主要內容

[Android][AOSP][ddmlib][Intelij IDEA][Gradle]搭建Android ddmlib編譯環境

Android ddmlib在AOSP的platform/tools/base的repo內
可以使用以下指令將整個repo的master branch抓回:
git clone https://android.googlesource.com/platform/tools/base
取其中的annotations、common、ddmlib

建立Intelij IDEA專案

使用Intelij IDEA開一新的Java Project,GroupId、ArtifictedId、Version隨便,並使用graddle wrapper方式建立專案:
GroupId 'com.android.tools.ddms'
ArtifictedId = 'ddmlib'
Version '1.0-SNAPSHOT'
刪除IDE建立的src資料夾,建立base資料夾,將annotations、common、ddmlib複製進來
參考Android Studio建立的專案,修改build.gradle為:
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenCentral()
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
修改settings.gradle,加入annotations、common、ddmlib為include
rootProject.name = 'ddmlib'
include ':base:annotations'
include ':base:common'
include ':base:ddmlib'
修改annotations、common、ddmlib內的build.gradle
替換apply plugin: 'sdk-java-lib'為apply plugin: 'java-library'
給定version '1.0-SNAPSHOT'
刪除apply from: "$rootDir/buildSrc*的那幾行
即可編譯成功!!
以上放在Github: https://github.com/eric100lin/ddmlib-study

留言