2013-03-21 103 views
0

這是我第一次爲android開發。我試圖在eclipse環境中開發,但我遇到了一個問題。沒有生成類R.java。我已經嘗試了所有的功能,如清理或刷新 - >清理,然後重新安裝eclipse。也許問題可以在我的佈局:Eclipse沒有生成R.java

我的佈局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/hello_world" /> 

</RelativeLayout> 
+0

在任何xml文件中是否有任何錯誤? – codeMagic 2013-03-21 18:18:33

+1

有很多原因爲什麼[R無法解決 - Android錯誤](http://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error)...像導入「android.R'和你的XML中的錯字。 – Sam 2013-03-21 18:19:51

+0

還檢查您的導入,如果它與android.R.java聯繫,則將其從導入中刪除。 – Pragnani 2013-03-21 18:21:45

回答

0

我假設你的意思是不是被再生?這個問題在Eclipse中出現了很多。只要刪除現有的R.java,它會正確地重新生成。

或者你是說你根本沒有R.java?

+0

不可以。我的Eclipse沒有生成R.java。而不是它生成的這個類: /**自動生成的文件。不要修改*/ package com.example.hello; public final class BuildConfig public final static boolean DEBUG = true; } – 2013-03-21 18:22:21

+0

BuildConfig類應另外生成R類。您可以從代碼中檢查DEBUG常量,看它是否帶有調試或不帶調試。 – Ridcully 2013-03-21 18:26:53

+0

你是如何創建這個項目的?新的Android應用程序嚮導默認會始終創建一個R文件。 – 2013-03-21 18:29:16