簡體   English   中英

R.java既不使用eclipse也不使用Android Studio生成

[英]R.java is not generating neither with eclipse nor with Android Studio

我在開發應用程序時遇到麻煩,無法繼續,因為R.java沒有生成。 我嘗試了所有可以在Stack Overflow上找到建議的建議,但是找不到任何有效的方法。 該問題不僅發生在Eclipse中,還發生在Android Studio中。 我檢查了所有的xml文件,但是找不到應該停止R.java生成的內容。 這是我的Manifest.xml的內容:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.thenewprogramming.android.timetoswim"
    android:versionCode="1"
    android:versionName="1.0" >

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

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

        <activity
            android:name="com.thenewprogramming.android.timetoswim.HomeActivity"
            android:label="@string/app_name" 
            android:screenOrientation="sensorPortrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.thenewprogramming.android.timetoswim.AddMatchActivity"
            android:label="@string/AddMatchActivity_ActivityTitle"  
            android:screenOrientation="sensor" >

            <intent-filter >
              <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>

        </activity>

        <activity
            android:name="com.thenewprogramming.android.timetoswim.SettingsActivity"
            android:label="@string/SettingsActivity_ActivityTitle" 
            android:screenOrientation="sensorPortrait">

            <intent-filter >
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>

        </activity>

    </application>

</manifest>

我嘗試清除所有其他xml,但該操作不起作用,因此我將它們放回去。

所有幫助將不勝感激。

編輯:有人立即告訴我,字符串必須以小寫字母開頭,所以我做到了,而且有效! 不幸的是,他刪除了該帖子,但我會將問題標記為已回答(如果我知道該怎么做...)。

我不確定Eclipse,但是最新版本的Android Studio(0.1.6)存在一個類似的已知錯誤,目前只有一種解決方法。 解決方法是在“首選項”>“編譯器”中關閉外部構建。

每當不生成生成的R類時,表明由於XML資源中的某些解析問題,生成類存在問題。 在您的IDE中檢查錯誤控制台,以找出具體存在的錯誤。

常見問題是:

  • 一個轉義字符在你strings.xml ,比如you're ,而不是you\\'re
  • 布局資源中缺少layout_widthlayout_height標簽
  • 缺少名稱空間聲明
  • Java不支持的變量名,例如由於大寫字母或使用空格,連字符或其他不受支持的字符
  • XML中的任何其他類型的語法錯誤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM