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'

解决方案 »

  1.   

    我在网上看到过这样一个帖子,不知道能否解决你的问题,你试试。
    进入Android源码的根目录,如:/work/android2.1/编译命令:
    make update-api; 
    make PRODUCT-sdk-sdk;命令说明:
    1、make update-api   #如果你在Android源码中添加了自定义的包、类、方法或者你修改了Android源码中标识为@hide的方法、类,你需要这些内容对Application可见并且需要编译进SDK的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
      

  2.   

    太棒了,重新编译SDK后,果然所有代码都正常了,多谢,兄弟。
      

  3.   

    我是初学者,我想细问下 “进入Android源码的根目录,如:/work/android2.1/”
    我的 D:\Android\android-sdk-windows\没有看到
    能具体点吗?
    谢谢!
      

  4.   

    初学者+1.。。
    俺是E:\android-sdk-windows\也木看到
    不知道到底如何重新编译SDK呢?
    希望能具体点。谢谢~!!
      

  5.   

    我也遇到相同问题,我搜索的结果是修改
    When building you might run into the Unable to get buffer of resource asset file error. The root cause of this is that the new android resource file resources.arsc is larger than the aapt tool allows. You can exchange the .arsc file inside android.jar with an older version or patch the aapt tool by editing frameworks/base/include/utils/Asset.h.Change both lines UNCOMPRESS_DATA_MAX = 1 * 1024 * 1024 to something bigger. As the new resources file currently has a size of 2.3Mb you should change the lines (both lines mind you) to at least 3*1024*1024.
    不知道到底有什么区别阿?
      

  6.   


    五楼 六楼两位兄台,别人指的是Android系统源码吧,你们的只是SDK而已。