Why is executing this HttpGet in Android raising a NullPointerException? - android

I've created a new Android project in which the only code I've added is this code in the onCreate() method (I also added the INTERNET permission to the manifest):
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_http_get_test);
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
try
{
System.out.println("making uri");
URI uri = new URI("http://w3mentor.com/");
request.setURI(uri);
System.out.println("executing");
client.execute(request); // This line throws the exception
System.out.println("Done!");
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
In the log, I see that the last thing printed by the try block was executing, after which a NullPointerException was thrown.
I loosely based my code on the beginning of this example, but I can't see what I'm doing differently that would cause a NullPointerException.
When run in the debugger I see that the exception is actually a NetworkOnMainThreadException, which apparently causes a NullPointerException when I try e.getMessage().
The error message being printed out is
07-12 02:58:33.997: E/AndroidRuntime(983): FATAL EXCEPTION: main
07-12 02:58:33.997: E/AndroidRuntime(983): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.whatever.http.test/com.whatever.http.test.HttpGetTest}: java.lang.NullPointerException
07-12 02:58:33.997: E/AndroidRuntime(983): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
07-12 02:58:33.997: E/AndroidRuntime(983): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-12 02:58:33.997: E/AndroidRuntime(983): at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-12 02:58:33.997: E/AndroidRuntime(983): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-12 02:58:33.997: E/AndroidRuntime(983): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 02:58:33.997: E/AndroidRuntime(983): at android.os.Looper.loop(Looper.java:137)
07-12 02:58:33.997: E/AndroidRuntime(983): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-12 02:58:33.997: E/AndroidRuntime(983): at java.lang.reflect.Method.invokeNative(Native Method)
07-12 02:58:33.997: E/AndroidRuntime(983): at java.lang.reflect.Method.invoke(Method.java:511)
07-12 02:58:33.997: E/AndroidRuntime(983): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-12 02:58:33.997: E/AndroidRuntime(983): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-12 02:58:33.997: E/AndroidRuntime(983): at dalvik.system.NativeStart.main(Native Method)
07-12 02:58:33.997: E/AndroidRuntime(983): Caused by: java.lang.NullPointerException
07-12 02:58:33.997: E/AndroidRuntime(983): at com.android.internal.os.LoggingPrintStream.println(LoggingPrintStream.java:298)
07-12 02:58:33.997: E/AndroidRuntime(983): at com.whatever.http.test.HttpGetTest.onCreate(HttpGetTest.java:33)
07-12 02:58:33.997: E/AndroidRuntime(983): at android.app.Activity.performCreate(Activity.java:4465)
07-12 02:58:33.997: E/AndroidRuntime(983): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-12 02:58:33.997: E/AndroidRuntime(983): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
07-12 02:58:33.997: E/AndroidRuntime(983): ... 11 more

The Issue is not a NullPointerException but if you debug your application, you will find that the exception is : NetworkOnMainThreadException.
Most likely you are running your application on the newer SDKs (Honeycomb or greater) as a result of which this is discouraged.
Any networking code, you should put in a thread. Ideally use the AsyncTask for that. Check this link out : http://www.techblogistech.com/2011/11/how-to-fix-the-android-networkonmainthreadexception/
Hope this helps.

Related

Android java.lang.exceptionininitializererror System.loadLibrary

I am trying to load prebuild native shared library from MainActivity of my project in following way:
static
{
System.loadLibrary("mylib.so"); // I have tried this way
//System.loadLibrary("libmylib.so"); // Also tried this way
//System.loadLibrary("mylib"); // Also tried this way
}
But all times it throws following exception:
Warning before exception:
07-12 11:08:36.019: W/dalvikvm(21552): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/libtest/src/MainActivity;
07-12 11:08:42.790: W/dalvikvm(21552): Class init failed in newInstance call (Lcom/libtest/src/MainActivity;)
07-12 11:08:47.067: D/AndroidRuntime(21552): Shutting down VM
07-12 11:08:47.067: W/dalvikvm(21552): threadid=1: thread exiting with uncaught exception (group=0x40015560)
Then exception:
07-12 11:08:47.167: E/AndroidRuntime(21552): FATAL EXCEPTION: main
07-12 11:08:47.167: E/AndroidRuntime(21552): java.lang.ExceptionInInitializerError
07-12 11:08:47.167: E/AndroidRuntime(21552): at java.lang.Class.newInstanceImpl(Native Method)
07-12 11:08:47.167: E/AndroidRuntime(21552): at java.lang.Class.newInstance(Class.java:1409)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.os.Looper.loop(Looper.java:130)
Native shared library placed "libs\armeabi\mylib.so" under my project folder.
Please help me what I did wrong?
your library name should be
libmylib.so
You should change the settings of the project which is generating the library and generate with correct name. then you can load this library using
System.loadLibrary("mylib");
As a quick measure, you can just rename the library name and try.
According to this document It Signals that an unexpected exception has occurred in a static initializer. An ExceptionInInitializerError is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable.
check somewhere you tried static initialization

Memory Issue in my android application

07-12 12:01:47.016: E/AndroidRuntime(24203): FATAL EXCEPTION: main
07-12 12:01:47.016: E/AndroidRuntime(24203): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.oman.muscat/com.oman.muscat.settings.Settings}: android.view.InflateException: Binary XML file line #55: Error inflating class <unknown>
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.app.ActivityThread.access$600(ActivityThread.java:140)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.os.Looper.loop(Looper.java:137)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.app.ActivityThread.main(ActivityThread.java:4898)
07-12 12:01:47.016: E/AndroidRuntime(24203): at java.lang.reflect.Method.invokeNative(Native Method)
07-12 12:01:47.016: E/AndroidRuntime(24203): at java.lang.reflect.Method.invoke(Method.java:511)
07-12 12:01:47.016: E/AndroidRuntime(24203): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
07-12 12:01:47.016: E/AndroidRuntime(24203): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
07-12 12:01:47.016: E/AndroidRuntime(24203): at dalvik.system.NativeStart.main(Native Method)
07-12 12:01:47.016: E/AndroidRuntime(24203): Caused by: android.view.InflateException: Binary XML file line #55: Error inflating class <unknown>
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
07-12 12:01:47.016: E/AndroidRuntime(24203): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-12 12:01:47.016: E/AndroidRuntime(24203): at com.muscat.menudrawer.MenuDrawer.setContentView(MenuDrawer.java:1055)
07-12 12:01:47.016: E/AndroidRuntime(24203): at com.oman.muscat.settings.Settings.onCreate(Settings.java:92)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.app.Activity.performCreate(Activity.java:5206)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
07-12 12:01:47.016: E/AndroidRuntime(24203): ... 11 more
07-12 12:01:47.016: E/AndroidRuntime(24203): Caused by: java.lang.reflect.InvocationTargetException
07-12 12:01:47.016: E/AndroidRuntime(24203): at java.lang.reflect.Constructor.constructNative(Native Method)
07-12 12:01:47.016: E/AndroidRuntime(24203): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
07-12 12:01:47.016: E/AndroidRuntime(24203): ... 23 more
07-12 12:01:47.016: E/AndroidRuntime(24203): Caused by: java.lang.OutOfMemoryError
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:623)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:476)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.content.res.Resources.loadDrawable(Resources.java:1963)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.view.View.<init>(View.java:3436)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.view.ViewGroup.<init>(ViewGroup.java:432)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.widget.LinearLayout.<init>(LinearLayout.java:176)
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.widget.LinearLayout.<init>(LinearLayout.java:172)
07-12 12:01:47.016: E/AndroidRuntime(24203): ... 26 more
Please give some solution to fix this issue.
You seem to be loading large bitmaps in your activity and the device is running out of memory. Here's a guide to displaying bitmaps properly in Android - http://developer.android.com/training/displaying-bitmaps/index.html
From the logs, it seems like the FATAL exception is caused by java.lang.OutOfMemoryError.
which means that the bitmaps which are created during aren't deallocated properly.
07-12 12:01:47.016: E/AndroidRuntime(24203): Caused by: android.view.InflateException: Binary XML file line #55: Error inflating class <unknown>
07-12 12:01:47.016: E/AndroidRuntime(24203): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
07-12 12:01:47.016: E/AndroidRuntime(24203): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
have you checked whether you are deallocating bitmaps, while pausing or destroying the activity or Not.(in onDestroy() or in onPause()).

Crash while playing a song with default music player

I want to play some audio files with the default music player. As mentioned in this post, I've tried the following code:
Intent intent = new Intent();
ComponentName comp = new ComponentName("com.android.music", "com.android.music.MediaPlaybackActivity");
intent.setComponent(comp);
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File(songPath.toString());
intent.setDataAndType(Uri.fromFile(file), "audio/*");
startActivity(intent);
But, I'm getting ActivityNotFound Exception with the following logs:
07-12 11:28:49.575: E/AndroidRuntime(22700): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jusplay/com.example.jusplay.playdb}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.music/com.android.music.MediaPlaybackActivity}; have you declared this activity in your AndroidManifest.xml?
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.app.ActivityThread.access$1500(ActivityThread.java:121)
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.os.Looper.loop(Looper.java:130)
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.app.ActivityThread.main(ActivityThread.java:3701)
07-12 11:28:49.575: E/AndroidRuntime(22700): at java.lang.reflect.Method.invokeNative(Native Method)
07-12 11:28:49.575: E/AndroidRuntime(22700): at java.lang.reflect.Method.invoke(Method.java:507)
07-12 11:28:49.575: E/AndroidRuntime(22700): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
07-12 11:28:49.575: E/AndroidRuntime(22700): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
07-12 11:28:49.575: E/AndroidRuntime(22700): at dalvik.system.NativeStart.main(Native Method)
07-12 11:28:49.575: E/AndroidRuntime(22700): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.music/com.android.music.MediaPlaybackActivity}; have you declared this activity in your AndroidManifest.xml?
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.app.Activity.startActivityForResult(Activity.java:2827)
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.app.Activity.startActivity(Activity.java:2933)
07-12 11:28:49.575: E/AndroidRuntime(22700): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
I'm unable to figure out why this crash is happening !!

Illegal state exception when querying MediaStrore.Images

I am getting a IllegalStateException when I run the following code:
Cursor imageCursor=getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,new String[]{MediaStore.Images.Media.DATA},MediaStore.Images.Media.DISPLAY_NAME+"=?" ,new String[]{imageTitle},null);
imageCursor.moveToFirst();
String imageData=imageCursor.getString(imageCursor.getColumnIndex(MediaStore.Images.Media.DATA));
Long imageSize=imageCursor.getLong(imageCursor.getColumnIndex(ImageColumns.SIZE));
Toast.makeText(getApplicationContext(), String.valueOf(imageSize), Toast.LENGTH_LONG).show();
Here is the stacktrace
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): java.lang.IllegalStateException: get field slot from row 0 col -1 failed
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at android.database.CursorWindow.getLong_native(Native Method)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at android.database.CursorWindow.getLong(CursorWindow.java:380)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at android.database.AbstractWindowedCursor.getLong(AbstractWindowedCursor.java:108)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at android.database.CursorWrapper.getLong(CursorWrapper.java:127)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at com.messageHider.viewImageThumb$1.onClick(viewImageThumb.java:93)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at android.os.Looper.loop(Looper.java:123)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at java.lang.reflect.Method.invokeNative(Native Method)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at java.lang.reflect.Method.invoke(Method.java:521)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-12 10:49:27.426: ERROR/AndroidRuntime(1397): at dalvik.system.NativeStart.main(Native Method)
The error is at:
Long imageSize=imageCursor.getLong(imageCursor.getColumnIndex(ImageColumns.SIZE));
Include SIZE in your query projection(the second param in the content resolvers query method).
its MediaStore.MediaColumns.SIZE i believe.

RuntimeException from Google Analytics for Android "sending message to a handler on a dead thread"

I am using Google Analytics for Android to track events, page views on an Android app. When calling the tracker's dispatch method, I receive a RuntimeException:
07-12 18:02:05.594: WARN/MessageQueue(12823): Handler{44a08620} sending message to a Handler on a dead thread
07-12 18:02:05.594: WARN/MessageQueue(12823): java.lang.RuntimeException: Handler{44a08620} sending message to a Handler on a dead thread
07-12 18:02:05.594: WARN/MessageQueue(12823): at android.os.MessageQueue.enqueueMessage(MessageQueue.java:179)
07-12 18:02:05.594: WARN/MessageQueue(12823): at android.os.Handler.sendMessageAtTime(Handler.java:457)
07-12 18:02:05.594: WARN/MessageQueue(12823): at android.os.Handler.sendMessageDelayed(Handler.java:430)
07-12 18:02:05.594: WARN/MessageQueue(12823): at android.os.Handler.post(Handler.java:248)
07-12 18:02:05.594: WARN/MessageQueue(12823): at com.google.android.apps.analytics.NetworkDispatcher$DispatcherThread.dispatchEvents(Unknown Source)
07-12 18:02:05.594: WARN/MessageQueue(12823): at com.google.android.apps.analytics.NetworkDispatcher.dispatchEvents(Unknown Source)
07-12 18:02:05.594: WARN/MessageQueue(12823): at com.google.android.apps.analytics.GoogleAnalyticsTracker.dispatch(Unknown Source)
07-12 18:02:05.594: WARN/MessageQueue(12823): at com.company.activity.set(MyActivity.java:177)
07-12 18:02:05.594: WARN/MessageQueue(12823): at com.company.activity.access$34(MyActivity.java:175)
07-12 18:02:05.594: WARN/MessageQueue(12823): at com.company.activity.$45.onClick(MyActivity.java:1982)
07-12 18:02:05.594: WARN/MessageQueue(12823): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
07-12 18:02:05.594: WARN/MessageQueue(12823): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 18:02:05.594: WARN/MessageQueue(12823): at android.os.Looper.loop(Looper.java:123)
07-12 18:02:05.594: WARN/MessageQueue(12823): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-12 18:02:05.594: WARN/MessageQueue(12823): at java.lang.reflect.Method.invokeNative(Native Method)
07-12 18:02:05.594: WARN/MessageQueue(12823): at java.lang.reflect.Method.invoke(Method.java:521)
07-12 18:02:05.594: WARN/MessageQueue(12823): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-12 18:02:05.594: WARN/MessageQueue(12823): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-12 18:02:05.594: WARN/MessageQueue(12823): at dalvik.system.NativeStart.main(Native Method)
--EDIT--
At first I was convinced it had to do with my placement of tracker, putting it in onResume, Threads, etc. magically made it throw exceptions. Turns out, Google's own example code (also available in their SDK download) also throws this Exception:
>07-12 23:47:09.343: WARN/MessageQueue(18468): null sending message to a Handler on a dead thread
07-12 23:47:09.343: WARN/MessageQueue(18468): java.lang.RuntimeException: null sending message to a Handler on a dead thread
07-12 23:47:09.343: WARN/MessageQueue(18468): at android.os.MessageQueue.enqueueMessage(MessageQueue.java:179)
07-12 23:47:09.343: WARN/MessageQueue(18468): at android.os.Looper.quit(Looper.java:173)
07-12 23:47:09.343: WARN/MessageQueue(18468): at com.google.android.apps.analytics.NetworkDispatcher.stop(Unknown Source)
07-12 23:47:09.343: WARN/MessageQueue(18468): at com.google.android.apps.analytics.NetworkDispatcher.init(Unknown Source)
07-12 23:47:09.343: WARN/MessageQueue(18468): at com.google.android.apps.analytics.GoogleAnalyticsTracker.start(Unknown Source)
07-12 23:47:09.343: WARN/MessageQueue(18468): at com.google.android.apps.analytics.GoogleAnalyticsTracker.start(Unknown Source)
07-12 23:47:09.343: WARN/MessageQueue(18468): at com.google.android.apps.analytics.GoogleAnalyticsTracker.start(Unknown Source)
07-12 23:47:09.343: WARN/MessageQueue(18468): at com.google.android.apps.analytics.sample.AnalyticsSample.onCreate(AnalyticsSample.java:23)
07-12 23:47:09.343: WARN/MessageQueue(18468): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-12 23:47:09.343: WARN/MessageQueue(18468): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-12 23:47:09.343: WARN/MessageQueue(18468): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-12 23:47:09.343: WARN/MessageQueue(18468): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3815)
07-12 23:47:09.343: WARN/MessageQueue(18468): at android.app.ActivityThread.access$2400(ActivityThread.java:125)
07-12 23:47:09.343: WARN/MessageQueue(18468): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2037)
07-12 23:47:09.343: WARN/MessageQueue(18468): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 23:47:09.343: WARN/MessageQueue(18468): at android.os.Looper.loop(Looper.java:123)
07-12 23:47:09.343: WARN/MessageQueue(18468): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-12 23:47:09.343: WARN/MessageQueue(18468): at java.lang.reflect.Method.invokeNative(Native Method)
07-12 23:47:09.343: WARN/MessageQueue(18468): at java.lang.reflect.Method.invoke(Method.java:521)
07-12 23:47:09.343: WARN/MessageQueue(18468): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-12 23:47:09.343: WARN/MessageQueue(18468): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-12 23:47:09.343: WARN/MessageQueue(18468): at dalvik.system.NativeStart.main(Native Method)
This happens when you force the original activity to be destroyed (i.e. changing orientation, going to Home screen, etc.) . I can't store the original tracker object via onSavedInstance, since tracker isn't a Parcelable. Any other ideas, clues how to get rid of this error?
--EDIT--
Even stranger, it seems that this is also causing the following problem:
>07-13 00:50:02.581: WARN/googleanalytics(27605): Dispatcher thinks it finished, but there were -4 failed events
While most mentions of this online point their fingers back to whitespaces in the Events or PageViews which corrupt the db, I have confirmed this not to be the case. Also, I'm not sure what it means to have a negative event (-4)!
You could do a dispatch in onPause()
tracker.dispatch();
to avoid losing data and then recreate the tracker

Categories

Resources