Android R.java不会在Eclipse中生成 [英] Android R.java will not generate in Eclipse

查看:136
本文介绍了Android R.java不会在Eclipse中生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Eclipse 4.2.2 Juno在Windows 64位的Android SDK 17与ADT开发。就在今天,我清理了一个工作项目,只是发现R.java文件将不再生成。



这个问题有可能的原因列表。用户灰色,针对位于此处的线程,列出了一组他们说:


不要担心。首先你可以清理该项目,然后运行该项目。如果
这不工作,请按照以下链接:


然后继续列出有关此不同原因的文章问题,我无法包含的链接,但可以在与上述相关的问题中找到。



格雷的评论是一个很好的总结,最常见的原因这个问题,包括资源文件命名约定,错误的导入Android.R语句,XML错误,需要清理和重建的损坏,以及在项目 - >属性 - > Java构建路径/库中检查Android SDK。



问题是,我的R.java仍然不会生成! Gray列表中唯一剩下的可能性似乎是我的main.xml或者AndroidManifest.xml是坏的,所以我已经包括它们,以确保我没有错过任何错误。



我的主要布局:

 <?xml version =1.0encoding =utf-8?> ; 
< FrameLayout xmlns:android =http://schemas.android.com/apk/res/android
android:layout_width =match_parent
android:layout_height =match_parent >
< com.bostonwalker.sseng.SSSurfaceView
android:id =@ + id / ssview
android:layout_width =match_parent
android:layout_height =match_parent />
< / FrameLayout>

我的清单:

 < manifest xmlns:android =http://schemas.android.com/apk/res/android
package =com.bostonwalker.enginedev
android: versionCode =1
android:versionName =1.0>

< uses-sdk
android:minSdkVersion =8
android:targetSdkVersion =17/>

< application
android:allowBackup =true
android:icon =@ drawable / ic_launcher
android:label =@ string / app_name
android:theme =@ style / AppTheme>

< activity
android:name =。MainActivity
android:label =@ string / app_name>
< intent-filter>
< action android:name =android.intent.action.MAIN/>
< category android:name =android.intent.category.LAUNCHER/>
< / intent-filter>
< / activity>
< / application>



作为初学者Android程序员,这超出了我的调试能力,有人可以找到解释吗?

解决方案

首先检查资源文件是否有任何错误,如果是这样,则不会生成R.java。检查是否已将您的adt更新为rev 22。如果是这样,请按照以下说明



右键单击项目goto属性Java构建路径选择订单导出选项卡确保选择了Android私有库,如果已经引用图书馆项目也为图书馆项目做同样的工作。清理和构建。



还要转到android sdk管理器,并检查您是否安装了安卓的sdk构建工具。这很多不是必需的,但请确保您已安装Android构建工具。



检查以下链接



<一个href =https://stackoverflow.com/questions/16642604/eclipse-error-r-cannot-be-resolved-to-a-variable/16643060#16643060> Eclipse错误:R无法解析为变量


I am running Eclipse 4.2.2 Juno on Windows 64-bit for development on Android SDK 17 with ADT. Just today, I cleaned a working project, only to find that the R.java file would no longer generate.

This problem has a very divergent list of possible causes. User Gray, in response to the thread located here, listed a set of articles, all addressing different possible causes.

He says:

Dont worry. First you may clean the project, then run the project. If this does not work then follow the following links:

And then proceeds to list articles pertaining to different causes of this problem, the links to which I am unable to include, but can be found in the question linked to above.

Gray's comment is a good summary of the most common causes to this problem, including resource file naming convention, the erroneous "import Android.R" statement, XML errors, corruption requiring cleaning and rebuilding, and checking the Android SDK in Project -> Properties -> Java Build Path / Libraries.

The problem is, my R.java still doesn't generate! The only remaining possibility within Gray's list seems to be that either my main.xml or AndroidManifest.xml is broken, so I have included them to make sure I didn't miss any errors.

My main layout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.bostonwalker.sseng.SSSurfaceView
    android:id="@+id/ssview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</FrameLayout>

And my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bostonwalker.enginedev"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"    >"
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

As a beginner Android programmer, this is beyond my capability to debug. Can someone please find an explanation?

解决方案

First check if there are any errors in your resource file's. R.java will not be generated if that's the case. Check if you have updated your adt to rev 22. If so follow the below

Right click on your project goto properties. Java Build Path. Choose Order export tab. Make sure that Android Private Libraries is selected. If you have referenced library project. do the same for the library project also. Clean and Build.

Also goto android sdk manager and check that you have the android sdk build tools installed. This many not be necessary but make sure you have android build tools installed.

Check the link below

Eclipse error: R cannot be resolved to a variable

这篇关于Android R.java不会在Eclipse中生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