Problema "Hola Mundo" Android

Iniciado por csp, 29 Septiembre 2014, 17:38 PM

0 Miembros y 3 Visitantes están viendo este tema.

csp

Buenas,

Estoy tratando de hacer la aplicación "Hola mundo" con Android, y tengo un problema.
Al ejecutar el AVD, al cargar la aplicación me aparece el mensaje "Unfortunately, APP_NAME has stopped".

Archivo AndroidManifest.xml

Código (xml) [Seleccionar]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.example.holamundo"
   android:versionCode="1"
   android:versionName="1.0" >

   <uses-sdk
       android:minSdkVersion="20"
       android:targetSdkVersion="20" />
   <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">
       <activity android:name="MainActivity" android:label="@string/app_name">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />

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

</manifest>


Archivo activity_main.xml

Código (xml) [Seleccionar]
<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:paddingBottom="@dimen/activity_vertical_margin"
   android:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingRight="@dimen/activity_horizontal_margin"
   android:paddingTop="@dimen/activity_vertical_margin"
   tools:context="com.example.holamundo.MainActivity" >

   <TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/hello_world" />
<TextView
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="Esta es mi primera aplicacion Android" />
<Button
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="Esto es un boton!"
   />
</RelativeLayout>


Estoy trabajando con Android 4.4 (API 20).

Alguna idea de por qué se produce esto?

Muchas gracias.

ivancea96


csp

No es el activity_main que publique arriba?

ivancea96

Pero tiene un código en Java dentro del paquete. Revisa por Google la estructura de una App Android :o

csp

Este? MainActivity.java

Código (java) [Seleccionar]
package com.example.holamundo;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}

ivancea96

La verdad, sin compilarlo, no sabría qué decir.
Lo voy a compilar y a probar, y luego te digo :D

ivancea96

A mi me funcionó todo a la perfección. No sé que problema puedes tener.

¿IDE?
¿Maquina virtual o SmartPhone para probar?
Revisa que no falte alguna entrada en values/strings.xml

csp

Buenas,

Utilizo Eclipse como IDE, y estoy trabajando con Android 4.4 (API 20).

Esto es lo que me sale en el LogCat:

