1. 新建hello world总是不成功,提示The container ‘Android Dependencies‘ references non existing library
网上查资料有的说 clean 项目,然后 fix 之类的,各种不管用。又有人说 appcompat_v7是google自己的兼容包,右键你的工程-properties-android,就会发现在library里面有import appcompat_v7。删除就好,一举删掉后,新的问题又来了:
2.ActionBarActivity cannot be resolved to a type
在工程 /HelloAppPro/res/values/styles.xml 中还报错:error: Error retrieving parent for item: No resource found that matches the given name ‘Theme.AppCompat.Light‘.
于是有人说是android版本问题,把那段话删掉
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!-- API 11 theme customizations can go here. -->
</style>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
删除后,values 没错误了,但是menu/main.xml又报错,提示如下
3. error: No resource identifier found for attribute ‘showAsAction‘ in package ‘com.hcar.helloapppro‘
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never"/>
于是把步骤2中的删先改为了:
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
可是 error: No resource identifier found for attribute ‘showAsAction‘ in package ‘com.hcar.helloapppro‘ 这个问题依然存在。
4.于是把所有能造成错误的都删除后,终于看起来没错误了,运行后报错:
[2014-10-25 16:02:12 - HelloAppPro] Launching a new emulator with Virtual Device ‘AVD4.4.2‘
[2014-10-25 16:02:12 - Emulator] emulator: ERROR: x86 emulation currently requires hardware acceleration!
[2014-10-25 16:02:12 - Emulator] Please ensure Intel HAXM is properly installed and usable.
[2014-10-25 16:02:12 - Emulator] CPU acceleration status: HAX kernel module is not installed!
5. 这个我能解决呀,于是兴高采烈的用 SDK manager 下载了 HAX 硬件加速。这时候突然想起来,是不是不用 x86 就不会出现这些问题。下载
重启eclipse后,发现R出现了!也不是那么神秘,就是把一些整数值用 int 赋给字符串(具有一些展现含义)。E:\Dev\adroid_Lab\sdk\extras\intel\Hardware_Accelerated_Execution_Manager,点击安装.exe 即可。
public final class R {
public static final class attr {
}
public static final class dimen {
/** Default screen margins, per the Android Design guidelines.
Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
*/
public static final int activity_horizontal_margin=0x7f040000;
public static final int activity_vertical_margin=0x7f040001;
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int action_settings=0x7f080000;
}
public static final class layout {
public static final int activity_main=0x7f030000;
}
public static final class menu {
public static final int main=0x7f070000;
}
public static final class string {
public static final int action_settings=0x7f050002;
public static final int app_name=0x7f050000;
public static final int hello_world=0x7f050001;
}
public static final class style {
/**
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
Application theme.
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
*/
public static final int AppBaseTheme=0x7f060000;
}
}
6. 重新启动后,等了大概1min,ok,终于出来了"Hello,Android"
[2014-10-25 16:32:15 - HelloAppPro] Performing com.hcar.helloapppro.MainActivity activity launch
[2014-10-25 16:32:15 - HelloAppPro] Automatic Target Mode: Preferred AVD ‘AVD4.4.2‘ is not available. Launching new emulator.
[2014-10-25 16:32:15 - HelloAppPro] Launching a new emulator with Virtual Device ‘AVD4.4.2‘