【问题标题】:Fragment Activity Crash片段活动崩溃
【发布时间】:2013-12-02 16:26:41
【问题描述】:

我正在使用一个扩展 fragmentactivity 的类,但是当我运行它时它崩溃了。 logcat 给了我这个错误“原因:java.lang.ClassNotFoundException:在路径上找不到类“com.example.one.MainActivity”:DexPathList [[zip 文件“/data/app/com.example.one- 2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.one-2, /vendor/lib, /system/lib]]" 有人可以帮忙吗?

     package com.example.one;

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

     import android.os.Bundle;

      import android.support.v4.app.Fragment;
    import android.support.v4.app.FragmentActivity;
    import android.view.Menu;

    public class MainActivity extends FragmentActivity {

@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;
}

}

【问题讨论】:

  • 您是否在 AndroidManifest 中声明了您的活动?
  • 是的,活动已声明
  • 当我只放扩展活动时它可以工作

标签: android android-fragmentactivity


【解决方案1】:

旧版本的 android 不支持 Fragments。
右键单击您的项目,选择 Android 工具 > 添加支持库。再次运行您的应用,它应该可以工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多