3

我正在制作一个包含选项卡中的片段的应用程序。每当我尝试调用应用内计费请求购买时,它都会给我粘贴下面的错误。

这是我在应用程序中调用片段的设计。

CalendarUIActivity (FragmentActivity) -> CalendarUIMain (Fragment) -> When the user ask for more then InAppSubsricbe (DialogFragment) -> On click of OK of above dialog another dialog fragment got open with list of In-App Products which InAppProductsList(DialogFragment)

现在,当我单击 Dialog Fragment 中的产品列表时,Edit it redirects it method to main CalendarUIMain Fragment at that time它给了我错误(如下粘贴),市场购买屏幕已成功打开。但是在单击购买屏幕的 OK 时,它会随着应用程序被强制关闭而消失。

04-11 09:10:52.450: E/AndroidRuntime(1966): FATAL EXCEPTION: main
04-11 09:10:52.450: E/AndroidRuntime(1966): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.uks.android.epn.activity/com.uks.android.epn.activity.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.uks.android.epn.activity/com.uks.android.epn.activity.CalendarUIActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.uks.android.epn.fragments.CalendarUIMain$InAppProductsDialog: make sure class name exists, is public, and has an empty constructor that is public
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1818)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1834)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3200)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.ActivityThread.access$600(ActivityThread.java:125)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1031)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.os.Looper.loop(Looper.java:132)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.ActivityThread.main(ActivityThread.java:4135)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at java.lang.reflect.Method.invokeNative(Native Method)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at java.lang.reflect.Method.invoke(Method.java:491)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at dalvik.system.NativeStart.main(Native Method)
04-11 09:10:52.450: E/AndroidRuntime(1966): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.uks.android.epn.activity/com.uks.android.epn.activity.CalendarUIActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.uks.android.epn.fragments.CalendarUIMain$InAppProductsDialog: make sure class name exists, is public, and has an empty constructor that is public
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1818)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:1659)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:676)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.widget.TabHost.setCurrentTab(TabHost.java:345)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.widget.TabHost.addTab(TabHost.java:235)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at com.uks.android.epn.activity.MainActivity.addTab(MainActivity.java:78)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at com.uks.android.epn.activity.MainActivity.initTabs(MainActivity.java:45)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at com.uks.android.epn.activity.MainActivity.onCreate(MainActivity.java:35)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.Activity.performCreate(Activity.java:4397)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1782)
04-11 09:10:52.450: E/AndroidRuntime(1966):     ... 12 more
04-11 09:10:52.450: E/AndroidRuntime(1966): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.uks.android.epn.fragments.CalendarUIMain$InAppProductsDialog: make sure class name exists, is public, and has an empty constructor that is public
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.support.v4.app.Fragment.instantiate(Fragment.java:395)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.support.v4.app.FragmentState.instantiate(Fragment.java:96)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1726)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:198)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at com.uks.android.epn.activity.ActivitysTab.onCreate(ActivitysTab.java:25)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at com.uks.android.epn.activity.CalendarUIActivity.onCreate(CalendarUIActivity.java:23)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.Activity.performCreate(Activity.java:4397)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1782)
04-11 09:10:52.450: E/AndroidRuntime(1966):     ... 24 more
04-11 09:10:52.450: E/AndroidRuntime(1966): Caused by: java.lang.InstantiationException: com.uks.android.epn.fragments.CalendarUIMain$InAppProductsDialog
04-11 09:10:52.450: E/AndroidRuntime(1966):     at java.lang.Class.newInstanceImpl(Native Method)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at java.lang.Class.newInstance(Class.java:1301)
04-11 09:10:52.450: E/AndroidRuntime(1966):     at android.support.v4.app.Fragment.instantiate(Fragment.java:384)
04-11 09:10:52.450: E/AndroidRuntime(1966):     ... 32 more

现在请参考这个链接的代码(因为代码有点大)。关联

提前致谢。

4

2 回答 2

1

显示来自 的相关代码CalendarUIMain$InAppProductsDialog。是InAppProductsDialog静态内部类吗?它有可访问的默认构造函数吗?

于 2012-04-11T06:38:53.003 回答
1

很抱歉打扰 Stacked Guys 的回答,

这是一个简单的问题,我发现片段没有在屏幕方向被实例化,因为屏幕方向被锁定portrait。所以每当我在平板电脑上测试该代码时,Google Play 的屏幕都会进入横向模式,这反过来会导致异常.

感谢@Nikolay Elenkov 提供静态内部类的想法。

于 2012-04-11T09:14:18.640 回答