2012-03-25 10 views
1

Ich habe im Play Store viele einfache, alte, auf Aktivitäten basierende Apps. Seit zwei Tagen versuche ich meine ersten Schritte mit Fragments zu machen. Ich verstehe es immer noch nicht. Ich habe hauptsächlich alle Dokumente und Blogs und Anleitungen zu Fragmenten gelesen, aber meine dumme einfache Test-App weigert sich, mit einer ClassNotFoundException auf MyActivity zu beginnen.ActivityNotFoundException on FragmentActivity

Also hier ist, was ich bisher getan:

Der Start FragmentActivity genannt MyActivity:

public class MyActivity extends FragmentActivity { 

    @Override 
    public void onCreate(Bundle bundle) { 
     super.onCreate(bundle); 

     setContentView(R.layout.myactivity); 
    } 
} 

Hier ist das Layout/myactivity.xml:

<LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal" > 

    <fragment 
     class="com.test.app.Table1List" 
     android:id="@+id/table1list" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent" /> 
</LinearLayout> 

Dies ist ListFragment mit seinen XML-Datei:

public class Table1List extends ListFragment { 

    @Override 
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { 
     if (viewGroup == null) { 
      return null; 
     } 

     return layoutInflater.inflate(R.layout.table1list, viewGroup); 
    } 
} 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" > 

    <ListView 
     android:drawSelectorOnTop="false" 
     android:fastScrollEnabled="true" 
     android:id="@id/android:list" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" /> 

    <TextView 
     style="@style/TextViewMedium" 
     android:id="@id/android:empty" 
     android:text="@string/txt_noresult" /> 
</LinearLayout> 

Nennen Sie mich dumm, aber ich bekomme immer eine ActivityNotFoundException beim Start der FragmentActivity namens MyActivity.

Jede Hilfe wird sehr geschätzt.

EDIT:

Ich nahm das neueste Paket v4 Kompatibilität von einigen Tagen vor. Ich habe fast alle 10 Minuten saubere Projekte veröffentlicht - nein.

Hier ist das Manifest:

<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:versionCode="1" 
    android:versionName="1.0" 
    package="com.test.app" > 

    <uses-sdk 
     android:minSdkVersion="7" 
     android:targetSdkVersion="11" /> 

    <application 
     android:hardwareAccelerated="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/txt_appname" > 

     <activity 
      android:label="@string/txt_appname" 
      android:name="MyActivity" > 

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

EDIT 2: Hier ist die LogCat:

Unable to resolve superclass of Lcom/test/app/MyActivity; (25) 
Link of class 'Lcom/test/app/MyActivity;' failed 
Shutting down VM 
threadid=3: thread exiting with uncaught exception (group=0x4001b188) 
    Uncaught handler: thread main exiting due to uncaught exception 
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.test.app/com.test.app.MyActivity}: java.lang.ClassNotFoundException: com.test.app.MyActivity in loader [email protected] 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 
    at android.app.ActivityThread.access$2200(ActivityThread.java:119) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 
    at android.os.Handler.dispatchMessage(Handler.java:99) 
    at android.os.Looper.loop(Looper.java:123) 
    at android.app.ActivityThread.main(ActivityThread.java:4363) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:521) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
    at dalvik.system.NativeStart.main(Native Method) 
    Caused by: java.lang.ClassNotFoundException: com.test.app.MyActivity in loader [email protected] 
    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:573) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:532) 
    at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409) 
    ... 11 more 

EDIT 3: Ich habe das Support-Paket neu installieren, erstellt ein neues Projekt mit Compatability Package v4, alles auf die MyActivity und ein Fragment reduziert -> gleicher Fehler. Ich habe sogar mit dem vorherigen Support v4-Paket (Release 6) getestet.

Dies sind meine ersten Schritte mit Fragments nach fast drei Jahren mit Android-Entwicklung (viele Apps auf dem Markt). Scheint, dass das Ganze kaputt ist.

Dies ist der Projektbaum in Eclipse - jede Hilfe immer noch sehr erforderlich.

enter image description here

+2

Bitte teilen Sie die Manifest-Datei –

+0

scheint eine Manifest-Ausgabe – Blackbelt

+0

Auch teilen Sie die Zeilen von Ihnen anmelden, könnte mehr Licht auf die Ursache werfen :) – erbsman

Antwort

11

rekombinieren Ich weiß nicht, ob dies Ihr Problem zu beheben, aber in Ihrem Screenshot sucht, sieht mir alles richtig außer den Referenced Libraries Artikel. Das sollte nicht mehr sein, denn die neueste ADT-Version 17 erkennt automatisch alle Gläser im Ordner libs. Sie können das Element Referenced Libraries loswerden, indem Sie den expliziten Verweis auf das Android-Support-Jar aus dem Build-Pfad entfernen.

Ich hatte ein sehr ähnliches Problem und wurde für eine Weile völlig ratlos, bis ich this blog post lesen, das eine Menge Informationen zu diesem Problem hat, so dass es sogar einen Wert gelesen werden könnte, wenn die Referenced Libraries Entfernen funktioniert nicht.

+1

Ah, ich sehe, danke. Dies scheint den Trick zu machen. –

+0

löste mein Problem. Vielen Dank! – Stark

0

Etwas scheint nicht wie erwartet zu arbeiten. Kopieren Sie die Kompatibilität Glas in einen Ordner Libs und anschließend neu kompilieren und

+0

Bitte beachten Sie Edit 3 in meinem ursprünglichen Beitrag. Ich habe fast alles gemacht, Support-Paket neu installiert (in der Tat das vorherige und das aktuelle - eins nach dem anderen), ein neues Android-Projekt erstellt, die Dateien auf nur eine Aktivität und ein Fragment reduziert. Derselbe Fehler. Was passiert hier? Hat jemand das mit den neuesten SDK Tools, dem neuesten Eclipse und dem neuesten von allen getestet? –

+0

Überprüfen Sie diesen Blogpost - es rät, genau das zu tun, was ich geschrieben habe https://plus.sandbox.google.com/109385828142935151413/posts/RL91VJd1yti –

+0

Ich bekomme einen nicht gefunden Fehler auf dieser Seite. –

Verwandte Themen