Question

I am making an app which contains fragments within tabs.In this whenever I try to call in-app billing request purchase it gives me the error pasted below.

Here is the design of my fragments call within app.

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)

Now when I click on list of product from Dialog Fragment Edit it redirects it method to main CalendarUIMain Fragment at that time it gives me error (as pasted below) with the market purchase screen opened successfully.But on click on OK of purchase screen it disappers as the application is forced close.

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

Now please refer this link for the code(because the code is somewhat larger).Link

Thanks In Advance.

Was it helpful?

Solution 2

Sorry to disturb Stacked Guys in giving answers,

It is an simple problem I have found out that the fragment is not instantiated at the screen orientation as the screen orientation is locked to portrait.So whenever I tested that code on tablet the screen of Google Play goes in landscape mode, which in turn causes exception.

Thanks @Nikolay Elenkov for static inner class idea.

OTHER TIPS

Show relevant code from CalendarUIMain$InAppProductsDialog. Is InAppProductsDialog a static inner class? Does it have an accessible default constructor?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top