Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SunRain/1681491 to your computer and use it in GitHub Desktop.
Save SunRain/1681491 to your computer and use it in GitHub Desktop.
Android SDK Emulator: Compile CyanogenMod (SUSE)
NOTE: You only need to do these steps the first time you build. If you previously prepared your build environment, skip to Download RomManager.
NOTE:
在准备开工之前,请务必确保硬盘工作空间不少于20G(最低不能低于15G),且不能是VFAT或NTFS格式。
Install the ADB
Install the Android SDK.
Install the Build Packages
Install using the package manager of your choice:
For 32-bit & 64-bit systems:
git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk pngcrush schedtools
NOTE:
FOR OPENSUSE : bison flex gperf schedtool squashfs libesd-devel build libSDL-devel gcc-c++ java-1_6_0-sun java-1_6_0-sun-devel
For 64-bit only systems:
g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline5-dev gcc-4.3-multilib g++-4.3-multilib
Note: On Ubuntu 10.10, and variants, you need to enable the parter repository to install sun-java6-jdk:
add-apt-repository "deb http://archive.canonical.com/ maverick partner"
Create the Directories
You will need to set up some directories in your build environment.
To create them:
mkdir -p ~/bin
mkdir -p ~/android/system
Install the Repository
Enter the following to download make executable the "repo" binary:
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
NOTE: You may need to reboot for these changes to take effect.
Now enter the following to initialize the repository:
cd ~/android/system/
repo init -u http://github.com/CyanogenMod/android.git -b gingerbread
repo sync -j16
NOTE:
1、完整下载约5G多,下载过程不能断网;
2、实际表明,使用http连接方式获取代码更佳;
3、如果下载过程断链出错退出,或者手动kill过python进程,在执行sync之前需要删除临时文件:
find .repo/ -name tmp* -exec rm {} \;
4、如果下载完成,长时间等待下面提示时;
Fetching projects: 98% (208/211)
则需要kill掉python进程,去掉 -j16 参数再次同步
repo sync
5、如果下载过程中报某个目录一直出错,则需删除该目录再同步
6、如果想少下载一些文件,则可以不下载针对具体设备的代码(可以减少下载2G左右的内容),方法如下:
a. repo init 执行完毕后,编辑 .repo/manifest.xml 文件,注释掉device相关的projiect,如下
<project path="dalvik" name="CyanogenMod/android_dalvik" />
<project path="development" name="CyanogenMod/android_development" />
<project path="device/common" name="CyanogenMod/android_device_common" />
<project path="device/sample" name="CyanogenMod/android_device_sample" />
<!--
<project path="device/advent/vega" name="CyanogenMod/android_device_advent_vega" />
<project path="device/common" name="CyanogenMod/android_device_common" />
<project path="device/zte/blade" name="CyanogenMod/android_device_zte_blade" />
……
<project path="device/zte/v9" name="CyanogenMod/android_device_zte_v9" />
-->
<project path="external/alsa-lib" name="CyanogenMod/android_external_alsa-lib" />
b. repo sync 完成后,编辑 vendor/cyanogen/products/AndroidProducts.mk 文件,只保留下面内容
PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/cyanogen_generic.mk
7、如果在需认证的proxy(如公司网络)下同步,则请务必更新python版本到2.7,否则可能出错。
Download RomManager
NOTE: This only needs to be done when an update to RomManager is released. If you are-up-to date, you may skip toBuilding CyanogenMod.
Download ROM Manager which is needed by the build:
cd ~/android/system/vendor/cyanogen/
./get-rommanager
Building CyanogenMod
Check for updates
First, check for updates in the source:
cd ~/android/system/
repo sync
Configure Build
Now, your environment must be configured to build specifically for the Android Emulator. To set up your build environment:
. build/envsetup.sh
lunch cyanogen_generic-eng
NOTE:
1、新建shell进入工作目录之后都需要执行上述命令
2、如果想彻底重新编译,需执行 make clean
3、FOR OPENSUSE:
去掉OpenSuSE普通用户下执行envsetup.sh的提示:修改 schedtool 为 /usr/sbin/schedtool 即可。
function mka() {
case `uname -s` in
Darwin)
make -j `sysctl hw.ncpu|cut -d" " -f2` "$@"
;;
*)
/usr/sbin/schedtool -B -n 1 -e ionice -n 1 make -j `cat /proc/cpuinfo | grep "^processor" | wc -l` "$@"
;;
esac
}
Compile
Next, we will build the actual ROM.
mka
NOTE:
1、参考编译时间:90min(ThinkPad T61 ,3GB RAM )
2、编译出错处理(自己摸索的,非官方)
错误1:编译约1个小时后出现的:
target Strip: libutils (out/target/product/generic/obj/lib/libutils.so)
target Dex: QuickSearchBox
frameworks/base/core/java/android/widget/VideoView.java:46: package com.ti.omap.omap_mm_library does not exist
import com.ti.omap.omap_mm_library.OmapMMLibrary;
^
frameworks/base/core/java/android/widget/VideoView.java:62: cannot find symbol
symbol : class OmapMMLibrary
location: class android.widget.VideoView
private OmapMMLibrary mOmapMMHandle = null;
^
frameworks/base/core/java/android/widget/VideoView.java:196: cannot find symbol
symbol : class OmapMMLibrary
location: class android.widget.VideoView
mOmapMMHandle = new OmapMMLibrary();
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar] Error 41
make: *** Waiting for unfinished jobs....
错误分析和处理:
看起来是OmapMMLibrary的找不到,后来发现此代码在framework/base/omapmmlib中,修改 build/core/pathmap.mk的FRAMEWORKS_BASE_SUBDIRS,如下
FRAMEWORKS_BASE_SUBDIRS := \
$(addsuffix /java, \
core \
graphics \
location \
media \
opengl \
sax \
telephony \
wifi \
vpn \
keystore \
voip \
omapmmlib\
)
错误2:编译即将完成时出现的,此时system.img还未生成
Checking API: checkapi-last
Checking API: checkapi-current
(unknown): error 13: Class android.app.Profile changed final qualifier
(unknown): error 13: Class android.app.ProfileGroup changed final qualifier
(unknown): error 24: Method android.app.ProfileManager.getProfile has changed deprecation state
(unknown): error 24: Method android.app.ProfileManager.setActiveProfile has changed deprecation state
(unknown): error 3: Added class MultiSelectListPreference to package android.preference
(unknown): error 4: Added public method android.app.Profile.getProfileGroup
(unknown): error 4: Added public method android.app.Profile.getStatusBarIndicator
(unknown): error 4: Added public method android.app.Profile.getUuid
(unknown): error 4: Added public method android.app.Profile.setStatusBarIndicator
(unknown): error 4: Added public method android.app.ProfileGroup.getUuid
(unknown): error 4: Added public method android.app.ProfileManager.getProfile
(unknown): error 4: Added public method android.app.ProfileManager.profileExists
(unknown): error 4: Added public method android.app.ProfileManager.setActiveProfile
(unknown): error 4: Added public method android.telephony.TelephonyManager.isDormancyRejected
(unknown): error 4: Added public method android.telephony.TelephonyManager.setDormancyRejected
(unknown): error 5: Added public field android.Manifest.permission.RAW_AUDIO
(unknown): error 9: Removed public method android.app.Profile.getProfileGroup
(unknown): error 9: Removed public method android.app.ProfileGroup.getName
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1) You can add "@hide" javadoc comments to the methods, etc. listed in the
errors above.
2) You can update current.xml by executing the following command:
make update-api
To submit the revised current.xml to the main Android repository,
you will need approval.
******************************
make: *** [out/target/common/obj/PACKAGING/checkapi-current-timestamp] Error 38
make: *** Waiting for unfinished jobs....
htmlDir not a directory: out/target/common/docs/gen
DroidDoc took 252 sec. to write docs to out/target/common/docs/doc-comment-check
错误处理:执行一次 make update-api 后编译可以顺利完成。
Install
Create a folder called android-9-cyanogen on Your/Android-SDK/platforms/
Copy the contents of Your/Android-SDK/platforms/android-9 into Your/Android-SDK/platforms/android-9-cyanogen
Copy the ramdisk.img system.img and userdata.img file from ~/android/system/out/target/product/generic toYour/Android-SDK/platforms/android-9-cyanogen/images/
Run the Android AVD Manager and select the second Android 2.3 target.
NOTE: You only need to do these steps the first time you build. If you previously prepared your build environment, skip to Download RomManager.
NOTE:
在准备开工之前,请务必确保硬盘工作空间不少于20G(最低不能低于15G),且不能是VFAT或NTFS格式。
Install the ADB
Install the Android SDK.
Install the Build Packages
Install using the package manager of your choice:
For 32-bit & 64-bit systems:
git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk pngcrush schedtools
NOTE:
FOR OPENSUSE : bison flex gperf schedtool squashfs libesd-devel build libSDL-devel gcc-c++ java-1_6_0-sun java-1_6_0-sun-devel
For 64-bit only systems:
g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline5-dev gcc-4.3-multilib g++-4.3-multilib
Note: On Ubuntu 10.10, and variants, you need to enable the parter repository to install sun-java6-jdk:
add-apt-repository "deb http://archive.canonical.com/ maverick partner"
Create the Directories
You will need to set up some directories in your build environment.
To create them:
mkdir -p ~/bin
mkdir -p ~/android/system
Install the Repository
Enter the following to download make executable the "repo" binary:
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
NOTE: You may need to reboot for these changes to take effect.
Now enter the following to initialize the repository:
cd ~/android/system/
repo init -u http://github.com/CyanogenMod/android.git -b gingerbread
repo sync -j16
NOTE:
1、完整下载约5G多,下载过程不能断网;
2、实际表明,使用http连接方式获取代码更佳;
3、如果下载过程断链出错退出,或者手动kill过python进程,在执行sync之前需要删除临时文件:
find .repo/ -name tmp* -exec rm {} \;
4、如果下载完成,长时间等待下面提示时;
Fetching projects: 98% (208/211)
则需要kill掉python进程,去掉 -j16 参数再次同步
repo sync
5、如果下载过程中报某个目录一直出错,则需删除该目录再同步
6、如果想少下载一些文件,则可以不下载针对具体设备的代码(可以减少下载2G左右的内容),方法如下:
a. repo init 执行完毕后,编辑 .repo/manifest.xml 文件,注释掉device相关的projiect,如下
<project path="dalvik" name="CyanogenMod/android_dalvik" />
<project path="development" name="CyanogenMod/android_development" />
<project path="device/common" name="CyanogenMod/android_device_common" />
<project path="device/sample" name="CyanogenMod/android_device_sample" />
<!--
<project path="device/advent/vega" name="CyanogenMod/android_device_advent_vega" />
<project path="device/common" name="CyanogenMod/android_device_common" />
<project path="device/zte/blade" name="CyanogenMod/android_device_zte_blade" />
……
<project path="device/zte/v9" name="CyanogenMod/android_device_zte_v9" />
-->
<project path="external/alsa-lib" name="CyanogenMod/android_external_alsa-lib" />
b. repo sync 完成后,编辑 vendor/cyanogen/products/AndroidProducts.mk 文件,只保留下面内容
PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/cyanogen_generic.mk
7、如果在需认证的proxy(如公司网络)下同步,则请务必更新python版本到2.7,否则可能出错。
Download RomManager
NOTE: This only needs to be done when an update to RomManager is released. If you are-up-to date, you may skip toBuilding CyanogenMod.
Download ROM Manager which is needed by the build:
cd ~/android/system/vendor/cyanogen/
./get-rommanager
Building CyanogenMod
Check for updates
First, check for updates in the source:
cd ~/android/system/
repo sync
Configure Build
Now, your environment must be configured to build specifically for the Android Emulator. To set up your build environment:
. build/envsetup.sh
lunch cyanogen_generic-eng
NOTE:
1、新建shell进入工作目录之后都需要执行上述命令
2、如果想彻底重新编译,需执行 make clean
3、FOR OPENSUSE:
去掉OpenSuSE普通用户下执行envsetup.sh的提示:修改 schedtool 为 /usr/sbin/schedtool 即可。
function mka() {
case `uname -s` in
Darwin)
make -j `sysctl hw.ncpu|cut -d" " -f2` "$@"
;;
*)
/usr/sbin/schedtool -B -n 1 -e ionice -n 1 make -j `cat /proc/cpuinfo | grep "^processor" | wc -l` "$@"
;;
esac
}
Compile
Next, we will build the actual ROM.
mka
NOTE:
1、参考编译时间:90min(ThinkPad T61 ,3GB RAM )
2、编译出错处理(自己摸索的,非官方)
错误1:编译约1个小时后出现的:
target Strip: libutils (out/target/product/generic/obj/lib/libutils.so)
target Dex: QuickSearchBox
frameworks/base/core/java/android/widget/VideoView.java:46: package com.ti.omap.omap_mm_library does not exist
import com.ti.omap.omap_mm_library.OmapMMLibrary;
^
frameworks/base/core/java/android/widget/VideoView.java:62: cannot find symbol
symbol : class OmapMMLibrary
location: class android.widget.VideoView
private OmapMMLibrary mOmapMMHandle = null;
^
frameworks/base/core/java/android/widget/VideoView.java:196: cannot find symbol
symbol : class OmapMMLibrary
location: class android.widget.VideoView
mOmapMMHandle = new OmapMMLibrary();
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar] Error 41
make: *** Waiting for unfinished jobs....
错误分析和处理:
看起来是OmapMMLibrary的找不到,后来发现此代码在framework/base/omapmmlib中,修改 build/core/pathmap.mk的FRAMEWORKS_BASE_SUBDIRS,如下
FRAMEWORKS_BASE_SUBDIRS := \
$(addsuffix /java, \
core \
graphics \
location \
media \
opengl \
sax \
telephony \
wifi \
vpn \
keystore \
voip \
omapmmlib\
)
错误2:编译即将完成时出现的,此时system.img还未生成
Checking API: checkapi-last
Checking API: checkapi-current
(unknown): error 13: Class android.app.Profile changed final qualifier
(unknown): error 13: Class android.app.ProfileGroup changed final qualifier
(unknown): error 24: Method android.app.ProfileManager.getProfile has changed deprecation state
(unknown): error 24: Method android.app.ProfileManager.setActiveProfile has changed deprecation state
(unknown): error 3: Added class MultiSelectListPreference to package android.preference
(unknown): error 4: Added public method android.app.Profile.getProfileGroup
(unknown): error 4: Added public method android.app.Profile.getStatusBarIndicator
(unknown): error 4: Added public method android.app.Profile.getUuid
(unknown): error 4: Added public method android.app.Profile.setStatusBarIndicator
(unknown): error 4: Added public method android.app.ProfileGroup.getUuid
(unknown): error 4: Added public method android.app.ProfileManager.getProfile
(unknown): error 4: Added public method android.app.ProfileManager.profileExists
(unknown): error 4: Added public method android.app.ProfileManager.setActiveProfile
(unknown): error 4: Added public method android.telephony.TelephonyManager.isDormancyRejected
(unknown): error 4: Added public method android.telephony.TelephonyManager.setDormancyRejected
(unknown): error 5: Added public field android.Manifest.permission.RAW_AUDIO
(unknown): error 9: Removed public method android.app.Profile.getProfileGroup
(unknown): error 9: Removed public method android.app.ProfileGroup.getName
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1) You can add "@hide" javadoc comments to the methods, etc. listed in the
errors above.
2) You can update current.xml by executing the following command:
make update-api
To submit the revised current.xml to the main Android repository,
you will need approval.
******************************
make: *** [out/target/common/obj/PACKAGING/checkapi-current-timestamp] Error 38
make: *** Waiting for unfinished jobs....
htmlDir not a directory: out/target/common/docs/gen
DroidDoc took 252 sec. to write docs to out/target/common/docs/doc-comment-check
错误处理:执行一次 make update-api 后编译可以顺利完成。
Install
Create a folder called android-9-cyanogen on Your/Android-SDK/platforms/
Copy the contents of Your/Android-SDK/platforms/android-9 into Your/Android-SDK/platforms/android-9-cyanogen
Copy the ramdisk.img system.img and userdata.img file from ~/android/system/out/target/product/generic toYour/Android-SDK/platforms/android-9-cyanogen/images/
Run the Android AVD Manager and select the second Android 2.3 target.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment