Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android實戰技巧之四十一:制作自己的Android SDK

Android實戰技巧之四十一:制作自己的Android SDK

編輯:關於Android編程

編譯自己的SDK

特種設備會有一些額外的功能,這樣就需要給應用層提供特定的API,從而需要定制自己的SDK。
編譯自己的sdk還是很簡單的,因為google幫我們做好基礎工作,步驟如下:

$ source build/envsetup.sh 
$launch 'what you want'
$ make update-api
$ make PRODUCT-sdk-sdk -j8

如果一切順利的編譯完成,那麼恭喜你。如果遇到錯誤也不要緊,因為這是正常的。下面列出我遇到的主要錯誤:tools/base沒有。
error1:

sdk/eclipse/scripts/create_all_symlinks.sh: line 285: cd: tools/base: No such file or directory
...
sdk/eclipse/scripts/create_all_symlinks.sh: line 285: cd: tools/base: No such file or directory
...
sdk/eclipse/scripts/create_all_symlinks.sh: line 47: cd: tools/base: No such file or directory
make: *** [out/host/linux-x86/obj/EXECUTABLES/monitor_intermediates/monitor] Error 1

modify create_all_symlinks.sh
將文件中所有需要tools/base的地方都注釋掉。

error2:

sdk/build/tools.atree:124: couldn't locate source file: tools/base/templates/projects
sdk/build/tools.atree:125: couldn't locate source file: tools/base/templates/activities
sdk/build/tools.atree:126: couldn't locate source file: tools/base/templates/gradle
sdk/build/tools.atree:127: couldn't locate source file: tools/base/templates/other
make: *** [out/host/linux-x86/sdk/android-sdk_eng.linc_linux-x86.zip] Error 44

modify tools.atree

$ vim sdk/build/tools.atree
# Templates
#tools/base/templates/projects                  tools/templates/projects
#tools/base/templates/activities                tools/templates/activities
#tools/base/templates/gradle                    tools/templates/gradle
#tools/base/templates/other                     tools/templates/other

再次修改後就離成功不遠了,下面是成功的log。

Package SDK: out/host/linux-x86/sdk/android-sdk_eng.linc_linux-x86.zip
SDK: warning: including GNU target out/target/product/generic/system/lib/libgccdemangle.so

使用SDK

將android-sdk_eng.linc_linux-x86.zip解壓到你喜歡的目錄,在Android Studio的設置如下:
File—>Project Structure—>SDK Location,填寫你剛剛解壓的目錄即可。
試著用自定義的API做測試吧,good luck!

 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved