Unable to instantiate fragment make sure class name..

E/UncaughtException-main(13661): Unable to start activity ComponentInfo{com.android.fileexplorer/com.android.fileexplorer.FileExplorerTabActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.android.fileexplorer.view.FileViewFragment: make sure class name exists, is public, and has an empty constructor that is public
E/UncaughtException-main(13661): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.fileexplorer/com.android.fileexplorer.FileExplorerTabActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.android.fileexplorer.view.FileViewFragment: make sure class name exists, is public, and has an empty constructor that is public
E/UncaughtException-main(13661):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
E/UncaughtException-main(13661):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
E/UncaughtException-main(13661):     at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3738)
E/UncaughtException-main(13661):     at android.app.ActivityThread.access$900(ActivityThread.java:135)
E/UncaughtException-main(13661):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
E/UncaughtException-main(13661):     at android.os.Handler.dispatchMessage(Handler.java:102)
E/UncaughtException-main(13661):     at android.os.Looper.loop(Looper.java:136)
E/UncaughtException-main(13661):     at android.app.ActivityThread.main(ActivityThread.java:5017)
E/UncaughtException-main(13661):     at java.lang.reflect.Method.invokeNative(Native Method)
E/UncaughtException-main(13661):     at java.lang.reflect.Method.invoke(Method.java:515)
E/UncaughtException-main(13661):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/UncaughtException-main(13661):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/UncaughtException-main(13661):     at dalvik.system.NativeStart.main(Native Method)
E/UncaughtException-main(13661): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.android.fileexplorer.view.FileViewFragment: make sure class name exists, is public, and has an empty constructor that is public
E/UncaughtException-main(13661):     at android.app.Fragment.instantiate(Fragment.java:601)
E/UncaughtException-main(13661):     at android.app.FragmentState.instantiate(Fragment.java:98)
E/UncaughtException-main(13661):     at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1761)
E/UncaughtException-main(13661):     at android.app.Activity.onCreate(Activity.java:899)
E/UncaughtException-main(13661):     at miui.app.Activity.onCreate(Activity.java:48)
E/UncaughtException-main(13661):     at com.android.fileexplorer.FileExplorerTabActivity.onCreate(FileExplorerTabActivity.java:39)
E/UncaughtException-main(13661):     at android.app.Activity.performCreate(Activity.java:5231)
E/UncaughtException-main(13661):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
E/UncaughtException-main(13661):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
E/UncaughtException-main(13661):     ... 12 more
E/UncaughtException-main(13661): Caused by: java.lang.InstantiationException: can‘t instantiate class com.android.fileexplorer.view.FileViewFragment; no empty constructor
E/UncaughtException-main(13661):     at java.lang.Class.newInstanceImpl(Native Method)
E/UncaughtException-main(13661):     at java.lang.Class.newInstance(Class.java:1208)
E/UncaughtException-main(13661):     at android.app.Fragment.instantiate(Fragment.java:590)
E/UncaughtException-main(13661):     ... 20 more

解决方法:自定义的fragment最好有一个Public的参数为空的构造函数,若需要传入一个参数,可以使用下面的方法
public FileViewFragment(){    }
 public static FileViewFragment getInstance(A a){
        FileViewFragment fileViewFragment = new FileViewFragment();
        fileViewFragment.a = a;
        return fileViewFragment;
    }

时间: 2024-11-02 12:56:36

Unable to instantiate fragment make sure class name..的相关文章

Unable to instantiate fragment com.viewpager.demo.FirstFragment: make sure class name exists, is pub

尊重原创:http://blog.csdn.net/yuanzeyao/article/details/40922875 最近在项目中经常遇到旋转屏幕或者home键退至后台,然后恢复前台导致应用崩溃,崩溃log如标题所示,从log的信息来看,导致崩溃的原因是该Fragment没有提供一个默认构造函数(无参构造函数),经过深入分析发现,Activity中有Fragment,并且Fragment没有无参构造函数,那么这个崩溃非常容易出现,因为在旋转屏幕的过程中,Activity是会被销毁重建的,这个

android异常Unable to instantiate activity ComponentInfo解决方法

本人最近调试一个调试一个程序,jar包都添加好了,程序没有任何错误信息,但是运行到手机,却打印出这样的错误信息: 08-29 20:07:52.584: E/AndroidRuntime(4517): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.zhy.csdndemo/com.zhy.csdndemo.MainActivity}: java.lang.ClassNotFoundExce

Unable to instantiate Action异常

严重: Exception occurred during processing request: Unable to instantiate Action, SsbkAction,  defined for 'SsbkAction' in namespace ''Error creating bean with name 'SsbkAction' defined in file [D:\Program Files (x86)\Liuhe\code\myeclipse 2014 code\.me

2.Unable to instantiate Action, templateAction, defined for 'template_list' in namespace '/'templateAction

1.错误说没有命名空间'templateAction,但是在struts里写了这个,名字跟Action的名字是一样的,为什么会报这个错误 2.反复检查路径和名字,都没有问题 3.发现没有对其进行注入操作,所以一定要记得注入 2.Unable to instantiate Action, templateAction, defined for 'template_list' in namespace '/'templateAction

android启动时报错Unable to instantiate application xxxx:java.lang.NullPointerException

如果程序已经运行,再安装到手机的时候总是报以下错误.而且是在打开特定的Activity的情况下才会报错. 06-26 09:45:16.971: E/AndroidRuntime(29733): java.lang.RuntimeException: Unable to instantiate application com.css.promotiontool.ui.CSSAppliction: java.lang.NullPointerException06-26 09:45:16.971:

hive 报错 java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient

Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:344) at org.a

hive报Unable to instantiate org.apache.hadoop.hive.

Logging initialized using configuration in jar:file:/usr/share/hive/lib/hive-common-0.13.1.jar!/hive-log4j.properties Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive

运行ssh项目出现"HTTP Status 500 - Unable to instantiate Action"

开始整合ssh框架报的错: HTTP Status 500 - Unable to instantiate Action, employeeAction, defined for 'show' in namespace '/'Error creating bean with name 'employeeAction' defined in file [E:\javaTools\apache-tomcat-8.0.15\webapps\ssh\WEB-INF\classes\bean-action

Android - 错误:Unable to instantiate application

错误:Unable to instantiate application 本文地址: http://blog.csdn.net/caroline_wendy 错误:java.lang.RuntimeException: Unable to instantiate application me.chunyu.paddoctor.Activity Java执行时异常,不能实例化应用:XXX. 原因: <application>的"android:name"属性错误.即andro