构建Android XML布局时出错,未生成R文件

用户名

因此,我目前在程序中唯一的布局是该activity_main文件。我有一个MainActivity类。我在保存xml文件时收到构建错误,并且未生成我的R文件。我读到不生成的R文件与xml错误有关。即使在构建cml时,eclipse也不会捕获这些错误。我包括了我的字符串xml文件,布局文件和android清单。非常感谢您的帮助。


字符串XML文件

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">django mouse</string>
    <string name="title_activity_main">MainActivity</string>
    <string name="hello_world">Hello world!</string>
    <string name="welcome_header">Welcome to Django</string>
    <string name="start_instructions">To begin enter your local ip address and then click the start button</string>
    <string name="pebb_accel_header">Pebble Accelerometer Data</string>
    <string name="main_x_coordinate">X: </string>
    <string name="main_y_coordinate">Y: </string>
    <string name="main_z_coordinate">Z: </string>
    <string name="up_button">up</string>
    <string name="down_button">down</string>
    <string name="left_button">left</string>
    <string name="right_button">right</string>
    <string name="click_button">click</string>
    <string name="start_button">start</string>

</resources>

activity_main

<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:orientation="vertical"
    android:paddingBottom="20dp"
    tools:context=".MainActivity"
    tools:ignore="MergeRootFrame" >

    <TextView
        android:id="@+id/welcome_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:gravity="center_horizontal"
        android:text="@string/welcome_header"
        android:textColor="@color/Black"
        android:textSize="22sp" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/start_stop_instructions"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingTop="75dp"
            android:text="@string/start_instructions"
            android:textColor="@color/Black"
            android:textSize="18sp" />

        <TextView
            android:id="@+id/welcome_sub_header"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/start_stop_instructions"
            android:paddingTop="16dp"
            android:text="@string/pebb_accel_header"
            android:textColor="@color/Black"
            android:textSize="18sp" />

        <LinearLayout
            android:id="@+id/accel_data"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/pebb_accel_header"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/main_x_coordinate"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="@string/main_x_coordinate"
                android:textColor="@color/Black" />

            <TextView
                android:id="@+id/main_y_coordinate"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="@string/main_y_coordinate"
                android:textColor="@color/Black" />

            <TextView
                android:id="@+id/main_z_coordinate"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="@string/main_z_coordinate"
                android:textColor="@color/Black" />
        </LinearLayout>

        <Button
            android:id="@+id/up_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/accel_data"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="32dp"
            android:text="@string/up_button" />

        <Button
            android:id="@+id/down_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/up_button"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="48dp"
            android:text="@string/down_button" />

        <Button
            android:id="@+id/left_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/up_button"
            android:layout_toLeftOf="@id/up_button"
            android:text="@string/left_button" />

        <Button
            android:id="@+id/right_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/up_button"
            android:layout_toRightOf="@id/up_button"
            android:text="@string/right_button" />

        <Button
            android:id="@+id/click_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/up_button"
            android:layout_toLeftOf="@id/right_button"
            android:layout_toRightOf="@id/left_button"
            android:text="@string/click_button" />
    </RelativeLayout>

    <Button
        android:id="@+id/main_start_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="@string/start_button"

</RelativeLayout>`

Android清单

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.housedroid.djangomouse.MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>
南阮
  1. 检查您的最后一个Button标签activity_main.xml
  2. 你有没有定义类似的东西colors.xml

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在Android Studio 2.1.1中构建APK文件时出错

来自分类Dev

为Android构建Tesseract时出错

来自分类Dev

构建Cordova Android项目时出错

来自分类Dev

使用Cordova Android构建Xwalk时出错

来自分类Dev

构建android 4.3 master时出错

来自分类Dev

在Cordova中构建Android项目时出错

来自分类Dev

在 Android Studio 中构建 APK 时出错

来自分类Dev

使用android-ndk-r9构建pjsua时出错

来自分类Dev

在 Android Studio 中构建 Android 库时出错

来自分类Dev

Android Studio构建文件R损坏

来自分类Dev

当我使用 Jenkins 构建时,Android 构建总是失败

来自分类Dev

如何在Android中构建此布局?

来自分类Dev

如何构建android灵活的堆栈布局?

来自分类Dev

在Qt上构建Android应用时出错

来自分类Dev

从Android源构建Alarm应用时出错

来自分类Dev

Android Studio-构建版本未显示

来自分类Dev

Android资源未包含在构建中

来自分类Dev

Eclipse-运行构建器“ Android Package Builder”时出错

来自分类Dev

从Android Studio 6.1构建本机库时出错

来自分类Dev

构建Android内核时出错:“多个目标模式”

来自分类Dev

在Unity中为Android构建播放器时出错?

来自分类Dev

“找不到Android属性。” 构建Flutter Aar时出错

来自分类Dev

从Android Studio 6.1构建本机库时出错

来自分类Dev

使用 bazel 支持在 android 上构建 tensorflow 时出错

来自分类Dev

添加 Google 地图时 Xamarin Android 构建出错

来自分类Dev

运行 Cordova 构建 android ionic2 时出错

来自分类Dev

在Ionic框架中为Android构建时与Android SDK ANT构建文件相关的错误

来自分类Dev

使用Gitlab CI生成Android构建

来自分类Dev

Android在构建APK时选择资产

Related 相关文章

热门标签

归档