android looking for onClick handler in ContextThemeWrapper - android

In 4.0.3 if i am using a base theme in my manifest, it appears to Android is trying to resolve my onClick methods of my menu's in the android.view.ContextThemeWrapper class. It resolves fine in 4.03+. I can take out the style in the manifest and everything works and gets resolved. How can I get the onClick methods to resolve correctly while using a theme?
I'm inflating the menu in the onCreateOptionsMenue() method and that's where the exception is getting thrown.
android.view.InflateException: Couldn't resolve menu item onClick
handler createNewDoc in class android.view.ContextThemeWrapper
at android.view.MenuInflater$InflatedOnMenuItemClickListener.(MenuInflater.java:202)
at android.view.MenuInflater$MenuState.setItem(MenuInflater.java:402)
at android.view.MenuInflater$MenuState.addItem(MenuInflater.java:436)
at android.view.MenuInflater.parseMenu(MenuInflater.java:173)
at android.view.MenuInflater.inflate(MenuInflater.java:95)
at com.c2crm.c2crm.ListActivity.onCreateOptionsMenu(ListActivity.java:326)
at android.app.Activity.onCreatePanelMenu(Activity.java:2444)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:388)
at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:739)
at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:2833)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoSuchMethodException: createNewDoc [interface android.view.MenuItem]
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getMethod(Class.java:915)
at android.view.MenuInflater$InflatedOnMenuItemClickListener.(MenuInflater.java:200)

Related

Android Studio seems to build old version of project

I am wondering if this is some bug in Android Studio or I am simply lack od knowladge but straight to the point.
I am writing simple client-server via bluetooth app on android. At some point I encoured following problem:
07-11 18:59:20.553 10364-10364/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not find a method parujUrzadzenia(View) in the activity class com.example.pc.klient_serwerbluetooth.Klient for onClick handler on view class android.widget.Button with id 'button6'
at android.view.View$1.onClick(View.java:3775)
at android.view.View.performClick(View.java:4421)
at android.view.View$PerformClick.run(View.java:18190)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:5279)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoSuchMethodException: parujUrzadzenia [class android.view.View]
at java.lang.Class.getConstructorOrMethod(Class.java:460)
at java.lang.Class.getMethod(Class.java:915)
at android.view.View$1.onClick(View.java:3768)
at android.view.View.performClick(View.java:4421)
at android.view.View$PerformClick.run(View.java:18190)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:175)
at android.app.ActivityThread.main(ActivityThread.java:5279)
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:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
07-11 19:34:00.498 449-522/? E/ActivityManager﹕ The package com.example.pc.klient_serwerbluetooth is not found. Failure starting process com.example.pc.klient_serwerbluetooth
For what I understand Android Studio can't find method parujUrzadzenia(View) that is marked in button6's properties as onClick method...the funny thing is i deleted this button in my way of solving this problem.
I can't post picture of my project due to low reputation but like I said. I've deleted the reference to method from .xml and method from .java file and got an error saying that there is no required onClick method. So I deleted this whole button and still got this error.
Any advices will be greatly appreciated.

ClassNotFoundException inside Google-Analytics from inside Google-Play-Services

I got a strange crash in my app and the new Analytics from inside Google-Play-Services - this bug seems to be really rare, but I really would like to know what is going on there.
java.lang.RuntimeException: Unable to instantiate receiver com.google.analytics.tracking.android.AnalyticsReceiver: java.lang.ClassNotFoundException: Didn't find class "com.google.analytics.tracking.android.AnalyticsReceiver" on path: /mnt/asec/org.ligi.passandroid-1/pkg.apk
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2375)
at android.app.ActivityThread.access$1500(ActivityThread.java:145)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5095)
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:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.analytics.tracking.android.AnalyticsReceiver" on path: /mnt/asec/org.ligi.passandroid-1/pkg.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2370)
... 10 more

GoogleMap Support Fragment error

I have a project that uses the GoogleMaps API, and the support library for Fragments. I have a working map in one activity already, so I know that the API and library are all set up right. I am trying to add a map in a fragment as part of a new activity.
The activity extends an android.support.v4.app.FragmentActivity, and the xml file contains:
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="250dp"
android:name="com.google.android.gms.maps.SupportMapFragment" />
But when I run I get the error:
01-20 11:58:31.535: ERROR/AndroidRuntime(5389): FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
at android.app.Activity.setContentView(Activity.java:1835)
at com.yedidyak.gpsalarm.AddAlarm.onCreate(AddAlarm.java:19)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
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:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
All the information I can find about this error is about not having the google-play-lib properly installed both as a jar and an imported module, but I have that done - and a working map in another activity.
Any ideas?
You have to reference google play services library instead of adding jar and map_attrs.xml (and other files, like strings.xml) to your project.
If you do, you also might have deleted res/values/map_attrs.xml by accident.

Unable to start activity On Sony Experia S

I recently published my app to the android play store.
I see a whole lot of error logs from one device in particular. It's a Sony Experia S.
I contacted the owner of the device, and he says he has the latest version of android ( don't know the exact version ).
I heard from a colluege developer that there are more known issieus with sony devices and android.
This app in particular works with fragments... Don't know if this is the problem but... Maybe the sony's don't know how to cope with them.
Does anyone have an idea what this problem could be.
Error logs looks like:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.crosscommunications.kvodeventer/com.crosscommunications.kvodeventer.KVODeventerActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.crosscommunications.kvodeventer/com.crosscommunications.kvodeventer.TabControllerHome}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4511)
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:980)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.crosscommunications.kvodeventer/com.crosscommunications.kvodeventer.TabControllerHome}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
at android.app.ActivityThread.startActivityNow(ActivityThread.java:1808)
at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:682)
at android.widget.TabHost.setCurrentTab(TabHost.java:346)
at android.widget.TabHost.addTab(TabHost.java:236)
at com.crosscommunications.kvodeventer.KVODeventerActivity.onCreate(KVODeventerActivity.java:27)
at android.app.Activity.performCreate(Activity.java:4470)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
... 11 more
Caused by: java.lang.NullPointerException
at com.crosscommunications.kvodeventer.KVOHome.onCreateView(KVOHome.java:52)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:870)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:505)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1136)
at android.app.Activity.performStart(Activity.java:4480)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1940)
... 21 more
Thnx
Just put a null check to your code:
KVOHome Acvitivity, line 52.
at com.crosscommunications.kvodeventer.KVOHome.onCreateView(KVOHome.java:52)
Most probably, Sony sends a null value to your code.

Android AVD Bluetooth Activation Problem

By default Bluetooth is not enabled in Android. But when I go to Setting > Wireless & network and I click on Bluetooth Settings I get the following error:
04-04 11:42:22.492:
WARN/dalvikvm(747): threadid=1: thread
exiting with uncaught exception
(group=0x40014760) FATAL EXCEPTION:
main android.view.InflateException:
Binary XML file line #29: Error
inflating class
java.lang.reflect.Constructor
at android.preference.GenericInflater.createItem(GenericInflater.java:397)
at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:430)
at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
at android.preference.GenericInflater.inflate(GenericInflater.java:326)
at android.preference.GenericInflater.inflate(GenericInflater.java:263)
at android.preference.
PreferenceManager.inflateFromResource(PreferenceManager.java:269)
at android.preference.PreferenceFragment.addPreferencesFromResource(PreferenceFragment.java:271)
at com.android.settings.bluetooth.BluetoothSettings.addPreferencesForActivity(BluetoothSettings.java:53)
at com.android.settings.bluetooth.DeviceListPreferenceFragment.onActivityCreated(DeviceListPreferenceFragment.java:93)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:749)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:921)
at android.app.BackStackRecord.run(BackStackRecord.java:578)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1221)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:375)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:126)
at android.app.ActivityThread.main(ActivityThread.java:3997)
at java.lang.reflect.Method.invokeNative(Native
Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native
Method) Caused by:
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native
Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.preference.GenericInflater.createItem(GenericInflater.java:383)
... 22 more Caused by: java.lang.NullPointerException
at com.android.settings.bluetooth.BluetoothNamePreference.setSummaryToName(BluetoothNamePreference.java:101)
at com.android.settings.bluetooth.BluetoothNamePreference.(BluetoothNamePreference.java:66)
... 25 more
What I'm missing?
Thanks.
You cant setup bluetooth on ANdroid AVD. Please check this link for emulator limitations:
http://developer.android.com/guide/developing/devices/emulator.html

Categories

Resources