在构建Android源代码时,如何修复JDK未找到错误?

时间:2013-08-01 07:51:55

标签: java android ubuntu android-source

我正在尝试构建Android source by the steps provided here.但是我的JDK遇到了麻烦。发布时:

lunch full-eng

我收到以下错误:

/bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
/bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
/bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
/bin/bash: build/core/find-jdk-tools-jar.sh: Permission denied
build/core/config.mk:344: *** Error: could not find jdk tools.jar, please install JDK6, which you can download from java.sun.com.  Stop.    
** Don't have a product spec for: 'full'
** Do you have the right repo manifest?

所以我尝试通过以下步骤正确安装JDK:


第1步

卸载following these steps.

相关的所有JAVA

第2步

following these steps安装正确的JAVA。我使用默认安装程序选项和版本6,而不是7或8

第3步

我只是following this answer.

sudo gedit .bashrc

通过添加这些行来编辑底部的文件

JAVA_HOME=/usr/lib/jvm/java-6-oracle
export JAVA_HOME

# replacing /path/to/androidsdk/ with correct path of course..
export PATH=${PATH}:/path/to/androidsdk/android-sdk-linux/platform-tools

PATH=$PATH:$JAVA_HOME

# Variable ANDROID_JAVA_HOME
ANDROID_JAVA_HOME=/usr/lib/jvm/java-6-oracle
export ANDROID_JAVA_HOME

PATH=$PATH:$ANDROID_JAVA_HOME

第4步

测试我到目前为止所做的事情:

...:~$ echo $JAVA_HOME
/usr/lib/jvm/java-6-oracle
...:~$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Server VM (build 20.45-b01, mixed mode)
...:~$ which java
/usr/bin/java
...:~$ echo $ANDROID_JAVA_HOME
/usr/lib/jvm/java-6-oracle
...:~$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-6-oracle/bin:/usr/lib/jvm/java-6-oracle/db/bin:/usr/lib/jvm/java-6-oracle/jre/bin:/path/to/androidsdk/android-sdk-linux/platform-tools:/usr/lib/jvm/java-6-oracle

第5步

进入终端到Android源文件夹并输入

source build/envsetup.sh

结果:

including device/asus/grouper/vendorsetup.sh
including device/asus/tilapia/vendorsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/armv7-a/vendorsetup.sh
including device/generic/mips/vendorsetup.sh
including device/generic/x86/vendorsetup.sh
including device/lge/mako/vendorsetup.sh
including device/samsung/maguro/vendorsetup.sh
including device/samsung/manta/vendorsetup.sh
including device/samsung_slsi/arndale/vendorsetup.sh
including device/samsung/toroplus/vendorsetup.sh
including device/samsung/toro/vendorsetup.sh
including device/ti/panda/vendorsetup.sh

第6步

进入终端到Android源文件夹并输入

lunch full-eng

结果:

.../androidsource$ lunch full-eng
/bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
/bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
/bin/bash: prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc: Permission denied
/bin/bash: build/core/find-jdk-tools-jar.sh: Permission denied
build/core/config.mk:344: *** Error: could not find jdk tools.jar, please install JDK6, which you can download from java.sun.com.  Stop.

** Don't have a product spec for: 'full'
** Do you have the right repo manifest?

我做错了什么?缺什么? “权限被拒绝”怎么办?

5 个答案:

答案 0 :(得分:9)

我有同样的问题。我得到它解决了我更改整个android源代码文件夹的文件权限:

sudo chmod 755 -R ~/Android

答案 1 :(得分:3)

我找到了解决方案:

  1. 出于某种原因,我没有相应的权利,因为“许可被拒绝”会暗示。通过chmod设置Android源文件夹的权限就可以了解

  2. 我错误地下载了最新的分支机构。但是我只有32位系统。对于32位,您只能使用小于Android 2.3的Android源,对于那些版本,您还必须使用JDK 5 http://source.android.com/source/building.html

答案 2 :(得分:2)

也有同样的问题,但这是由于NTFS问题,因为我无法从分区执行。这是我发现的修复。

https://askubuntu.com/questions/164847/cant-compile-in-ntfs-partition

答案 3 :(得分:1)

通常,这是由于javac未配置为系统的替代方案。所以你的javac没有/ usr / bin / javac的链接。

请使用以下命令设置javac的替代方案:

$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_32/bin/javac" 1

注意:我安装的javac目录是“/usr/lib/jvm/jdk1.6.0_32/”,您可以通过配置进行更改。

答案 4 :(得分:0)

我也遇到过同样的情况。我激活了root用户并登录并执行了与http://source.android.com/source/building.html站点相同的操作,并且它运行良好。