No hay contenido XML. Agregue una vista o un diseño raíz a su documento

Estoy desarrollando una aplicación para Android. Y soy nuevo en XML. Estoy recibiendo el mensaje diciendo "No contenido XML. Por favor, agregue una vista de raíz o el diseño de su documento" El código XML se da a continuación. Por favor ayuda

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/ref" android:textSize="15dp"/> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/ref2" android:textSize="15dp"/> <EditText android:id="@+id/uname" android:layout_width="150dp" android:layout_height="25dp" android:inputType="text" android:ems="5" > <requestFocus /> </EditText> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/ref3" android:textSize="15dp"/> <EditText android:id="@+id/pwd" android:layout_width="150dp" android:layout_height="25dp" android:inputType="text" android:ems="5" /> <Button android:layout_width="60dp" android:layout_height="35dp" android:text="@string/ref" android:id="@+id/bLogin" /> </LinearLayout> 

—- Código de actividad principal —

 package com.android.disasterAlertApp; import android.app.Activity; import android.os.Bundle; import android.widget.Button; public class MainActivity extends Activity { /** Called when the activity is first created. */ Button login; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); login =(Button) findViewById(R.id.bLogin); } } ----Manifest---- [2012-04-17 00:34:20 - Disaster Alert App] res\layout\main.xml:0: error: Resource entry main is already defined. [2012-04-17 00:34:20 - Disaster Alert App] res\layout\main.out.xml:0: Originally defined here. [2012-04-17 00:34:20 - Disaster Alert App] C:\Users\Acer\workspace\Disaster Alert App\res\layout\main.out.xml:1: error: Error parsing XML: no element found [2012-04-17 01:05:59 - Disaster Alert App] res\layout\main.xml:0: error: Resource entry main is already defined. [2012-04-17 01:05:59 - Disaster Alert App] res\layout\main.out.xml:0: Originally defined here. [2012-04-17 01:05:59 - Disaster Alert App] C:\Users\Acer\workspace\Disaster Alert App\res\layout\main.out.xml:1: error: Error parsing XML: no element found [2012-04-17 01:11:14 - Disaster Alert App] res\layout\main.xml:0: error: Resource entry main is already defined. [2012-04-17 01:11:14 - Disaster Alert App] res\layout\main.out.xml:0: Originally defined here. [2012-04-17 01:11:14 - Disaster Alert App] C:\Users\Acer\workspace\Disaster Alert App\res\layout\main.out.xml:1: error: Error parsing XML: no element found [2012-04-17 01:14:56 - Disaster Alert App] ------------------------------ [2012-04-17 01:14:56 - Disaster Alert App] Android Launch! [2012-04-17 01:14:56 - Disaster Alert App] Connection with adb was interrupted. [2012-04-17 01:14:56 - Disaster Alert App] 0 attempts have been made to reconnect. [2012-04-17 01:14:56 - Disaster Alert App] You may want to manually restart adb from the Devices view. [2012-04-17 01:17:27 - Disaster Alert App] Error in an XML file: aborting build. [2012-04-17 01:37:10 - Disaster Alert App] res\layout\main.xml:0: error: Resource entry main is already defined. [2012-04-17 01:38:42 - Disaster Alert App] res\layout\main.xml:0: error: Resource entry main is already defined. [2012-04-17 01:38:42 - Disaster Alert App] res\layout\main.out.out.xml:0: Originally defined here. [2012-04-17 01:38:42 - Disaster Alert App] C:\Users\Acer\workspace\Disaster Alert App\res\layout\main.out.out.xml:1: error: Error parsing XML: no element found [2012-04-17 01:39:28 - Disaster Alert App] Error in an XML file: aborting build. 

Ohhh – ver el 'main.out.xml'? eso es lo que sucede cuando se inicia un archivo XML con eclipse. simplemente elimine el xml 'out' y mantenga el archivo main.xml

Asegúrese de seleccionar / estar editando un archivo .java al pulsar Reproducir, de lo contrario eclipse generará un 'out.xml' y fallará al iniciar.

solo cierre eclipse y reinicie. Eso funcionó para mí.

Me gustaría señalar que hay un error en ADT Preview 21 – Instalé Herramientas de vista previa para corregir el error de emulador de Retina de MacBook aquí: Emulador de Android no escala al 100% para Mac Book Pro con Retina Display .

Sin embargo, no puedo abrir ninguno de mis diseños ahora porque todos me dan este error. He encontrado que hay una solución: cambiar a la vista XML y hacer cualquier edición – incluso si es un solo espacio. Guardar y, a continuación, volver a diseño gráfico y el error se ha ido.

Trabajó para mí: En eclipse, haga clic en help-> check for updates. Si tiene actualizaciones disponibles (Android en particular) – instálelos.

FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.