Ubuntu9.04,Android源码版本2.1
以下是我用ADT创建的Android程序,全部自动生成的源代码,之前报R cannot be resolved to a variable,然后我加了import android.R;
但又报main cannot be resolved or is not a field。
第一次写java程序,实在不知道该怎么解,按说自动生成的代码应该可以一下子编成功才对啊。
package test.china.com;
import android.app.Activity;
import android.os.Bundle;
public class android extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
这个错误我就更不知道怎么搞了,上网也搜索不到解决的办法。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
[2010-11-28 18:57:42 - Hello] W/ResourceType( 2296): Unable to get buffer of resource asset file
[2010-11-28 18:57:42 - Hello] /home/sp/workspace/Hello/res/layout/main.xml:2: error: No resource identifier found for attribute 'orientation' in package 'android'
[2010-11-28 18:57:42 - Hello] /home/sp/workspace/Hello/res/layout/main.xml:2: error: No resource identifier found for attribute 'layout_width' in package 'android'
[2010-11-28 18:57:42 - Hello] /home/sp/workspace/Hello/res/layout/main.xml:2: error: No resource identifier found for attribute 'layout_height' in package 'android'
[2010-11-28 18:57:42 - Hello] /home/sp/workspace/Hello/res/layout/main.xml:7: error: No resource identifier found for attribute 'layout_width' in package 'android'
[2010-11-28 18:57:42 - Hello] /home/sp/workspace/Hello/res/layout/main.xml:7: error: No resource identifier found for attribute 'layout_height' in package 'android'
[2010-11-28 18:57:42 - Hello] /home/sp/workspace/Hello/res/layout/main.xml:7: error: No resource identifier found for attribute 'text' in package 'android'
------解决方案--------------------
我在网上看到过这样一个帖子,不知道能否解决你的问题,你试试。
进入Android源码的根目录,如:/work/android2.1/
编译命令:
make update-api;
make PRODUCT-sdk-sdk;
命令说明:
1、make update-api #如果你在Android源码中添加了自定义的包、类、方[email protected]?,[email protected]的Document中的话,这个命令是必须的(其实还有另外一种手工修改的方式替代这个命令的,呵呵);
2、make PRODUCT-sdk-sdk #编译源码并且声称SDK,这个方法解决了之前使用make sdk命令编译SDK的一个bug,就是R文件不能自动生成,需要手动更新一个jar文件才可以,这个文章本博客中也有涉及。
异常现象:
如果在源码中添加了一些style、theme、drawable、package、class、method,编译时会出现有out/目录中的一些异常现象,一般不是特别严重的,主要是针对有些文件找不到,此时你可以在执行以下命令:
make clean
再执行:
make update-api
make PRODUCT-sdk-sdk
------解决方案--------------------
坐等结帖···························