Ubuntu Configuration Android Development environment and compile the source of some problems encountered

Source: Internet
Author: User

---------------------------------------------environment variable Settings---------------------------------------------

1. Setting the JDK environment variable

Compiled Android source only support JDK 1.6, so if you need to compile the source must download JDK 1.6, cannot download the latest JDK 1.7, if you do not need to compile the source code, you can download the 1.7 version.

1.6 Version Jdk:http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html

Do not configure the environment variables in the/etc/environment and/etc/profile files, so configured in some Ubuntu version will appear after exiting the current terminal does not work, on the ubuntu12.04 I encountered this problem.
Configuring environment variables in the user directory. bashrc file is the best choice.
Export java_home=/home/abc/jdk1.6.0_45
Export path= $PATH: $JAVA _home/bin: $JAVA _home/jre/bin
Export classpath=.: $JAVA _home/lib: $JAVA _home/jre/lib

Then execute the source. BASHRC to make the configuration effective.

Because there may be default JDK in Ubuntu, such as OpenJDK. If there is openjdk, so, in order to make the default use of the JDK we installed, but also to do the following work.
Perform:
sudo update-alternatives--install/usr/bin/java Java ~/abc/jdk1.6.0_45/bin/java 300
sudo update-alternatives--install/usr/bin/javac javac ~/abc/jdk1.6.0_45/bin/javac 300
This step adds our installed JDK to the Java menu.
Then execute:
sudo update-alternatives--config java
Use this step to select the system default JDK

---------
2. Add aliases
Alias b= ' CD.. #返回到上一级目录
Alias bb= ' CD. /..‘
Alias bbb= ' CD. /.. /..‘
Alias g= ' Gedit ' #打开文本编辑器

---------------------------------------------Eclise Related Issues---------------------------------------------
1. You can successfully start eclipse at the terminal, but the mouse double-click from the folder, or start with the starter will appear the following:

A Java RunTime Environment (JRE) or Java development Kit (JDK) must be available on order to run eclipse.no Java virtual m Achine was found after searching the following locations: ...


Workaround: Enter your Eclipse directory from the terminal and enter:
The command is: Ln-s/home/abc/jdk1.6.0_45/jre JRE

Or

The workaround is to enter your Eclipse directory at the terminal and enter:
mkdir JRE
CD JRE

Ln-s your JDK directory/bin bin


2. Unable to find ADB
Adb:error = 12 error after setting up JDK and SDK environment under Android---64bit Ubuntu system
Failed to get the ADB version:cannot Run Program "/HOME/XXXX/ANDROID/ANDROID-SDK/PLATFORM-TOOLS/ADB": error=2, no file or directory
Error message: android-sdk-linux/platform-tools/adb: There is no file or directory.

Solution: Because it is 64bit system, and ANDROIDSDK only 32bit program, need to install ia32-libs, in order to use.
Open Terminal: sudo apt-get install ia32-libs

3. Install ADT (Android development Tools).
Start Eclipse, select Help->install New softwares-> in the navigation menu, click the Add button, and in the pop-up box add repository, enter name:android (fill it in),
Location: Fill in the Address https://dl-ssl.google.com/android/eclipse/. Click OK, select as needed, then install. When the installation is complete, restart Eclipse.

4. Configuring the SDK path in eclipse
Select Windows->preferences->android and select the location of the Android SDK. Mine is extracted here in D:program filesandroid-sdk-windows, choose here.

---------------------------------------------compiling Android source code---------------------------------------------

Issues encountered during the compilation process:
/bin/bash:bison: Command not found

sudo apt-get install Bison

/bin/bash:xsltproc: Command not found
sudo apt-get install Xsltproc

external/clearsilver/cgi/cgi.c:22:18:fatal error:zlib.h: No file or directory
sudo apt-get install Zlib1g-dev

/bin/bash:flex: Command not found
sudo apt-get install Flex

prebuilt/linux-x86/sdl/include/sdl/sdl_syswm.h:55:22:fatal error:x11/xlib.h: No file or directory
sudo apt-get install Libx11-dev

/usr/bin/ld:cannot find-lncurses
sudo apt-get install Libncurses5-dev
sudo apt-get install Gperf

gcc:error trying to exec ' cc1plus ': execvp: No file or directory
sudo apt-get install build-essential
Reference: http://www.cnblogs.com/skyme/archive/2011/01/19/1939606.html

/bin/bash:xmllint: Command not found
Solve
sudo apt-get install Xsltproc
sudo apt-get install libxml2-utils

Javac: Target release 1.5 conflicts with the default source release 1.7
Cause: Installing Eclipse in Ubuntu Software Center causes the JDK to become the default OpenJDK
~$ java-version
Java Version "1.7.0_21"
OpenJDK Runtime Environment (IcedTea 2.3.9) (7U21-2.3.9-1UBUNTU1)
OpenJDK 64-bit Server VM (build 23.7-b01, Mixed mode)
Modification method: Uninstall Eclipse installed in UBUTNU Software Center and re-download install Eclipse and Sun jdk1.6.
sudo apt-get remove openjdk*
This command uninstalls all dependent OPENJDK software, including eclipse installed from Ubuntu Software Center.

/usr/include/stdc-predef.h:30:26:fatal error:bits/predefs.h:no Such file or directory
Compilation terminated.
sudo apt-get install Gcc-multilib

Error:
Build/core/java.mk:9: * * * bin:target java module does not define any source or resource files. Stop.

Solve:
Delete the Bin folder under the source root directory, which was created when you imported eclipse.

[Email protected]:~$ sudo update-alternatives--config java
Update-alternatives: Error: No alternatives for Java

Http://source.android.com/source/initializing.html#configuring-usb-access
Initializing a Build environment
The following libraries need to be installed on the 12.04,12.10,13.04 version
$ sudo apt-get install git gnupg flex bison gperf build-essential \
Zip curl Libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
Libgl1-mesa-dev g++-multilib mingw32 tofrodos \
Python-markdown libxml2-utils Xsltproc zlib1g-dev:i386
$ sudo ln-s/usr/lib/i386-linux-gnu/mesa/libgl.so.1/usr/lib/i386-linux-gnu/libgl.so
But I installed on the machine on the above Lib is still compiled, but later found that because the previous compilation caused the Current.txt file has changed, so the API interface and the actual discrepancy, so the compilation error can not find the Android API.
After restoring the Current.txt, you can compile and pass.
--------------------------------------------

Ubuntu Configuration Android Development environment and compile the source of some problems encountered

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.