大家好,我从我的开发者控制台得到了这个堆栈跟踪。我不确定是什么导致了这个崩溃,因为在测试我的应用程序时从未遇到过这个错误,只是从Google Play的开发者控制台中得到了它。
任何人都可以帮我分析这个问题吗?并给我一些有用的建议。谢谢,问候...
编辑:
这是PhotoPreviewFragmentAdapter代码。
“给我一些关于如何重现这个崩溃的线索可能会对我非常有帮助。谢谢。
编辑:
也许问题就像“波士顿街道”所说的那样,是PhotoTumbnailFragmentAdapter中的匿名内部类,我在这个方法中使用了它。”
PhotoThumbnailFragment是一个独立的类,顺便说一下。
java.lang.RuntimeException: Unable to start activity ComponentInfo{package.name/package.name.activity.SomeActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment package.name.photopreview.PhotoThumbnailFragmentAdapter$1: make sure class name exists, is public, and has an empty constructor that is public
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
at android.app.ActivityThread.access$700(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment streetdirectory.mobile.modules.photopreview.PhotoThumbnailFragmentAdapter$1: make sure class name exists, is public, and has an empty constructor that is public
at android.support.v4.app.Fragment.instantiate(Fragment.java:399)
at android.support.v4.app.FragmentState.instantiate(Fragment.java:97)
at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1760)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:200)
at streetdirectory.mobile.modules.businessdetail.BusinessDetailActivity.onCreate(BusinessDetailActivity.java:134)
at android.app.Activity.performCreate(Activity.java:5188)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
... 11 more
Caused by: java.lang.InstantiationException: can't instantiate class streetdirectory.mobile.modules.photopreview.PhotoThumbnailFragmentAdapter$1; no empty constructor
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.support.v4.app.Fragment.instantiate(Fragment.java:388)
... 18 more
任何人都可以帮我分析这个问题吗?并给我一些有用的建议。谢谢,问候...
编辑:
这是PhotoPreviewFragmentAdapter代码。
public class PhotoPreviewFragmentAdapter<T extends ImageListServiceOutput> extends FragmentPagerAdapter {
private ArrayList<T> mData = new ArrayList<T>();
public PhotoPreviewFragmentAdapter(FragmentManager fm) {
super(fm);
}
public void setData(ArrayList<T> data) {
mData = data;
}
@SuppressLint("ValidFragment")
@Override
public Fragment getItem(final int position) {
PhotoPreviewFragment view = new PhotoPreviewFragment() {
@Override
public ImageListServiceOutput getData() {
if (position < mData.size()) {
return mData.get(position);
}
return null;
}
};
return view;
}
@Override
public int getCount() {
// TODO Add Photo Button
//return mData.size()+1;
return mData.size();
}
}
“给我一些关于如何重现这个崩溃的线索可能会对我非常有帮助。谢谢。
编辑:
也许问题就像“波士顿街道”所说的那样,是PhotoTumbnailFragmentAdapter中的匿名内部类,我在这个方法中使用了它。”
public Fragment getItem(final int position) {
PhotoThumbnailFragment view = new PhotoThumbnailFragment() {
@Override
public ImageListServiceOutput getData() {
if (position < mData.size()) {
return mData.get(position);
}
return null;
}
public void onPhotoClicked(ImageListServiceOutput data) {
if (mImageClickedListener != null) {
if (data != null) {
Logger.info("Photo Clicked");
mImageClickedListener.onImageClicked(data, position);
} else {
Logger.info("Add Photo Clicked");
mImageClickedListener.onAddImageClicked(position);
}
}
}
};
return view;
}
PhotoThumbnailFragment是一个独立的类,顺便说一下。
PhotoThumbnailFragmentAdapter
代码吗? - GrIsHumData
,可以通过实现mData
的setter方法来访问它。 - kingori