【问题标题】:R.java is not generating neither with eclipse nor with Android StudioR.java 既不使用 Eclipse 也不使用 Android Studio 生成
【发布时间】:2013-06-19 17:11:13
【问题描述】:

我的应用程序开发遇到问题,我无法继续,因为 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的输出控制台不是有错误吗?
  • Eclipse 是否在您的任何 XML 文件中给出任何错误?
  • @ReijerTheCoder 你能把编辑写成答案,并把它标记为接受吗?

标签: java android eclipse android-studio


【解决方案1】:

我不确定 Eclipse,但最新版本的 Android Studio (0.1.6) 有一个像这样的已知错误,目前只有一个解决方法。解决方法是在首选项 > 编译器中关闭外部构建。

【讨论】:

  • 巨大的帮助...很容易浪费一个小时想知道为什么你将 Android Studio 更新到 0.1.6 并且你的 R.java 没有编译,即使没有任何改变。
【解决方案2】:

当您生成的 R 类没有生成时,它表明由于 XML 资源的一些解析问题,生成它时存在问题。检查 IDE 中的错误控制台,找出具体错误。

常见问题有:

  • strings.xml 中的未转义字符,例如 you're 而不是 you\'re
  • 布局资源中缺少layout_width 或layout_height 标记
  • 缺少命名空间声明
  • Java 不支持的变量名称,例如由于大写或使用空格、连字符或其他不受支持的字符而导致的
  • XML 中的任何其他类型的语法错误

【讨论】:

    猜你喜欢
    • 2014-10-10
    • 1970-01-01
    • 2015-02-21
    • 1970-01-01
    • 1970-01-01
    • 2016-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多