惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
V
Visual Studio Blog
C
Check Point Blog
Google DeepMind News
Google DeepMind News
S
SegmentFault 最新的问题
博客园 - 聂微东
量子位
T
Tailwind CSS Blog
罗磊的独立博客
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
L
LangChain Blog
小众软件
小众软件
Engineering at Meta
Engineering at Meta
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Security Latest
Security Latest
M
MIT News - Artificial intelligence
Know Your Adversary
Know Your Adversary
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
有赞技术团队
有赞技术团队
V
Vulnerabilities – Threatpost
Martin Fowler
Martin Fowler
A
Arctic Wolf
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
Cyberwarzone
Cyberwarzone
阮一峰的网络日志
阮一峰的网络日志
The Hacker News
The Hacker News
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
GbyAI
GbyAI
Latest news
Latest news
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
腾讯CDC
AWS News Blog
AWS News Blog
aimingoo的专栏
aimingoo的专栏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
Lohrmann on Cybersecurity
博客园 - Franky
S
Securelist
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threatpost
美团技术团队

博客园 - 八进制

博客已搬家 Swift开发iOS应用过程中的问题和解决记录 AndroidStudio的一些坑 Eclipse崩溃后无法启动的问题解决 Android 5.0/5.1开发问题专贴 WordPress安装使用问题记录 Arduino单片机使用和开发问题记录 U盘启动笔记本无法安装Win7问题和解决 FreeSwitch安装配置记录 安装配置opensips过程记录 Android SDK开发包国内下载地址 博客园被黑了? [Android问答] 如何获得手机屏幕分辨率? [Android问答] ListView如何加载远程图片?(附代码) [Android问答] 如何实现“退出应用”功能? [Android问答] 旋转屏幕导致Activity重建怎么办? [Android问答] 如何应对Activity进程被杀? [Android问答] 如何理解Activity生命周期? [Android问答] px、dp和sp,这些单位有什么区别?
[Android问答] 开发环境问题集锦
八进制 · 2012-11-11 · via 博客园 - 八进制

工欲善其事,必先利其器。

和iOS开发相比,Android的开发环境的版本比较多,随之而来的问题也多。显然,我们不应该浪费宝贵的时间在解决开发环境带来的问题上,为此本文总结了常见的开发环境问题和解决方法,供大家查询和随时补充。

Debug certificate expired

Android SDK生成的用于调试的证书文件debug.keystore有效期是365天,当使用超过一年后控制台就会报这个错误。

Error generating final archive: Debug Certificate expired on 10/09/18 16:30

解决方法是手工删除debug.keystore文件,Windows系统下位于"C:\Documents and Settings\username\.android"目录,Linux和Mac系统下位于"~/.android/"目录。下次启动应用时,Eclipse会自动新建一个debug.keystore文件。最好"Project->Clean"一下项目以便触发编译器重新编译。

Failed to install apk on device: timeout

导致这个问题的确切原因不清楚,可能是由于不正确关闭adb连接。

Failed to install helloworld.apk on device 'emulator-5554': timeout

解决方法1:更换电脑usb口(不使用前置usb口)或重装手机驱动,将手机关机后再开机。

解决方法2:在Eclipse里选择"Window->Preferences->Android->DDMS->ADB connection time out",将缺省的5000ms改为更大的值,例如20000ms。

解决方法3:在命令行窗口里依次输入如下命令:

adb kill-server
adb start-server

invalid command-line parameter

这是由于Eclipse开发环境无法找到所需的可执行文件造成的。

[2011-07-10 07:10:22 - demo] Android Launch!
[2011-07-10 07:10:24 - demo] adb is running normally.
[2011-07-10 07:10:24 - demo] Performing com.demo.DemoActivity activity launch
[2011-07-10 07:10:25 - demo] Automatic Target Mode: launching new emulator with compatible AVD 'xxx'
[2011-07-10 07:10:25 - demo] Launching a new emulator with Virtual Device 'xxx'
[2011-07-10 07:11:06 - Emulator] invalid command-line parameter: Files\Android\android-sdk\tools/emulator-arm.exe.

解决方法是在Eclipse里选择"Window->Preferences->Android"选项,检查"SDK Location"的路径是否包含了空格,如果是"c:\Program Files\android"这种,改为"c:\Progra~1\android",这样命令行就可以正常调用到了。

小提示:在命令行窗口里输入"dir /x"命令就可以列出8.3格式的文件名,看下面的结果:

2012-09-25  23:52    <DIR>          WATCHD~1     WatchData
2012-09-01  11:01    <DIR>                       Winamp
2012-07-24  22:22    <DIR>          WINDOW~4     Windows Live
2012-07-24  22:21    <DIR>          WI3957~1     Windows Live SkyDrive

INSTALL_FAILED_INSUFFICIENT_STORAGE

安装应用程序时遇到存储容量不足时会报这个错误:

Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
Please check logcat output for more details.
Launch canceled!

如果是在模拟器上运行应用,可以扩大AVD的内存容量。

如果是在真机上运行,可以在AndroidManifest.xml里修改安装偏好,让应用直接安装到SD卡上解决。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example"
    android:installLocation="preferExternal" >
...
</manifest>

Unable to open sync connection

虽然很多人遇到这个问题,但问题的根源并不确切,可能有多种原因造成adb报这个错误:

[2010-10-12 09:36:48 - myapp] Android Launch!
[2010-10-12 09:36:48 - myapp] adb is running normally.
[2010-10-12 09:36:48 - myapp] Performing com.mycompany.myapp.MyActivity activity launch
[2010-10-12 09:36:48 - myapp] Automatic Target Mode: using device 'xxx'
[2010-10-12 09:36:48 - myapp] Uploading myapp.apk onto device 'xxx'
[2010-10-12 09:36:48 - myapp] Failed to upload myapp.apk on device 'xxx'
[2010-10-12 09:36:48 - myapp] java.io.IOException: Unable to open sync connection!
[2010-10-12 09:36:48 - myapp] Launch canceled!

解决方法1:拔掉手机连接线再重新连上;

解决方法2:在手机上关闭Debug选项再重新打开,这个选项在手机的"设置->应用程序->开发->USB调试"里。

Too many open files

这个问题与系统可同时打开文件数量设置有关,但一般不需要修改相关设置,用上一个问题(Unable to open sync connection)的方法即可解决。

第三方Jar包,NoClassDefFoundError

升级ADT版本以后容易出现这个问题:本来一切正常的Android项目,升级以后所有的第三方Jar包里的类都提示NoClassDefFoundError了。

原因可能出现在不同版本ADT使用的编译ant脚本的区别,可能的解决方法有两个:

方法1:在Eclipse里右键点击你的Android工程,选择"Properties->Java Build Path->Order and Export",在这里把所有第三方Jar包前面的复选框都勾上。

方法2:检查你的第三方Jar包文件是否放在工程目录下的"libs"目录,如果不是,改过来。

Failed to allocate memory: 8

一般是AVD的设置有问题,很可能是RAM值设得太高,降低些试试。早期adt版本里有个bug,就是RAM值里必须包含"MB",例如是"512MB"而不是"512",否则提示上述错误信息。

也有人提到过分辨率是原因之一,但我没有实际遇到过,如果只改小RAM没有解决问题,试着把分辨率也调低看看。

参考资料

“Debug certificate expired” error in Eclipse Android plugins

Android error: Failed to install *.apk on device *: timeout

The Android emulator is not starting, showing “invalid command-line parameter”

Solution: Android INSTALL_FAILED_INSUFFICIENT_STORAGE error

Android adb “Unable to open sync connection!”

com.android.ddmlib.SyncException: Too many open files

NoClassDefFoundError - Eclipse and Android

Android emulator failed to allocate memory 8