2012-03-30 10 views
0

Ich bin neu in Android, aber OK mit Java, und lieber Netbeans zu Eclipse. Ich versuche, die HelloAndroid-App ohne Erfolg zu starten.Android & Netbeans: "unerwartet gestoppt"

package com.ex.helloandroid; 

import android.app.Activity; 
import android.os.Bundle; 
import android.widget.TextView; 

public class HelloAndroid extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    TextView tv = new TextView(this); 
    tv.setText("Hello, Android"); 
    setContentView(tv); 
} 
} 

Manifest:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.ex.helloandroid" 
    android:versionCode="1" 
    android:versionName="1.0"> 
<application android:label="@string/app_name" > 
    <activity android:name="HelloAndroid" 
       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> 

Dies kompiliert OK und installiert OK sowohl im Emulator und mein Handy. Aber wenn ich versuche, es auszuführen, bekomme ich das gefürchtete "Die Anwendung HelloAndroid (process com.ex.helloandroid) wurde unerwartet beendet. Bitte versuchen Sie es erneut."

Hier ist die logcat:

I/ActivityManager( 70): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.ex.helloandroid/.HelloAndroid } 
I/ActivityManager( 70): Start proc com.ex.helloandroid for activity com.ex.helloandroid/.HelloAndroid: pid=691 uid=10036 gids={1015} 
D/AndroidRuntime( 691): Shutting down VM 
W/dalvikvm( 691): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 
E/AndroidRuntime( 691): FATAL EXCEPTION: main 
E/AndroidRuntime( 691): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.ex.helloandroid/com.ex.helloandroid.HelloAndroid}: java.lang.ClassNotFoundException: com.ex.helloandroid.HelloAndroid in loader dalvik.system.PathClassLoader[/dat 
a/app/com.ex.helloandroid-1.apk] 
E/AndroidRuntime( 691):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585) 
E/AndroidRuntime( 691):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
E/AndroidRuntime( 691):  at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
E/AndroidRuntime( 691):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
E/AndroidRuntime( 691):  at android.os.Handler.dispatchMessage(Handler.java:99) 
E/AndroidRuntime( 691):  at android.os.Looper.loop(Looper.java:123) 
E/AndroidRuntime( 691):  at android.app.ActivityThread.main(ActivityThread.java:4627) 
E/AndroidRuntime( 691):  at java.lang.reflect.Method.invokeNative(Native Method) 
E/AndroidRuntime( 691):  at java.lang.reflect.Method.invoke(Method.java:521) 
E/AndroidRuntime( 691):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
E/AndroidRuntime( 691):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
E/AndroidRuntime( 691):  at dalvik.system.NativeStart.main(Native Method) 
E/AndroidRuntime( 691): Caused by: java.lang.ClassNotFoundException: com.ex.helloandroid.HelloAndroid in loader dalvik.system.PathC 
lassLoader[/data/app/com.ex.helloandroid-1.apk] 
E/AndroidRuntime( 691):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) 
E/AndroidRuntime( 691):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573) 
E/AndroidRuntime( 691):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532) 
E/AndroidRuntime( 691):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 
E/AndroidRuntime( 691):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577) 
E/AndroidRuntime( 691):  ... 11 more 
W/ActivityManager( 70): Force finishing activity com.ex.helloandroid/.HelloAndroid 
W/ActivityManager( 70): Activity pause timeout for HistoryRecord{45422d20 com.ex.helloandroid/.HelloAndroid} 
W/ActivityManager( 70): Activity destroy timeout for HistoryRecord{45422d20 com.ex.helloandroid/.HelloAndroid} 
I/Process ( 691): Sending signal. PID: 691 SIG: 9 
I/ActivityManager( 70): Process com.ex.helloandroid (pid 691) has died. 
W/InputManagerService( 70): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Prox 
[email protected] 

ich damit verbracht habe Tage versucht, diese Arbeit zu machen ... eine neue Kopie von Netbeans installiert, neu installiert NBAndroid, neu installiert Android SDK, gegoogelt und mit dem Code getüftelt. Kann mir bitte jemand helfen?

Dank

Frank

Antwort

0

Das Projekt scheint gut zu laufen. Ich habe deine Aktivität und mein Manifest benutzt und es gab keine Probleme. Versuchen Sie, Ihr Projekt zu säubern. GO Projekt -> Sauber

+0

Sorry, soll ich gesagt habe ich eine Java-Bibliothek mit dem Android-Projekt zu verbinden versuche, und hatte meinen Quellcode der ganzen Weg zurück zu Vanille HelloAndroid regrediert. Aber die Bibliothek aus dem Android-Projekt nicht entfernt. Es scheint also, dass das Problem etwas damit zu tun hat, ein Java Library-Projekt mit der Android-App zu verknüpfen ... selbst wenn die App nichts in der Bibliothek verwendet, verursacht die Tatsache, dass sie dort ist, einen Absturz der App. – user998303

0
setContentView(R.layout.main); 

Setzen Sie Ihre main.xml. Verwenden DroidDraw main.xml zu erstellen und ruft setContentView(R.layout.main); statt setContentView(tv);