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.
Show relevant code from CalendarUIMain$InAppProductsDialog. Is InAppProductsDialog a static inner class? Does it have an accessible default constructor?
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.
Related
Hi guys I'm totally new to programming and need some help, and I hope one of you lovely people can help me:
When I run the AVD emulator I then click my button and I get an error saying "Unfortunately, Eventrecorder has stopped".
This is what my LogCat says:
04-11 22:08:10.415: D/dalvikvm(544): Not late-enabling CheckJNI (already on)
04-11 22:08:10.955: D/(544): Created
04-11 22:08:11.445: D/gralloc_goldfish(544): Emulator without GPU emulation detected.
04-11 22:08:19.615: D/AndroidRuntime(544): Shutting down VM
04-11 22:08:19.615: W/dalvikvm(544): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
04-11 22:08:19.655: E/AndroidRuntime(544): FATAL EXCEPTION: main
04-11 22:08:19.655: E/AndroidRuntime(544): java.lang.IllegalStateException: Could not execute method of the activity
04-11 22:08:19.655: E/AndroidRuntime(544): at android.view.View$1.onClick(View.java:3039)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.view.View.performClick(View.java:3480)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.view.View$PerformClick.run(View.java:13983)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.os.Handler.handleCallback(Handler.java:605)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.os.Handler.dispatchMessage(Handler.java:92)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.os.Looper.loop(Looper.java:137)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.app.ActivityThread.main(ActivityThread.java:4340)
04-11 22:08:19.655: E/AndroidRuntime(544): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 22:08:19.655: E/AndroidRuntime(544): at java.lang.reflect.Method.invoke(Method.java:511)
04-11 22:08:19.655: E/AndroidRuntime(544): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-11 22:08:19.655: E/AndroidRuntime(544): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-11 22:08:19.655: E/AndroidRuntime(544): at dalvik.system.NativeStart.main(Native Method)
04-11 22:08:19.655: E/AndroidRuntime(544): Caused by: java.lang.reflect.InvocationTargetException
04-11 22:08:19.655: E/AndroidRuntime(544): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 22:08:19.655: E/AndroidRuntime(544): at java.lang.reflect.Method.invoke(Method.java:511)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.view.View$1.onClick(View.java:3034)
04-11 22:08:19.655: E/AndroidRuntime(544): ... 11 more
04-11 22:08:19.655: E/AndroidRuntime(544): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.eventrecorder/com.example.eventrecorder.NewEvent}; have you declared this activity in your AndroidManifest.xml?
04-11 22:08:19.655: E/AndroidRuntime(544): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.app.Activity.startActivityForResult(Activity.java:3190)
04-11 22:08:19.655: E/AndroidRuntime(544): at android.app.Activity.startActivity(Activity.java:3297)
04-11 22:08:19.655: E/AndroidRuntime(544): at com.example.eventrecorder.MainActivity.showAddForm(MainActivity.java:45)
04-11 22:08:19.655: E/AndroidRuntime(544): ... 14 more
Your AndroidManifest.xml file does not have an <activity> element with an android:name attribute of com.example.eventrecorder.NewEvent.
If NewEvent is supposed to be an activity, you need to add the associated <activity> element.
If NewEvent is not supposed to be an activity, go to line 45 of MainActivity, in your showAddForm() method, and fix the Intent that you are using with startActivity() to be one that points to an actual activity.
I have putted my activities in childview and now I cannot display dialogs from my activities and adapters. In my logCat i'm getting
04-11 12:39:59.823: E/AndroidRuntime(12831): FATAL EXCEPTION: main
04-11 12:39:59.823: E/AndroidRuntime(12831): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord#41971f18 is not valid; is your activity running?
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.ViewRootImpl.setView(ViewRootImpl.java:513)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:301)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.Window$LocalWindowManager.addView(Window.java:537)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.app.Dialog.show(Dialog.java:278)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.app.AlertDialog$Builder.show(AlertDialog.java:932)
04-11 12:39:59.823: E/AndroidRuntime(12831): at com.myapp.functions.DownloadsDetailsAdapter$1$2.run(DownloadsDetailsAdapter.java:148)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.app.Activity.runOnUiThread(Activity.java:4170)
04-11 12:39:59.823: E/AndroidRuntime(12831): at com.myapp.functions.DownloadsDetailsAdapter$1.onClick(DownloadsDetailsAdapter.java:139)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.View.performClick(View.java:3511)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.view.View$PerformClick.run(View.java:14105)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.os.Handler.handleCallback(Handler.java:605)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.os.Handler.dispatchMessage(Handler.java:92)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.os.Looper.loop(Looper.java:137)
04-11 12:39:59.823: E/AndroidRuntime(12831): at android.app.ActivityThread.main(ActivityThread.java:4440)
04-11 12:39:59.823: E/AndroidRuntime(12831): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 12:39:59.823: E/AndroidRuntime(12831): at java.lang.reflect.Method.invoke(Method.java:511)
04-11 12:39:59.823: E/AndroidRuntime(12831): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
04-11 12:39:59.823: E/AndroidRuntime(12831): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
04-11 12:39:59.823: E/AndroidRuntime(12831): at dalvik.system.NativeStart.main(Native Method)
And here is an example of how I'm trying to display dialogs.
AlertDialog.Builder builder = new AlertDialog.Builder(
activity);
builder.setMessage(R.string.are_you_sure)
.setPositiveButton(R.string.yes,
dialogClickListener)
.setNegativeButton(R.string.no, dialogClickListener)
.show();
Note: this code was working before I make the change. I thing I should run this in new runnable but if should I have to do that, can anybody tell me how can I do that?
I also faced the same problem. I have used tab bar for this. Just use getParent() instead of youractivity.this.
I hope this will help.
the activity object must be the activity that is currently shown on the screen.
If it's something that was already paused or not build show yet it will give this error.
see here the answer for ActivityGroup.
For child activity of a ActivityGroup, we cannot be sure that it always exist and live when we use the Context in the child activity such as PrompDialog.
For example:
mPromptDialog = new LoginPromptDialog(this);//this is used as Context
//But when we use this context it may be destroyed.
//So this is the parent instance
mPromptDialog = new LoginPromptDialog(this.getParent());
preference:
http://www.cnblogs.com/kaima/archive/2011/08/04/2127813.html
My Android app seemed to have been working fine till i did a git reset on it. Now it keep crashing and says that a library I am using is not present.
This is the crash log I get
04-11 16:31:31.230: E/AndroidRuntime(9206): FATAL EXCEPTION: main
04-11 16:31:31.230: E/AndroidRuntime(9206): java.lang.NoClassDefFoundError: de.greenrobot.event.EventBus$3
04-11 16:31:31.230: E/AndroidRuntime(9206): at de.greenrobot.event.EventBus.postToSubscription(EventBus.java:413)
04-11 16:31:31.230: E/AndroidRuntime(9206): at de.greenrobot.event.EventBus.postSingleEvent(EventBus.java:399)
04-11 16:31:31.230: E/AndroidRuntime(9206): at de.greenrobot.event.EventBus.post(EventBus.java:326)
04-11 16:31:31.230: E/AndroidRuntime(9206): at com.cobboc.eashmartdemo.Session$5.onError(Session.java:362)
04-11 16:31:31.230: E/AndroidRuntime(9206): at com.cobboc.eashmartdemo.Session$5.onSuccess(Session.java:355)
04-11 16:31:31.230: E/AndroidRuntime(9206): at com.cobboc.eashmartdemo.Session$3.run(Session.java:238)
04-11 16:31:31.230: E/AndroidRuntime(9206): at android.os.Handler.handleCallback(Handler.java:615)
04-11 16:31:31.230: E/AndroidRuntime(9206): at android.os.Handler.dispatchMessage(Handler.java:92)
04-11 16:31:31.230: E/AndroidRuntime(9206): at android.os.Looper.loop(Looper.java:137)
04-11 16:31:31.230: E/AndroidRuntime(9206): at android.app.ActivityThread.main(ActivityThread.java:4931)
04-11 16:31:31.230: E/AndroidRuntime(9206): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 16:31:31.230: E/AndroidRuntime(9206): at java.lang.reflect.Method.invoke(Method.java:511)
04-11 16:31:31.230: E/AndroidRuntime(9206): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
04-11 16:31:31.230: E/AndroidRuntime(9206): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
04-11 16:31:31.230: E/AndroidRuntime(9206): at dalvik.system.NativeStart.main(Native Method)
I have tried restoring the last known working copy too. Could it be an issue with my machine?
You need to make sure that the library is in the app libs directory
Look in eclipse - make sure you have a libs directory and that the library is in it
It turns out that I was using new relic to build the app, and when I used eclipse to build it, the libraries failed.
I have an app on the market using admob and now I would like to update my app. When I test this new version I get a Fatal Exception caused by the admob.
04-06 15:09:04.123: E/AndroidRuntime(409): Caused by: android.view.InflateException: Binary XML file line #51: Error inflating class com.google.ads.AdView
04-06 15:09:04.123: E/AndroidRuntime(409): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader[/data/app/com.kmbdev.purrkitty-2.apk]
Here is the xml file with line #51:
<com.google.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#id/bottom_border"
android:layout_toLeftOf="#id/right_border"
ads:adSize="BANNER"
ads:adUnitId="my id"
ads:loadAdOnCreate="true" />
I have not made any major changes from the original app that is published. I have only added a splash screen and some language strings files and changed the version to 1.2, the published app is version 1.1. I was wondering why this app will no longer run.
I have tried again, here is the log:
04-11 12:13:21.474: D/AndroidRuntime(282): Shutting down VM
04-11 12:13:21.474: W/dalvikvm(282): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-11 12:13:21.644: E/AndroidRuntime(282): FATAL EXCEPTION: main
04-11 12:13:21.644: E/AndroidRuntime(282): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kmbdev.purrkitty/com.kmbdev.purrkitty.Cat1}: android.view.InflateException: Binary XML file line #52: Error inflating class com.google.ads.AdView
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.os.Looper.loop(Looper.java:123)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-11 12:13:21.644: E/AndroidRuntime(282): at dalvik.system.NativeStart.main(Native Method)
04-11 12:13:21.644: E/AndroidRuntime(282): Caused by: android.view.InflateException: Binary XML file line #52: Error inflating class com.google.ads.AdView
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.Activity.setContentView(Activity.java:1647)
04-11 12:13:21.644: E/AndroidRuntime(282): at com.kmbdev.purrkitty.Cat1.onCreate(Cat1.java:25)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-11 12:13:21.644: E/AndroidRuntime(282): ... 11 more
04-11 12:13:21.644: E/AndroidRuntime(282): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader[/data/app/com.kmbdev.purrkitty-2.apk]
04-11 12:13:21.644: E/AndroidRuntime(282): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-11 12:13:21.644: E/AndroidRuntime(282): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
04-11 12:13:21.644: E/AndroidRuntime(282): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
04-11 12:13:21.644: E/AndroidRuntime(282): ... 20 more
I've got the same issue and wasted more than 3 hours to figure it out. Finally, I found the way to make it work.
change sdk name from GoogleAdMobAdsSdk-6.0.0.jar to GoogleAdMobAdsSdk.jar
create "libs" folder under project, copy above sdk in the folder and link the library using Add External JARs.
if not worked, change import class name from com.google.ads.* to com.google.ads.AdRequest, comp.google.ads.AdView, and so on.
Are you sure the manifest has all the tags? (Those of admob). Also in the XML, you need to have a addl tag for xmlns right? Did you specify it?
Clean your project, and if you don't have activated the automatic build in Eclipse, make a manual build. It will work.
To fix that problem you just have to link the sdk .jar file in two ways. First, to add it to the libs folder (if you don't have one, create it) and then, right-click on .jar file, go to Build Path->Add to Build Path... Three days to that conclusion.
I fixed it by renaming the folder in which the jar file is kept from /lib to /libs.
So I am modifying the Cube live wallpaper example. I have a class that extends PreferenceActivity, and I added the Activity in my manifest file. I keep getting ActivityNotFoundExceptions.
Here is my preference class :
package com.p.t.wallpapers.mywallpaper;
import com.p.t.wallpapers.mywallpaper.R;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class MySettingsActivity extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener {
#Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
getPreferenceManager().setSharedPreferencesName(
ParticleCandy.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.settings);
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(
this);
}
#Override
protected void onResume() {
super.onResume();
}
#Override
protected void onDestroy() {
getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(
this);
super.onDestroy();
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
}
}
And here is my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.p.t.wallpapers.mywallpaper"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<service
android:label="#string/app_name"
android:name=".MyWallpaper"
android:permission="android.permission.BIND_WALLPAPER" >
<intent-filter>
<action
android:name="android.service.wallpaper.WallpaperService">
</action>
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/wallpaper_info" />
</service>
<activity
android:label="#string/settings_title"
android:name=".MySettingsActivity"
android:theme="#android:style/Theme.Light.WallpaperSettings"
android:exported="true">
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:name="android.software.live_wallpaper" />
</manifest>
Any ideas why my preferences activity doesn't get read in from the manifest? The wallpaper service, MyWallpaper shows up just fine, but DDMS keeps telling me the activity MySettingsActivity doesn't exit.
Here is output from logcat
04-11 00:22:19.617: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) }
04-11 00:22:21.796: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 2111 ms (total 2111 ms)
04-11 00:22:25.667: DEBUG/dalvikvm(375): GC freed 4745 objects / 316576 bytes in 192ms
04-11 00:22:25.727: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.p.t.wallpapers.mywallpaper/MySettingsActivity (has extras) }
04-11 00:22:25.757: DEBUG/AndroidRuntime(375): Shutting down VM
04-11 00:22:25.768: WARN/dalvikvm(375): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-11 00:22:25.787: ERROR/AndroidRuntime(375): Uncaught handler: thread main exiting due to uncaught exception
04-11 00:22:25.847: ERROR/AndroidRuntime(375): java.lang.IllegalStateException: Could not execute method of the activity
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View$1.onClick(View.java:2031)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.performClick(View.java:2364)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.onTouchEvent(View.java:4179)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.widget.TextView.onTouchEvent(TextView.java:6540)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View.dispatchTouchEvent(View.java:3709)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.wallpaper.livepicker.LiveWallpaperPreview.dispatchTouchEvent(LiveWallpaperPreview.java:199)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.os.Looper.loop(Looper.java:123)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at dalvik.system.NativeStart.main(Native Method)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): Caused by: java.lang.reflect.InvocationTargetException
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.view.View$1.onClick(View.java:2026)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): ... 20 more
04-11 00:22:25.847: ERROR/AndroidRuntime(375): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.p.t.wallpapers.mywallpaper/MySettingsActivity}; have you declared this activity in your AndroidManifest.xml?
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Activity.startActivityForResult(Activity.java:2749)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): at android.app.Activity.startActivity(Activity.java:2855)
04-11 00:22:25.847: ERROR/AndroidRuntime(375): ... 24 more
04-11 00:22:25.917: INFO/Process(57): Sending signal. PID: 375 SIG: 3
04-11 00:22:25.917: INFO/dalvikvm(375): threadid=7: reacting to signal 3
04-11 00:22:25.988: ERROR/ActivityThread(57): Failed to find provider info for android.server.checkin
04-11 00:22:26.012: ERROR/Checkin(57): Error reporting crash: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/crashes
04-11 00:22:26.044: INFO/dalvikvm(375): Wrote stack trace to '/data/anr/traces.txt'
04-11 00:22:29.307: INFO/Process(375): Sending signal. PID: 375 SIG: 9
04-11 00:22:29.516: INFO/ActivityManager(57): Process android.process.acore (pid 375) has died.
04-11 00:22:29.516: INFO/WindowManager(57): WIN DEATH: Window{44dd50d8 Media:com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 00:22:29.576: INFO/WindowManager(57): WIN DEATH: Window{44d660f8 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperListActivity paused=false}
04-11 00:22:29.586: INFO/WindowManager(57): WIN DEATH: Window{44dbe2f0 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 00:22:29.876: INFO/ActivityManager(57): Start proc android.process.acore for activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: pid=421 uid=10022 gids={}
04-11 00:22:30.687: DEBUG/ddm-heap(421): Got feature list request
04-11 00:22:30.957: INFO/UsageStats(57): Unexpected resume of com.android.wallpaper.livepicker while already resumed in com.android.wallpaper.livepicker
04-11 00:22:31.756: WARN/ResourceType(421): getEntry failing because entryIndex 2 is beyond type entryCount 2
04-11 00:22:31.768: WARN/ResourceType(421): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001
04-11 00:22:32.758: WARN/InputManagerService(57): Got RemoteException sending setActive(false) notification to pid 375 uid 10022
04-11 00:22:33.137: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 3430 ms (total 3430 ms)
04-11 00:22:33.528: ERROR/gralloc(57): [unregister] handle 0x467ae8 still locked (state=40000001)
04-11 00:22:38.368: DEBUG/dalvikvm(364): GC freed 611 objects / 51656 bytes in 179ms
Updated logcat
04-11 01:10:52.976: INFO/ActivityManager(57): Starting activity: Intent { act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras) }
04-11 01:10:53.668: WARN/InputManagerService(57): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#44db02f8
04-11 01:10:54.587: INFO/ActivityManager(57): Displayed activity android/com.android.internal.app.ChooserActivity: 1140 ms (total 17760 ms)
04-11 01:10:56.458: INFO/ActivityManager(57): Starting activity: Intent { act=android.intent.action.SET_WALLPAPER flg=0x3000000 cmp=com.android.wallpaper.livepicker/.LiveWallpaperListActivity }
04-11 01:10:57.466: DEBUG/dalvikvm(1622): GC freed 1487 objects / 106648 bytes in 167ms
04-11 01:10:57.556: WARN/ResourceType(1622): getEntry failing because entryIndex 2 is beyond type entryCount 2
04-11 01:10:57.587: WARN/ResourceType(1622): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001
04-11 01:10:58.516: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 1625 ms (total 1625 ms)
04-11 01:11:00.717: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.android.wallpaper.livepicker/.LiveWallpaperPreview (has extras) }
04-11 01:11:02.948: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperPreview: 2187 ms (total 2187 ms)
04-11 01:11:11.538: INFO/ActivityManager(57): Starting activity: Intent { cmp=com.p.t.wallpapers.mywallpaper/MySettingsActivity (has extras) }
04-11 01:11:11.577: DEBUG/AndroidRuntime(1622): Shutting down VM
04-11 01:11:11.587: WARN/dalvikvm(1622): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-11 01:11:11.597: ERROR/AndroidRuntime(1622): Uncaught handler: thread main exiting due to uncaught exception
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): java.lang.IllegalStateException: Could not execute method of the activity
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View$1.onClick(View.java:2031)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.performClick(View.java:2364)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.onTouchEvent(View.java:4179)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.widget.TextView.onTouchEvent(TextView.java:6540)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View.dispatchTouchEvent(View.java:3709)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.wallpaper.livepicker.LiveWallpaperPreview.dispatchTouchEvent(LiveWallpaperPreview.java:199)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.os.Looper.loop(Looper.java:123)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at dalvik.system.NativeStart.main(Native Method)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): Caused by: java.lang.reflect.InvocationTargetException
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:113)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invokeNative(Native Method)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at java.lang.reflect.Method.invoke(Method.java:521)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.view.View$1.onClick(View.java:2026)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): ... 20 more
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.p.t.wallpapers.mywallpaper/MySettingsActivity}; have you declared this activity in your AndroidManifest.xml?
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Activity.startActivityForResult(Activity.java:2749)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): at android.app.Activity.startActivity(Activity.java:2855)
04-11 01:11:11.667: ERROR/AndroidRuntime(1622): ... 24 more
04-11 01:11:11.748: INFO/Process(57): Sending signal. PID: 1622 SIG: 3
04-11 01:11:11.748: INFO/dalvikvm(1622): threadid=7: reacting to signal 3
04-11 01:11:11.827: INFO/dalvikvm(1622): Wrote stack trace to '/data/anr/traces.txt'
04-11 01:11:11.858: ERROR/ActivityThread(57): Failed to find provider info for android.server.checkin
04-11 01:11:11.877: ERROR/Checkin(57): Error reporting crash: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/crashes
04-11 01:11:13.788: DEBUG/dalvikvm(101): GC freed 3389 objects / 203632 bytes in 2805ms
04-11 01:11:16.787: INFO/Process(1622): Sending signal. PID: 1622 SIG: 9
04-11 01:11:17.037: INFO/ActivityManager(57): Process android.process.acore (pid 1622) has died.
04-11 01:11:17.046: INFO/WindowManager(57): WIN DEATH: Window{44db47b0 Media:com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 01:11:17.107: INFO/WindowManager(57): WIN DEATH: Window{44db7138 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperListActivity paused=false}
04-11 01:11:17.208: INFO/WindowManager(57): WIN DEATH: Window{44da6860 com.android.wallpaper.livepicker/com.android.wallpaper.livepicker.LiveWallpaperPreview paused=false}
04-11 01:11:17.426: INFO/ActivityManager(57): Start proc android.process.acore for activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: pid=1647 uid=10022 gids={}
04-11 01:11:18.266: DEBUG/dalvikvm(30): GC freed 222 objects / 8512 bytes in 799ms
04-11 01:11:18.577: DEBUG/ddm-heap(1647): Got feature list request
04-11 01:11:18.686: DEBUG/dalvikvm(30): GC freed 2 objects / 56 bytes in 406ms
04-11 01:11:19.037: INFO/UsageStats(57): Unexpected resume of com.android.wallpaper.livepicker while already resumed in com.android.wallpaper.livepicker
04-11 01:11:19.367: DEBUG/dalvikvm(30): GC freed 2 objects / 56 bytes in 652ms
04-11 01:11:19.827: WARN/ResourceType(1647): getEntry failing because entryIndex 2 is beyond type entryCount 2
04-11 01:11:19.837: WARN/ResourceType(1647): Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001
04-11 01:11:20.378: WARN/InputManagerService(57): Got RemoteException sending setActive(false) notification to pid 1622 uid 10022
04-11 01:11:20.737: INFO/ActivityManager(57): Displayed activity com.android.wallpaper.livepicker/.LiveWallpaperListActivity: 3496 ms (total 3496 ms)
04-11 01:11:21.117: ERROR/gralloc(57): [unregister] handle 0x448168 still locked (state=40000001)
04-11 01:23:24.496: DEBUG/dalvikvm(98): GC freed 12398 objects / 575024 bytes in 213ms
Figured it out. It was the wallpaper xml that is referenced in the manifest, under the meta data tag in the service tag. Basically, that xml has
<wallpaper
xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="MySettingsActivity"/>
Notice the "MySettingsActivity" there? Yeah, since this is a separate file from the manifest, it doesn't automatically have a package it starts searching class names from. So all I had to do was put the full package path, like so
<wallpaper
xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="com.p.t.wallpapers.mywallpaper.MySettingsActivity" />
and voila! My preference screen pops up now when I hit the Settings... button, instead of force crashing. Oh man, facepalm!
I would add a leading dot on your android:name attributes (e.g., android:name=".MySettingsActivity") or fully-qualify their package (e.g., android:name="com.p.t.wallpapers.mywallpaper.MySettingsActivity").
Also, I would get rid of the import com.p.t.wallpapers.mywallpaper.R, as it should not be needed (you're already in that package) and might be masking a package problem.
If neither of those help, please update your question to explain where, exactly, you are getting the ActivityNotFoundExceptions.
First answer ie adding
is correct. this should be added into the xml file which describes the tag.
if you want to get rid of the Settings crash delete the
android:settingActivity tag from the same file.
n njy the beauty of live wallpaper..
cheers,
Shivam Sabhlok, India
Make sure your MySettingsActivity is in the com.p.t.wallpapers.mywallpaper package, otherwise you have to specify the absolute package name.