Foros del Web » Programando para Internet » Android »

error eclipse android

Estas en el tema de error eclipse android en el foro de Android en Foros del Web. hola he iniciado a programar en eclipse android y tengo este error, cual no se que es: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código log: Ver original 05-23 18:03:23.537: ...
  #1 (permalink)  
Antiguo 23/05/2014, 16:15
Avatar de kakashi20  
Fecha de Ingreso: septiembre-2009
Mensajes: 616
Antigüedad: 14 años, 7 meses
Puntos: 15
Exclamación error eclipse android

hola

he iniciado a programar en eclipse android y tengo este error, cual no se que es:

Código log:
Ver original
  1. 05-23 18:03:23.537: D/AndroidRuntime(1289): Shutting down VM
  2. 05-23 18:03:23.537: W/dalvikvm(1289): threadid=1: thread exiting with uncaught exception (group=0xb3a77ba8)
  3. 05-23 18:03:23.557: E/AndroidRuntime(1289): FATAL EXCEPTION: main
  4. 05-23 18:03:23.557: E/AndroidRuntime(1289): Process: com.example.holausuario, PID: 1289
  5. 05-23 18:03:23.557: E/AndroidRuntime(1289): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.holausuario/com.example.holausuario.MainActivity}: java.lang.NullPointerException
  6. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
  7. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
  8. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
  9. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
  10. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at android.os.Handler.dispatchMessage(Handler.java:102)
  11. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at android.os.Looper.loop(Looper.java:136)
  12. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at android.app.ActivityThread.main(ActivityThread.java:5017)
  13. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at java.lang.reflect.Method.invokeNative(Native Method)
  14. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at java.lang.reflect.Method.invoke(Method.java:515)
  15. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
  16. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
  17. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at dalvik.system.NativeStart.main(Native Method)
  18. 05-23 18:03:23.557: E/AndroidRuntime(1289): Caused by: java.lang.NullPointerException
  19. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at com.example.holausuario.MainActivity.onCreate(MainActivity.java:34)
  20. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at android.app.Activity.performCreate(Activity.java:5231)
  21. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
  22. 05-23 18:03:23.557: E/AndroidRuntime(1289):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
  23. 05-23 18:03:23.557: E/AndroidRuntime(1289):     ... 11 more
  24. 05-23 18:06:35.097: I/Process(1289): Sending signal. PID: 1289 SIG: 9

este es mi archivo de manifiesto

Código XML:
Ver original
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.    package="com.example.holausuario"
  4.    android:versionCode="1"
  5.    android:versionName="1.0" >
  6.  
  7.     <uses-sdk
  8.        android:minSdkVersion="8"
  9.        android:targetSdkVersion="19" />
  10.  
  11.     <application
  12.        android:allowBackup="true"
  13.        android:icon="@drawable/ic_launcher"
  14.        android:label="@string/app_name"
  15.        android:theme="@style/AppTheme" >
  16.         <activity
  17.            android:name="com.example.holausuario.MainActivity"
  18.            android:label="@string/app_name" >
  19.             <intent-filter>
  20.                 <action android:name="android.intent.action.MAIN" />
  21.  
  22.                 <category android:name="android.intent.category.LAUNCHER" />
  23.             </intent-filter>
  24.         </activity>
  25.     </application>
  26.  
  27. </manifest>


fragment_main.xml

Código XML:
Ver original
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.    xmlns:tools="http://schemas.android.com/tools"
  3.    android:layout_width="match_parent"
  4.    android:layout_height="match_parent"
  5.    android:paddingBottom="@dimen/activity_vertical_margin"
  6.    android:paddingLeft="@dimen/activity_horizontal_margin"
  7.    android:paddingRight="@dimen/activity_horizontal_margin"
  8.    android:paddingTop="@dimen/activity_vertical_margin"
  9.    tools:context="com.example.holausuario.MainActivity$PlaceholderFragment" >
  10.  
  11.     <TextView
  12.        android:id="@+id/LblNombre"
  13.        android:layout_width="wrap_content"
  14.        android:layout_height="wrap_content"
  15.        android:text="Escribe tu nombre:" />
  16.  
  17.     <Button
  18.        android:id="@+id/BtnHola"
  19.        android:layout_width="wrap_content"
  20.        android:layout_height="wrap_content"
  21.        android:layout_alignLeft="@+id/TxtNombre"
  22.        android:layout_below="@+id/TxtNombre"
  23.        android:layout_marginTop="18dp"
  24.        android:text="Aceptar" />
  25.  
  26.     <EditText
  27.        android:id="@+id/TxtNombre"
  28.        android:layout_width="match_parent"
  29.        android:layout_height="wrap_content"
  30.        android:layout_alignLeft="@+id/LblNombre"
  31.        android:layout_below="@+id/LblNombre"
  32.        android:layout_marginTop="16dp"
  33.        android:ems="10"
  34.        android:inputType="text" />
  35.  
  36. </RelativeLayout>


MainActivity.java

Código Java:
Ver original
  1. package com.example.holausuario;
  2.  
  3. import android.support.v7.app.ActionBarActivity;
  4. import android.support.v7.app.ActionBar;
  5. import android.support.v4.app.Fragment;
  6. import android.os.Bundle;
  7. import android.view.LayoutInflater;
  8. import android.view.Menu;
  9. import android.view.MenuItem;
  10. import android.view.View;
  11. import android.view.ViewGroup;
  12. import android.os.Build;
  13. import android.view.View.OnClickListener;
  14. import android.widget.Button;
  15. import android.widget.EditText;
  16. import android.content.Intent;
  17.  
  18. public class MainActivity extends ActionBarActivity {
  19.  
  20.    
  21.     @Override
  22.     protected void onCreate(Bundle savedInstanceState) {
  23.         super.onCreate(savedInstanceState);
  24.         setContentView(R.layout.activity_main);
  25.        
  26.        
  27.      // OBTENGO LA REFERENCIA DE LOS OBJETOS CREADOS EN EL FORM DEL MAIN PRINCIPAL
  28.        
  29.         final Button btnHola = (Button)findViewById(R.id.BtnHola);
  30.         final EditText txtNombre = (EditText)findViewById(R.id.TxtNombre);
  31.        
  32.       //-----------------------------------------------------------------------------
  33.        
  34.         btnHola.setOnClickListener(new OnClickListener() {
  35.  
  36.    
  37.             public void onClick(View v) {
  38.                
  39.                
  40.                 // Creamos el Intent, el cual se comunica entre distintas aplicacion y componentes.
  41.                 Intent intent =
  42.                         new Intent(MainActivity.this, FrmSaludo.class);
  43.                
  44.               //Creamos la información a pasar entre actividades en el objeto Bundle que contiene la estructura ( clave, valor ), en pocas palabras son las variables que puedes enviar de pagina a pagina
  45.                 Bundle b = new Bundle();
  46.                 b.putString("NOMBRE", txtNombre.getText().toString()); // añadimos el variable string al objeto, mediante la estrcutura ( clave, valor )
  47.  
  48.                 //Añadimos la información al intent, ya que el intent es el que te permite interactuar de pagina a pagina.
  49.                 intent.putExtras(b);
  50.                
  51.                
  52.               //Iniciamos la nueva actividad y le pasamos el intent el cual nos muestra a la pantalla que mandamos, osea iniciamos el envio de pagina a pagina
  53.                 startActivity(intent);
  54.             }
  55.            
  56.            
  57.        
  58.         });
  59.        
  60.        
  61.  
  62.         if (savedInstanceState == null) {
  63.             getSupportFragmentManager().beginTransaction()
  64.                     .add(R.id.container, new PlaceholderFragment())
  65.                     .commit();
  66.         }
  67.     }
  68.    
  69.    
  70.  
  71.  
  72.     @Override
  73.     public boolean onCreateOptionsMenu(Menu menu) {
  74.        
  75.         // Inflate the menu; this adds items to the action bar if it is present.
  76.         getMenuInflater().inflate(R.menu.main, menu);
  77.         return true;
  78.     }
  79.  
  80.     @Override
  81.     public boolean onOptionsItemSelected(MenuItem item) {
  82.         // Handle action bar item clicks here. The action bar will
  83.         // automatically handle clicks on the Home/Up button, so long
  84.         // as you specify a parent activity in AndroidManifest.xml.
  85.         int id = item.getItemId();
  86.         if (id == R.id.action_settings) {
  87.             return true;
  88.         }
  89.         return super.onOptionsItemSelected(item);
  90.     }
  91.  
  92.     /**
  93.      * A placeholder fragment containing a simple view.
  94.      */
  95.     public static class PlaceholderFragment extends Fragment {
  96.  
  97.         public PlaceholderFragment() {
  98.         }
  99.  
  100.         @Override
  101.         public View onCreateView(LayoutInflater inflater, ViewGroup container,
  102.                 Bundle savedInstanceState) {
  103.             View rootView = inflater.inflate(R.layout.fragment_main, container, false);
  104.             return rootView;
  105.         }
  106.     }
  107.  
  108. }



alguien que me ayude por favor.. gracias
  #2 (permalink)  
Antiguo 26/05/2014, 16:32
Avatar de darkasecas  
Fecha de Ingreso: marzo-2005
Ubicación: SantaCata, NL, Mexico
Mensajes: 1.553
Antigüedad: 19 años, 1 mes
Puntos: 77
Respuesta: error eclipse android

El mensaje de error dice claramente Null pointer exception. Verifica que btnHola no sea nulo

Etiquetas: activity, androi, aplicacion, app, eclipse, horizontal, layout, view
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:27.