Código (xml) [Seleccionar]
10-03 15:38:05.670: I/ActivityManager(356): Resuming delayed broadcast
10-03 15:38:05.690: D/GCM(529): GcmService start Intent { act=com.google.android.gms.INITIALIZE   flg=0x10 pkg=com.google.android.gms cmp=com.google.android.gms/.gcm.GcmService } com.google.android.gms.INITIALIZE
10-03 15:38:05.800: I/ActivityManager(356): Delay finish: com.google.android.gms/.wearable.init.InitializeGmsWearableReceiver
10-03 15:38:05.820: I/ActivityManager(356): Resuming delayed broadcast
10-03 15:38:05.940: D/GCM(529): GcmService start Intent { act=com.google.android.gms.INITIALIZE flg=0x10 pkg=com.google.android.gms cmp=com.google.android.gms/.gcm.GcmService } com.google.android.gms.INITIALIZE
10-03 15:38:06.030: D/GCM(529): GcmService start Intent { act=com.google.android.checkin.CHECKIN_COMPLETE flg=0x10 cmp=com.google.android.gms/.gcm.GcmService (has extras) } com.google.android.checkin.CHECKIN_COMPLETE
10-03 15:38:06.900: I/ActivityManager(356): Delay finish: com.android.providers.calendar/.CalendarProviderBroadcastReceiver
10-03 15:38:07.040: I/ActivityManager(356): Resuming delayed broadcast
10-03 15:38:15.930: I/ActivityManager(356): START u0 {act=android.intent.action.MAIN flg=0x10000000 cmp=com.example.holamundo/.MainActivity} from pid 481 on display 0
10-03 15:38:16.030: D/PermissionCache(52): checking android.permission.READ_FRAME_BUFFER for uid=1000 => granted (786 us)
10-03 15:38:16.040: D/gralloc(52): Registering a buffer in the process that created it. This may cause memory ordering problems.
10-03 15:38:16.040: E/libEGL(52): called unimplemented OpenGL ES API
10-03 15:38:16.050: E/libEGL(52): called unimplemented OpenGL ES API
10-03 15:38:16.050: E/libEGL(52): called unimplemented OpenGL ES API
10-03 15:38:16.050: E/libEGL(52): called unimplemented OpenGL ES API
10-03 15:38:16.060: E/SurfaceFlinger(52): glCheckFramebufferStatusOES error 180008443
10-03 15:38:16.060: E/SurfaceFlinger(52): got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot
10-03 15:38:16.060: E/libEGL(52): called unimplemented OpenGL ES API
10-03 15:38:16.060: E/libEGL(52): called unimplemented OpenGL ES API
10-03 15:38:16.060: W/WindowManager(356): Screenshot failure taking screenshot for (123x164) to layer 21000
10-03 15:38:16.120: D/LightsService(356): Excessive delay setting light: 111ms
10-03 15:38:16.130: D/rpctransport(513): sendRpc: failed: 6
10-03 15:38:16.240: I/ActivityManager(356): Start proc com.example.holamundo for activity com.example.holamundo/.MainActivity: pid=684 uid=10018 gids={50018}
10-03 15:38:16.300: D/dalvikvm(684): Not late-enabling CheckJNI (already on)
10-03 15:38:16.550: D/AndroidRuntime(684): Shutting down VM
10-03 15:38:16.550: W/dalvikvm(684): threadid=1: thread exiting with uncaught exception (group=0xb4a82d70)
10-03 15:38:16.570: E/AndroidRuntime(684): FATAL EXCEPTION: main
10-03 15:38:16.570: E/AndroidRuntime(684): Process: com.example.holamundo, PID: 684
10-03 15:38:16.570: E/AndroidRuntime(684): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.holamundo/com.example.holamundo.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
10-03 15:38:16.570: E/AndroidRuntime(684):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
10-03 15:38:16.570: E/AndroidRuntime(684):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
10-03 15:38:16.570: E/AndroidRuntime(684):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
10-03 15:38:16.570: E/AndroidRuntime(684):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
10-03 15:38:16.570: E/AndroidRuntime(684):  at android.os.Handler.dispatchMessage(Handler.java:102)
10-03 15:38:16.570: E/AndroidRuntime(684):  at android.os.Looper.loop(Looper.java:136)
10-03 15:38:16.570: E/AndroidRuntime(684):  at android.app.ActivityThread.main(ActivityThread.java:5026)
10-03 15:38:16.570: E/AndroidRuntime(684):  at java.lang.reflect.Method.invokeNative(Native Method)
10-03 15:38:16.570: E/AndroidRuntime(684):  at java.lang.reflect.Method.invoke(Method.java:515)
10-03 15:38:16.570: E/AndroidRuntime(684):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
10-03 15:38:16.570: E/AndroidRuntime(684):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
10-03 15:38:16.570: E/AndroidRuntime(684):  at dalvik.system.NativeStart.main(Native Method)
10-03 15:38:16.570: E/AndroidRuntime(684): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
10-03 15:38:16.570: E/AndroidRuntime(684):  at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
10-03 15:38:16.570: E/AndroidRuntime(684):  at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
10-03 15:38:16.570: E/AndroidRuntime(684):  at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
10-03 15:38:16.570: E/AndroidRuntime(684):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
10-03 15:38:16.570: E/AndroidRuntime(684):  at android.app.Activity.setContentView(Activity.java:1930)
10-03 15:38:16.570: E/AndroidRuntime(684):  at com.example.holamundo.MainActivity.onCreate(MainActivity.java:13)
10-03 15:38:16.570: E/AndroidRuntime(684):  at android.app.Activity.performCreate(Activity.java:5242)
10-03 15:38:16.570: E/AndroidRuntime(684):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-03 15:38:16.570: E/AndroidRuntime(684):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
10-03 15:38:16.570: E/AndroidRuntime(684):  ... 11 more
10-03 15:38:16.590: W/ActivityManager(356):   Force finishing activity com.example.holamundo/.MainActivity
10-03 15:38:16.610: W/InputMethodManagerService(356): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@b4ed2450 attribute=null, token = android.os.BinderProxy@b4e62a90
10-03 15:38:16.830: D/dalvikvm(356): GC_FOR_ALLOC freed 362K, 15% free 4022K/4692K, paused 43ms, total 45ms
10-03 15:38:17.080: I/Choreographer(356): Skipped 137 frames!  The application may be doing too much work on its main thread.
10-03 15:38:17.160: W/ActivityManager(356): Activity pause timeout for ActivityRecord{b4eac478 u0 com.example.holamundo/.MainActivity t2 f}
10-03 15:38:17.220: I/ARMAssembler(52): generated scanline__00000077:03515104_00009002_00000000 [127 ipp] (149 ins) at [0xb5e941f0:0xb5e94444] in 10000000 ns
10-03 15:38:17.230: I/Choreographer(356): Skipped 38 frames!  The application may be doing too much work on its main thread.
10-03 15:38:17.310: I/Choreographer(356): Skipped 49 frames!  The application may be doing too much work on its main thread.
10-03 15:38:17.340: I/Choreographer(356): Skipped 237 frames!  The application may be doing too much work on its main thread.
10-03 15:38:17.360: D/rpctransport(513): sendRpc: failed: 7
10-03 15:38:17.390: I/Choreographer(356): Skipped 45 frames!  The application may be doing too much work on its main thread.
10-03 15:38:17.440: I/Choreographer(356): Skipped 53 frames!  The application may be doing too much work on its main thread.
10-03 15:38:17.450: I/ARMAssembler(52): generated scanline__00000077:03010104_00008002_00000000 [ 89 ipp] (110 ins) at [0xb5e94450:0xb5e94608] in 0 ns
10-03 15:38:17.470: I/Choreographer(481): Skipped 42 frames!  The application may be doing too much work on its main thread.
10-03 15:38:17.480: I/Choreographer(356): Skipped 36 frames!  The application may be doing too much work on its main thread.
10-03 15:38:27.550: W/ActivityManager(356): Activity destroy timeout for ActivityRecord{b4eac478 u0 com.example.holamundo/.MainActivity t2 f}
10-03 15:38:29.020: D/ConnectivityService(356): Sampling interval elapsed, updating statistics ..
10-03 15:38:29.060: D/ConnectivityService(356): Done.
10-03 15:38:29.060: D/ConnectivityService(356): Setting timer for 720seconds
10-03 15:39:00.070: D/WearableConn(513): Error writing to device
10-03 15:39:00.070: D/WearableConn(513): java.net.ConnectException: failed to connect to /10.0.2.2 (port 5601): connect failed: ETIMEDOUT (Connection timed out)
10-03 15:39:00.070: D/WearableConn(513):    at libcore.io.IoBridge.connect(IoBridge.java:114)
10-03 15:39:00.070: D/WearableConn(513):    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
10-03 15:39:00.070: D/WearableConn(513):    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
10-03 15:39:00.070: D/WearableConn(513):    at java.net.Socket.startupSocket(Socket.java:567)
10-03 15:39:00.070: D/WearableConn(513):    at java.net.Socket.<init>(Socket.java:226)
10-03 15:39:00.070: D/WearableConn(513):    at btx.run(SourceFile:130)
10-03 15:39:00.070: D/WearableConn(513): Caused by: libcore.io.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)
10-03 15:39:00.070: D/WearableConn(513):    at libcore.io.Posix.connect(Native Method)
10-03 15:39:00.070: D/WearableConn(513):    at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:101)
10-03 15:39:00.070: D/WearableConn(513):    at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
10-03 15:39:00.070: D/WearableConn(513):    at libcore.io.IoBridge.connect(IoBridge.java:112)
10-03 15:39:00.070: D/WearableConn(513):    ... 5 more
10-03 15:39:00.110: D/WearableConn(513): Socket closed
10-03 15:39:00.170: D/WearableConn(513): Waiting 1.0 seconds to retry connection
10-03 15:39:00.250: D/dalvikvm(481): GC_FOR_ALLOC freed 491K, 16% free 3285K/3908K, paused 111ms, total 115ms
10-03 15:39:01.210: D/WearableConn(513): Connecting via TCP to /10.0.2.2:5601
10-03 15:40:04.410: D/WearableConn(513): Caused by: libcore.io.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)

ivancea96

En el manifest, prueba a poner esto:
android:theme="@android:style/Theme.DeviceDefault"
(Con poner me refiero a cambiar el theme que tienes)