Ubuntu下android开发环境配置与奇葩错误解决

Sanchi

ubuntu下配置Java开发环境(命令行)

http://www.cnblogs.com/a2211009/p/4265225.html
http://www.phpini.com/linux/ubuntu-install-java-8

参考如上文章,按顺序执行如下命令:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
java -version
sudo apt-get install oracle-java8-set-default

命令执行完毕之后输入javacjava -version测试是否安装成功。
如上命令安装的JDK路径为:/usr/lib/jvm/java-8-oracle

ubuntu下安装android开发环境

https://github.com/jikexueyuanwiki/android-studio-basics/blob/master/Android%20Studio%20%E7%9A%84%E4%B8%8B%E8%BD%BD%E4%B8%8E%E5%AE%89%E8%A3%85.md
按照如上教程中的方式下载完成android studio与SDK之后,进行配置,先在用户文件夹下新建文件夹android,并将studio与SDK解压出来的文件夹放到其中。在studio的bin文件夹下执行命令./studio.sh打开studio,然后右键其图标,将studio放到dash以及固定到启动栏。其他studio的设置跟windows相同。

错误解决

问题一

ubuntu下运行android程序的时候总是报错,错误信息如下:

Error:Execution failed for task ':compileDebugAidl'.
> java.lang.RuntimeException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/zrp/software/android/android-sdk-linux/build-tools/23.0.1/aidl'' finished with non-zero exit value 127

gradle console中的错误信息:
build-tools/23.0.1/aidl: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory

google找到一篇文章:http://askubuntu.com/questions/409905/apt-get-error-loading-libgcc-s-so-1
解决方式:sudo apt-get install gcc-multilib,即可编译通过。

但是按照如上步骤解决编译问题之后,运行安装包的时候出现了另一个问题:

Exception in thread "png-cruncher_18" java.lang.RuntimeException: Timed out while waiting for slave aapt process, make sure the aapt execute at /home/zrp/software/android/android-sdk-linux/build-tools/23.0.1/aapt can run successfully (some anti-virus may block it) or try setting environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds
at com.android.builder.png.AaptProcess.waitForReady(AaptProcess.java:108)
at com.android.builder.png.QueuedCruncher$1.creation(QueuedCruncher.java:110)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:203)
at java.lang.Thread.run(Thread.java:745)

问题描述及解决链接:https://code.google.com/p/android/issues/detail?id=188627

问题二

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Unexpected lock protocol found in lock file. Expected 3, found 0.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

解决方式:http://stackoverflow.com/questions/31743942/errorunexpected-lock-protocol-found-in-lock-file-expected-3-found-0
删除项目文件夹下的.gradle文件夹并重新编译即可。

问题三

ubuntu下连接手机的时候报错:insufficient permissions for device,就是手机连接到电脑之后adb一直显示null,无法进行软件安装等。
找到如下解决方式:http://itsfoss.com/fix-error-insufficient-permissions-device/
解决办法如下:

adb kill-server
sudo adb start-server

敲完如上命令之后,手机上会弹出确认adb调试的弹框,确认连接即可。

问题四

ubuntu下安装android studio之后,studio无法关联源码,经过多方搜索,最终找到了奇葩的问题原因:SDK的文件夹名称中包含-字符或者路径名过长!修改文件夹名称之后关联到了源码。

阅读 8.5k

share
我也是个菜鸟。希望大家都不会跟我一样走弯路~

0100100100100111011011010010000001110111011010010111010001101000001000000111100101101111011101010...

361 声望
14 粉丝
0 条评论

0100100100100111011011010010000001110111011010010111010001101000001000000111100101101111011101010...

361 声望
14 粉丝
文章目录
宣传栏