1

我有以下活动

package com.appnetics;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.Button;

public class FragmenttestActivity extends FragmentActivity {
    Button LogIn = null ;
    final   FragmentManager fragmentManager =    getSupportFragmentManager()  ;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        LogIn = (Button) findViewById(R.id.btn_showdetails); 
        LogInEvent() ; 
    }
public void LogInEvent(){

        LogIn.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {


                        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                        details fragment = new details();
                        fragmentTransaction.add(R.id.my_parent_layout, fragment);
                        fragmentTransaction.commit();


            }
        }); 

    }


}

我称之为清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.appnetics"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".FragmenttestActivity"
            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>

问题是应用程序崩溃给这个日志猫

05-30 14:31:10.970: W/dalvikvm(4958): Unable to resolve superclass of Lcom/appnetics/FragmenttestActivity; (5)
05-30 14:31:10.970: W/dalvikvm(4958): Link of class 'Lcom/appnetics/FragmenttestActivity;' failed
05-30 14:31:10.970: D/AndroidRuntime(4958): Shutting down VM
05-30 14:31:10.970: W/dalvikvm(4958): threadid=1: thread exiting with uncaught exception (group=0x402ce760)
05-30 14:31:10.980: E/AndroidRuntime(4958): FATAL EXCEPTION: main
05-30 14:31:10.980: E/AndroidRuntime(4958): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.appnetics/com.appnetics.FragmenttestActivity}: java.lang.ClassNotFoundException: com.appnetics.FragmenttestActivity in loader dalvik.system.PathClassLoader[/data/app/com.appnetics-1.apk]
05-30 14:31:10.980: E/AndroidRuntime(4958):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1739)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at android.app.ActivityThread.access$500(ActivityThread.java:122)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at android.os.Looper.loop(Looper.java:132)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at android.app.ActivityThread.main(ActivityThread.java:4123)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at java.lang.reflect.Method.invokeNative(Native Method)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at java.lang.reflect.Method.invoke(Method.java:491)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at dalvik.system.NativeStart.main(Native Method)
05-30 14:31:10.980: E/AndroidRuntime(4958): Caused by: java.lang.ClassNotFoundException: com.appnetics.FragmenttestActivity in loader dalvik.system.PathClassLoader[/data/app/com.appnetics-1.apk]
05-30 14:31:10.980: E/AndroidRuntime(4958):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at java.lang.ClassLoader.loadClass(ClassLoader.java:540)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at java.lang.ClassLoader.loadClass(ClassLoader.java:500)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at android.app.Instrumentation.newActivity(Instrumentation.java:1025)
05-30 14:31:10.980: E/AndroidRuntime(4958):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1730)
05-30 14:31:10.980: E/AndroidRuntime(4958):     ... 11 more

我确定活动的名称,我不知道为什么有任何想法

4

2 回答 2

2

如果您正在使用the ADT >= 17,则必须将支持包的 jar 复制到libs项目中的文件夹中。

于 2012-05-30T12:39:05.847 回答
1

已在 eclipse 的 bulid 路径中添加了 jar 请按照以下链接获取更多信息....

http://tools.android.com/recent/dealingwithdependenciesinandroidprojects

http://mobile.tutsplus.com/tutorials/android/jar-for-android/

于 2012-05-30T12:34:36.817 回答