OS: Ubuntu 10.04
編譯Donut:
development/emulator/qtools/trace_reader.cpp: In function 'char* ExtractDexPathFromMmap(const char*)':
development/emulator/qtools/trace_reader.cpp:1012: error: invalid conversion from 'const char*' to 'char*'
development/emulator/qtools/trace_reader.cpp:1015: error: invalid conversion from 'const char*' to 'char*'
make: *** [out/host/linux-x86/obj/EXECUTABLES/bb2sym_intermediates/trace_reader.o] error 1
檢查gcc的版本
$ ls -al /usr/bin/gcc
$ gcc --version
若是為4.4.0以上的版本, 則因為該版本在編譯時的語法要求較高, 導致編譯失敗, 解決方法是降gcc的版本
$ sudo apt-get install gcc-4.3
$ sudo apt-get install g++-4.3
$ sudo ln -f /usr/bin/gcc-4.3 /usr/bin/gcc
$ sudo ln -f /usr/bin/g++-4.3 /usr/bin/g++
也可以透過
update-alternatives工具做切換(symbolic links)
安裝各版本的gcc
$ sudo apt-get install gcc-4.1 gcc-4.3 gcc-4.4
使用update-alternatives
Usage: update-alternatives [<option> ...] <command>
Commands:
--install <link> <name> <path> <priority>
<link> is the symlink pointing to /etc/alternatives/<name>.
(e.g. /usr/bin/pager)
<name> is the master name for this link group.
(e.g. pager)
<path> is the location of one of the alternative target files.
(e.g. /usr/bin/less)
<priority> is an integer; options with higher numbers have higher priority in
automatic mode.
建立symbolic links(update-alternatives --install <link> <name> <path> <priority>)
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.1 1
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 2
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 3
切換gcc版本
$ sudo update-alternatives --config gcc
顯示結果
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/gcc-4.1 1 auto mode
1 /usr/bin/gcc-4.1 1 manual mode
* 2 /usr/bin/gcc-4.3 2 manual mode
3 /usr/bin/gcc-4.4 3 manual mode
Press enter to keep the current choice[*], or type selection number:
reference:
[Android開發]Android開發環境建立-gcc的問題
編譯Eclair/Froyo:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/tools/StandardJavaFileManager
at java.lang.ClassLoader.defineClass2(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:719)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:160)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:254)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at com.sun.tools.javac.main.Main.compile(Main.java:269)
at com.sun.tools.javac.Main.compile(Main.java:87)
at util.build.JavacBuildStep.build(JavacBuildStep.java:69)
at util.build.BuildDalvikSuite.handleTests(BuildDalvikSuite.java:498)
at util.build.BuildDalvikSuite.compose(BuildDalvikSuite.java:170)
at util.build.BuildDalvikSuite.main(BuildDalvikSuite.java:136)
make: *** [out/host/linux-x86/obj/EXECUTABLES/vm-tests_intermediates/tests] Error 1
編輯/etc/security/limits.conf, 註解掉
#* hard nofile 4096
新增
* soft nofile 8192
* hard nofile 8192
target Java: Browser (out/target/common/obj/APPS/Browser_intermediates/classes)
packages/apps/Browser/src/com/android/browser/DownloadTouchIcon.java:81: cannot find symbol
symbol : method getPreferredHttpHost(android.content.Context,java.lang.String)
location: class android.net.Proxy
HttpHost httpHost = Proxy.getPreferredHttpHost(mContext, url);
^
packages/apps/Browser/src/com/android/browser/FetchUrlMimeType.java:73: cannot find symbol
symbol : method getPreferredHttpHost(com.android.browser.BrowserActivity,java.lang.String)
location: class android.net.Proxy
HttpHost httpHost = Proxy.getPreferredHttpHost(mActivity, uri);
^
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.
2 errors
make: *** [out/target/common/obj/APPS/Browser_intermediates/classes-full-debug.jar] Error 41
之前提到
在Ubuntu使用sun-java-sdk, 若是在java6的環境編譯時就會出現以上問題, 原因大概是@override annotation的關係, 可是JDK 1.6當然有支援annotation, 這部份未來再補充
reference:
Android4SAM FAQ