Android Studio 常见问题集锦

问题一:

Error:(26, 9) Attribute application@icon value=(@drawable/logo) from AndroidManifest.xml:26:9

Error:(28, 9) Attribute application@theme value=(@style/ThemeActionBar) from AndroidManifest.xml:28:9
is also present at XXXX-trunk:XXXXLib:unspecified:15:9 value=(@style/AppTheme)
Suggestion: add ‘tools:replace=”android:theme”‘ to <application> element at AndroidManifest.xml:24:5 to override
Error:Execution failed for task ‘:XXXX:processDebugManifest’.

> Manifest merger failed with multiple errors, see logs

原因:

AS的Gradle插件默认会启用Manifest Merger Tool,若Library项目中也定义了与主项目相同的属性(例如默认生成的android:icon和android:theme),则此时会合并失败,并报上面的错误。

解决方法有以下2种:

方法1:在Manifest.xml的application标签下添加tools:replace=”android:icon, android:theme”(多个属性用,隔开,并且记住在manifest根标签上加入xmlns:tools=”http://schemas.android.com/tools”,否则会找不到namespace哦)

方法2:在build.gradle根标签上加上useOldManifestMerger true (懒人方法)

参考官方介绍:

http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger

问题二:

Library Project里面的BuildConfig.DEBUG永远都是false。这是Android Studio的一个已知问题,某Google的攻城狮说,Library projects目前只会生成release的包。

Issue 52962: https://code.google.com/p/android/issues/detail?id=52962

解决方法:(某Google的攻城狮推荐的方法)

Workaround: instaed of BuildConfig.DEBUG create another boolean variable at lib-project’s e.g. BuildConfig.RELEASE and link it with application’s buildType.

https://gist.github.com/almozavr/d59e770d2a6386061fcb

参考stackoverflow上的这篇帖:

http://stackoverflow.com/questions/20176284/buildconfig-debug-always-false-when-building-library-projects-with-gradle

问题三:

每次保存的时候,每行多余的空格和TAB会被自动删除(例如结尾、空行的多余空格或TAB)

特别是每次准备提交SVN,Review代码时候你就蛋疼了,显示一堆不相关的更改,看的眼花。

解决方法:

Settings->IDE Settings->Editor->Other->Strip trailing spaces on Save->None

问题四:

编译的时候,报:Failure [INSTALL_FAILED_OLDER_SDK]。一般是系统自动帮你设置了compileSdkVersion

解决方法:

修改build.gradle下的compileSdkVersion ‘android-L’为compileSdkVersion 19(或者你本机已有的SDK即可)



1.报错:BUILD FAILED
D:\workspace\ganji\build.xml:144: The following error occurred while executing this line:
D:\workspace\ganji\build.xml:271: Unable to delete file D:\workspace\ganji\tmp\proguard\tmp.jar
解决:
已经开了一个模拟器了,无法重新编译,必须关闭一个。用于ant


2.报错:
The connection to adb is down, and a severe error has occured.
这个问题谁能解决啊
解决:
cmd跳到sdk tools文件路径下
adb kill-server
然后再adb start-server

3.报错:
The connection to adb is down, and a severe error has occured.
[2010-03-11 09:36:56 - HelloOPone] You must restart adb and Eclipse.
[2010-03-11 09:36:56 - HelloOPone] Please ensure that adb is correctly located at 'D:\OPhoneSDK_1.5
\platform-tools\adb.exe' and can be executed.
解决:
方法1.cmd中adb kill-server,然后adb -startserver
方法2.方法1不管用,那么在任务管理器中杀死adb.exe,然后重启Eclipse。
方法3.方法1和2都不管用,那么查看最后一句报错中:platform-tools中是否有adb.exe(我的错误就是在相关路径下面没有platform-tools文件夹
,所以我选择新建一个文件夹,并且把tools中的文件全部复制到platform-tools中)
4.前面的方法试了还是不行的话,建议重新装一个系统,最好换个系统。有些大牛也说过:MS存在一些小问题[size=large][/size]
 
 
 

启动和关掉 adb服务器 

当你启动 Android服务器时,adb服务器也就会一起启动。当你无法确定 adb服务器是否已启动?可以用“adb start-server”命令来启动 adb服务器,如果已启动就不做任何事,尚未启动就会直接启动 adb服务器。若你不想继续进行调试监控,则可以用“ adb kill-server”命令来关掉 adb服务器。 

E:\Android\android-sdk-windows\platform-tools>adb start-server

E:\Android\android-sdk-windows\platform-tools>adb kill-server

E:\Android\android-sdk-windows\platform-tools>adb devices

* daemon not running. starting it now on port 5037 *

could not read ok from ADB Server, error = 109

* failed to start daemon *

error: cannot connect to daemon

E:\Android\android-sdk-windows\platform-tools>adb devices

* daemon not running. starting it now on port 5037 *

* daemon started successfully *

List of devices attached

2CBE000400000001        device

 

android adb shell:unknown host service

我们在Windows DOS窗口中输入adb shell后,会出现如下错误: adb server is out of date.  killing... ADB server didn't ACK * failed to start daemon * error: unknown host service   ,出现这问题是因为你的电脑上安装了豌豆夹造成的,只需打开“任务管理器”,找到'wandoujia_helper.exe',把这个进行终止掉就可以,

 

Android Studio ADB connection error

***Unable to establish a connection to adb This usually happens if you have an incompatible version of adb running already. Try reopening Android Studio after killing any existing adb daemons. If this happens repeatedly ,please file a bug at http://b.android.com including the following :

  1. Output of the command 'C:\Users\username\AppData\Local\Android\sdk\platform-tools\adb.exe devices'

2.you Idea.log file (Help |Show log in explorer)***

Whats the solution ,i'm running Win7 32bit

You need to kill the adb process that is running, to do so,

  1. Go to Spotlight search, open Activity Monitor,

  2. Loop for adb under CPU tag,

  3. Now Select it and Force Quit the process.

You can kill adb process through Terminal command too, by simply typing Kill -9 adb


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值