Android Google Maps error - android

In my app I want to open a MapActivity from a button click. But on the button click,its showing a class not found error.
Im posting my error log also,so that it will be easy to correct me...
06-11 17:16:53.854: WARN/dalvikvm(890): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): FATAL EXCEPTION: main
06-11 17:16:53.865: ERROR/AndroidRuntime(890): java.lang.NoClassDefFoundError: com.iqmobi.SampleMapPage
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at com.iqmobi.Login.onClick(Login.java:61)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at android.view.View.performClick(View.java:2408)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at android.view.View$PerformClick.run(View.java:8816)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at android.os.Handler.handleCallback(Handler.java:587)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at android.os.Handler.dispatchMessage(Handler.java:92)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at android.os.Looper.loop(Looper.java:123)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at java.lang.reflect.Method.invokeNative(Native Method)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at java.lang.reflect.Method.invoke(Method.java:521)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-11 17:16:53.865: ERROR/AndroidRuntime(890): at dalvik.system.NativeStart.main(Native Method)
06-11 17:16:53.874: WARN/ActivityManager(60): Force finishing activity com.iqmobi/.Login
06-11 17:16:54.384: WARN/ActivityManager(60): Activity pause timeout for HistoryRecord{4505c5d8 com.iqmobi/.Login}
The code which is moving to the MapActivity is
Intent successIntent=new Intent(Login.this,SampleMapPage.class);
startActivity(successIntent);
An additional information i checked,that,when i Toast instead of startActivity in my above code section,its working....Its something related to the button click,i think.....please help

Add <uses-library android:name="com.google.android.maps" /> to your manifest and make sure you're using the Google API version of Android. Your manifest should look something like the one in this question.

Write Below Code line into your manifest file's <application> tag.
<uses-library android:name="com.google.android.maps" />

Related

Having issues integrating Scandit SDK into my app

Decided to use Scandit SDK to get the barcode scanning feature in my app. Unfortunately, since I'm relatively new to Android development and Java in general I've run into a few issues that I can't seem to work out. The demo that Scandit provided doesn't give any errors(runs fine) but crashes when I try to start it up (pressing a button from one activity is meant to start it up). I've tried reading the logcat and googling a solution to the problems but I'm not getting the right solutions. Does anyone have an idea of what I'm doing wrong?
Logcat is provided below:
10-08 23:30:00.807 21563-21563/com.kwesimbia.management D/AndroidRuntime? Shutting down VM
10-08 23:30:00.807 21563-21563/com.kwesimbia.management W/dalvikvm? threadid=1: thread exiting with uncaught exception (group=0x40aa4228)
10-08 23:30:00.817 21563-21563/com.kwesimbia.management E/AndroidRuntime? FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3082)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
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.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3077)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
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.NoClassDefFoundError: com.kwesimbia.management.ScanditSDKDemoSimple
at com.kwesimbia.management.Activity_D.initiateCodeScan(Activity_D.java:63)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3077)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
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)
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger? App crashed!
Process: com.kwesimbia.management
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger? App crashed!
Package: com.kwesimbia.management v1 (1.0)
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger?
Application Label: firstapp
10-08 23:30:00.827 32726-587/? W/ActivityManager?
Force finishing activity com.kwesimbia.management/.Activity_D
I came across this problem as well, my solution was to extract the library files and put them as their files in the lib folder
The library basically isn't being exported with it
EDIT
So I checked out my project, basically I did these things:
In the libs folder I have a new folder called armeabi and inside that I have libscanditsdk-android-3.3.1.so
Then in my build path I have also referenced the jar file that they provide:
<classpathentry exported="true" kind="lib" path="C:/GIT/Android/FwayScannerProject/FwayScanner/libs/scanditsdk-barcodepicker-android-3.3.1.jar"/>

Selecting an item in ListFragment list programmatically

I've made my Android app tablet optimized and I followed the tutorial here:
Everything is great, but I am trying to select an item (say, the 1st item) with a button in the ActionBar.
I tried this answer to use performItemClick but on I've got error reports of java.lang.IllegalStateException
in android.support.v4.app.ListFragment.ensureList, java.lang.IllegalStateException: Content view not yet created, and java.lang.NullPointerException
in android.content.ComponentName.<init>
I've tried checking if the ListView is null and still get the error reports on the Play Store. How do I properly select an item in my list programmatically?
Update to add logcat and the code is virtually identical to the tutorials in the links:
Logcat A:
java.lang.IllegalStateException: Content view not yet created
at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:69)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:298)
at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2606)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1045)
at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:592)
at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:149)
at android.view.View.performClick(View.java:4222)
at android.view.View$PerformClick.run(View.java:17273)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
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:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
Logcat B:
java.lang.NullPointerException
at android.content.ComponentName.<init>(ComponentName.java:75)
at android.content.Intent.<init>(Intent.java:2874)
at com.ccwilcox.meteorshower.MeteorList.showMeteorDetails(MeteorList.java:86)
at com.ccwilcox.meteorshower.MeteorList.onListItemClick(MeteorList.java:62)
at android.support.v4.app.ListFragment$2.onItemClick(ListFragment.java:58)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3701)
at com.ccwilcox.meteorshower.MainActivity.viewUpcomingEvent(MainActivity.java:648)
at com.ccwilcox.meteorshower.MainActivity.onOptionsItemSelected(MainActivity.java:534)
at android.app.Activity.onMenuItemSelected(Activity.java:2205)
at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:361)
at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:779)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:861)
at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
at android.view.View$PerformClick.run(View.java:9152)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Update 2
And here is the code that is causing the problem:
if (mListFragment.listView != null) {
mListFragment.listView.performItemClick(mListFragment.listView.getAdapter().getView(position, null, null), position, mListFragment.listView.getAdapter().getItemId(position));
}

An app that uses Google API v2 crashes whenever the map tries to load. I've tried every other solution on this site, I give up

I believe my problem lies in the fact that some of the jar files are not in the "dependency" folder. Not sure how to fix this, I have removed all the Google-play-services stuff and re-added it many times.
Here is the album of images with my package explorer, map.xml, map.java, and manifest, all labelled. (Since I can't post more than 2 links, or any images)
My logcat (using my android device [v4.0.4], not an emulator):
06-11 11:30:57.858: E/AndroidRuntime(16661): FATAL EXCEPTION: main
06-11 11:30:57.858: E/AndroidRuntime(16661): java.lang.RuntimeException: Unable to
start activity ComponentInfo{com.example.playground/com.example.playground.Map}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.os.Handler.dispatchMessage(Handler.java:99)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.os.Looper.loop(Looper.java:137)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.app.ActivityThread.main(ActivityThread.java:4424)
06-11 11:30:57.858: E/AndroidRuntime(16661): at java.lang.reflect.Method.invokeNative(Native Method)
06-11 11:30:57.858: E/AndroidRuntime(16661): at java.lang.reflect.Method.invoke(Method.java:511)
06-11 11:30:57.858: E/AndroidRuntime(16661): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:812)
06-11 11:30:57.858: E/AndroidRuntime(16661): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:579)
06-11 11:30:57.858: E/AndroidRuntime(16661): at dalvik.system.NativeStart.main(Native Method)
06-11 11:30:57.858: E/AndroidRuntime(16661): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-11 11:30:57.858: E/AndroidRuntime(16661): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.app.Activity.setContentView(Activity.java:1835)
06-11 11:30:57.858: E/AndroidRuntime(16661): at com.example.playground.Map.onCreate(Map.java:12)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.app.Activity.performCreate(Activity.java:4465)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
06-11 11:30:57.858: E/AndroidRuntime(16661): ... 11 more
06-11 11:30:57.858: E/AndroidRuntime(16661): Caused by: java.lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
06-11 11:30:57.858: E/AndroidRuntime(16661): at maps.aj.ay.a(Unknown Source)
06-11 11:30:57.858: E/AndroidRuntime(16661): at maps.aj.ay.a(Unknown Source)
06-11 11:30:57.858: E/AndroidRuntime(16661): at maps.aj.al.a(Unknown Source)
06-11 11:30:57.858: E/AndroidRuntime(16661): at maps.aj.bf.a(Unknown Source)
06-11 11:30:57.858: E/AndroidRuntime(16661): at maps.aj.be.a(Unknown Source)
06-11 11:30:57.858: E/AndroidRuntime(16661): at bcw.onTransact(SourceFile:107)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.os.Binder.transact(Binder.java:297)
06-11 11:30:57.858: E/AndroidRuntime(16661): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
06-11 11:30:57.858: E/AndroidRuntime(16661): at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
06-11 11:30:57.858: E/AndroidRuntime(16661): at com.google.android.gms.internal.bb$4.b(Unknown Source)
06-11 11:30:57.858: E/AndroidRuntime(16661): at com.google.android.gms.internal.bb.a(Unknown Source)
06-11 11:30:57.858: E/AndroidRuntime(16661): at com.google.android.gms.internal.bb.onCreateView(Unknown Source)
06-11 11:30:57.858: E/AndroidRuntime(16661): at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:884)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1066)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1168)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:280)
06-11 11:30:57.858: E/AndroidRuntime(16661): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
06-11 11:30:57.858: E/AndroidRuntime(16661): ... 21 more
06-11 11:30:58.529: E/dalvikvm(16696): Could not find class 'android.telephony.CellInfo', referenced from method dmr.onCellInfoChanged
06-11 11:30:59.240: E/InputDispatcher(305): channel '41915cf8 com.example.playground/com.example.playground.Main (server)' ~ Channel is unrecoverably broken and will be disposed!
06-11 11:32:29.518: E/rmt_storage(97): rmt_storage write event
06-11 11:35:12.717: E/rmt_storage(97): rmt_storage write event
06-11 11:38:05.235: E/MipErrorService(17012): *** The argument of intent is null.
06-11 11:40:50.346: E/rmt_storage(97): rmt_storage write event
As the error suggests:
API key not found. Check that
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your API key"/>
is in the element of AndroidManifest.xml
So you place you key in the wrong possition in the Menifest file.

android error IllegalArgumentException

I can't find following error in my code. It looks like the problem is in the asynctask onpostexecute.
java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:672)
at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:368)
at android.view.WindowManagerImpl$CompatModeWrapper.removeView(WindowManagerImpl.java:160)
at android.app.Dialog.dismissDialog(Dialog.java:319)
at android.app.Dialog.dismiss(Dialog.java:302)
at www.mobilezar.mn.Advertisements$InitialLoading.onPostExecute(Advertisements.java:216)
at www.mobilezar.mn.Advertisements$InitialLoading.onPostExecute(Advertisements.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)

How to disable a tab bar item in android?

I am making my first android app. I want to disable a tab bat item in my android app. I searched and found the following way to do that:
tabHost = (TabHost)findViewById(R.id.tabhost);
tabHost.getTabWidget().getChildTabViewAt(your_index).setEnabled(false);
but its not working and i am getting following error:
06-11 16:53:15.927: D/AndroidRuntime(8466): Shutting down VM
06-11 16:53:15.927: W/dalvikvm(8466): threadid=1: thread exiting with uncaught exception (group=0x40028a00)
06-11 16:53:16.037: D/dalvikvm(8466): GC_FOR_MALLOC freed 5350 objects / 347632 bytes in 98ms
06-11 16:53:16.047: E/AndroidRuntime(8466): FATAL EXCEPTION: main
06-11 16:53:16.047: E/AndroidRuntime(8466): java.lang.IllegalStateException: Could not execute method of the activity
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.view.View$1.onClick(View.java:2072)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.view.View.performClick(View.java:2408)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.view.View$PerformClick.run(View.java:8817)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.os.Handler.handleCallback(Handler.java:587)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.os.Handler.dispatchMessage(Handler.java:92)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.os.Looper.loop(Looper.java:143)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.app.ActivityThread.main(ActivityThread.java:4914)
06-11 16:53:16.047: E/AndroidRuntime(8466): at java.lang.reflect.Method.invokeNative(Native Method)
06-11 16:53:16.047: E/AndroidRuntime(8466): at java.lang.reflect.Method.invoke(Method.java:521)
06-11 16:53:16.047: E/AndroidRuntime(8466): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
06-11 16:53:16.047: E/AndroidRuntime(8466): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-11 16:53:16.047: E/AndroidRuntime(8466): at dalvik.system.NativeStart.main(Native Method)
06-11 16:53:16.047: E/AndroidRuntime(8466): Caused by: java.lang.reflect.InvocationTargetException
06-11 16:53:16.047: E/AndroidRuntime(8466): at com.eplinovo.runnoandroid.ActivityViewActivity.startClick(ActivityViewActivity.java:40)
06-11 16:53:16.047: E/AndroidRuntime(8466): at java.lang.reflect.Method.invokeNative(Native Method)
06-11 16:53:16.047: E/AndroidRuntime(8466): at java.lang.reflect.Method.invoke(Method.java:521)
06-11 16:53:16.047: E/AndroidRuntime(8466): at android.view.View$1.onClick(View.java:2067)
06-11 16:53:16.047: E/AndroidRuntime(8466): ... 11 more
06-11 16:53:16.047: E/AndroidRuntime(8466): Caused by: java.lang.NullPointerException
06-11 16:53:16.047: E/AndroidRuntime(8466): ... 15 more
Why am i getting that? Thanks in advance.
Ok. Go to the top of the error in logcat, which is ActivityViewActivity.startClick. Go ahead and click on this line. It will take you to some line in startClick method where there is a null pointer exeption. Tell us what is on that line. It might be the line above. If it is than for example
tabHost might be null. Check this separately.
tabHost.getWidget()
tagHost.getWidget().getChildTabViewAt(your_index) // I bet its this one thats null.
if any of the above are null you will get that exception assumming that the line causing the problem. If not its something similar on another line.
So divide and conquer. Find the line. Split it up to find what might be null. Then set a breakpoint before the line runs, and step one line at a time. Hover over to see what is null at each step. Thats how you can solve any null pointer in android.
I was not getting tabhost in right way.
tabHost = (TabHost)findViewById(R.id.tabhost);
Following is the right way to get tabhost from child activity:
tabHost = (TabHost)getParent().findViewById(android.R.id.tabhost);

Categories

Resources