[置顶] Android Journal



========================================================================================================html

注:

本文内容转载自互联网,仅供我的学习之用!java

========================================================================================================android


(1)  Application does not specify an API level requirement!app

    在运行Android程序时,有时候会出现如下提示

[2010-05-28 19:03:03 - rss_reader]WARNING: Application does not specify an API level requirement!eclipse

[2010-05-28 19:03:03 - rss_reader]Device API version is 12 (Android 3.1)

    其中Android 3.1表示工程使用的Androidsdk版本,示例中使用的是3.1版本;12是设备的API版本,出现该提示,是由于工程中没有配置设备API版本,只须要在文件AndroidManifest.xml中添加上相应的配置信息便可。
    示例以下:ide

<manifest ……>
    <application ……">
        ……
    </application>
     <uses-sdk android:minSdkVersion="12"></uses-sdk>
</manifest>

    注意,红字部分是采用的设备API版本号;users-sdk节点同application节点在同一级别。学习



(2)  显示尺寸的单位: ui

Difference between px, dp, dip and sp in Android?

LinkTo:http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-androidthis

px is one pixel. scale-independent pixels ( sp ) and density-independent pixels ( dip ) you want to use sp for font sizes and dip for everything else.spa

dip==dp

from here http://developer.android.com/guide/topics/resources/more-resources.html#Dimension

px
Pixels - corresponds to actual pixels on the screen.

in
Inches - based on the physical size of the screen.

mm
Millimeters - based on the physical size of the screen.

pt
Points - 1/72 of an inch based on the physical size of the screen.

dp
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".

sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.



(3)  R资源丢失的问题:

Android: R cannot be resolved to a variable

转载自:http://hi.baidu.com/mycollection/item/5f62fbeada78120d65db00ac

Android开发过程当中,碰到R cannot be resolved to a variable的报错信息,好像没有很肯定的错误缘由,通常来讲,我总结出几个可能的解决方法,但愿试过之后管用。。。

 

1. 检查Android 的SDK是否丢失须要从新下载,检查build path

2.确保class没有import Android.R;

3,错误class引用的layout的xml文件没有错误

4.检查AndroidManifest.xml文件,里边的package,layout配置文件,strings.xml等的字符串所有书写正确

5.layout的xml文件中引用的strings.xml中的字符串拼写彻底正确

6.在layout 的xml文件手写添加一个控件,看id可否在R.java中自动生成,若是不能,那很大可能就是这个layout 的xml文件有问题,查看格式是否使用正确,或者包含什么非法字符串,或者调用到了不正确的字符串,等等,可使用排除法,挨个去掉控件,直到发现error message消失或者id能在R.java中自动生成。
7.删掉gen文件夹,使R.java从新自动生成一次,若是不能生成,继续检查layout的xml文件是否有如上不易发觉的问题

8.Clean project ,从新build,或者从新import project。

9.重启eclipse

10.重启电脑,以防Android 虚拟机的问题

另注:

当引用资源变量时,如R.string.bluetooth_name,编译程序失败,提示如“bluetooth_name cannot be resolved or is not a field..."之类的错误提示,

a)  须要检查源文件是否被误加入“import android.R;”相似的语句,若有则删除该语句,从新编译程序,看是否编译经过;

 b) 编辑./res/values/strings.xml文件,修改部分文字并保存,从新编译程序项目;






========================================================================================================

注:

本文内容转载自互联网,仅供我的学习之用!

========================================================================================================


(1)  Application does not specify an API level requirement!

    在运行Android程序时,有时候会出现如下提示

[2010-05-28 19:03:03 - rss_reader]WARNING: Application does not specify an API level requirement!

[2010-05-28 19:03:03 - rss_reader]Device API version is 12 (Android 3.1)

    其中Android 3.1表示工程使用的Androidsdk版本,示例中使用的是3.1版本;12是设备的API版本,出现该提示,是由于工程中没有配置设备API版本,只须要在文件AndroidManifest.xml中添加上相应的配置信息便可。
    示例以下:

<manifest ……>
    <application ……">
        ……
    </application>
     <uses-sdk android:minSdkVersion="12"></uses-sdk>
</manifest>

    注意,红字部分是采用的设备API版本号;users-sdk节点同application节点在同一级别。



(2)  显示尺寸的单位: 

Difference between px, dp, dip and sp in Android?

LinkTo:http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-android

px is one pixel. scale-independent pixels ( sp ) and density-independent pixels ( dip ) you want to use sp for font sizes and dip for everything else.

dip==dp

from here http://developer.android.com/guide/topics/resources/more-resources.html#Dimension

px
Pixels - corresponds to actual pixels on the screen.

in
Inches - based on the physical size of the screen.

mm
Millimeters - based on the physical size of the screen.

pt
Points - 1/72 of an inch based on the physical size of the screen.

dp
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".

sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.



(3)  R资源丢失的问题:

Android: R cannot be resolved to a variable

转载自:http://hi.baidu.com/mycollection/item/5f62fbeada78120d65db00ac

Android开发过程当中,碰到R cannot be resolved to a variable的报错信息,好像没有很肯定的错误缘由,通常来讲,我总结出几个可能的解决方法,但愿试过之后管用。。。

 

1. 检查Android 的SDK是否丢失须要从新下载,检查build path

2.确保class没有import Android.R;

3,错误class引用的layout的xml文件没有错误

4.检查AndroidManifest.xml文件,里边的package,layout配置文件,strings.xml等的字符串所有书写正确

5.layout的xml文件中引用的strings.xml中的字符串拼写彻底正确

6.在layout 的xml文件手写添加一个控件,看id可否在R.java中自动生成,若是不能,那很大可能就是这个layout 的xml文件有问题,查看格式是否使用正确,或者包含什么非法字符串,或者调用到了不正确的字符串,等等,可使用排除法,挨个去掉控件,直到发现error message消失或者id能在R.java中自动生成。
7.删掉gen文件夹,使R.java从新自动生成一次,若是不能生成,继续检查layout的xml文件是否有如上不易发觉的问题

8.Clean project ,从新build,或者从新import project。

9.重启eclipse

10.重启电脑,以防Android 虚拟机的问题

另注:

当引用资源变量时,如R.string.bluetooth_name,编译程序失败,提示如“bluetooth_name cannot be resolved or is not a field..."之类的错误提示,须要检查源文件是否被误加入“import android.R;”相似的语句,若有则删除该语句,从新编译程序便可正常。

相关文章
相关标签/搜索