Crash while playing a song with default music player - android

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 !!

Related

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()).

Android : can't load my XML file and app crashes

So I just created a parser and a handler to parse an XML file. It works fine in my Java test project but doesn't in my Android project. Here is the complaining log :
07-12 09:44:59.586: E/AndroidRuntime(1164): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ec.ec/com.ec.ec.ListeOffresActivity}: android.os.NetworkOnMainThreadException
07-12 09:44:59.586: E/AndroidRuntime(1164): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
07-12 09:44:59.586: E/AndroidRuntime(1164): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-12 09:44:59.586: E/AndroidRuntime(1164): at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-12 09:44:59.586: E/AndroidRuntime(1164): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-12 09:44:59.586: E/AndroidRuntime(1164): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 09:44:59.586: E/AndroidRuntime(1164): at android.os.Looper.loop(Looper.java:137)
07-12 09:44:59.586: E/AndroidRuntime(1164): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-12 09:44:59.586: E/AndroidRuntime(1164): at java.lang.reflect.Method.invokeNative(Native Method)
07-12 09:44:59.586: E/AndroidRuntime(1164): at java.lang.reflect.Method.invoke(Method.java:511)
07-12 09:44:59.586: E/AndroidRuntime(1164): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-12 09:44:59.586: E/AndroidRuntime(1164): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-12 09:44:59.586: E/AndroidRuntime(1164): at dalvik.system.NativeStart.main(Native Method)
07-12 09:44:59.586: E/AndroidRuntime(1164): Caused by: android.os.NetworkOnMainThreadException
07-12 09:44:59.586: E/AndroidRuntime(1164): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
07-12 09:44:59.586: E/AndroidRuntime(1164): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
07-12 09:44:59.586: E/AndroidRuntime(1164): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
07-12 09:44:59.586: E/AndroidRuntime(1164): at java.net.InetAddress.getAllByName(InetAddress.java:214)
07-12 09:44:59.586: E/AndroidRuntime(1164): at libcore.net.http.HttpConnection.(HttpConnection.java:70)
07-12 09:44:59.586: E/AndroidRuntime(1164): at libcore.net.http.HttpConnection.(HttpConnection.java:50)
07-12 09:44:59.586: E/AndroidRuntime(1164): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341)
07-12 09:44:59.586: E/AndroidRuntime(1164): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
07-12 09:44:59.586: E/AndroidRuntime(1164): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
07-12 09:44:59.586: E/AndroidRuntime(1164): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
07-12 09:44:59.586: E/AndroidRuntime(1164): at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
07-12 09:44:59.586: E/AndroidRuntime(1164): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
07-12 09:44:59.586: E/AndroidRuntime(1164): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
07-12 09:44:59.586: E/AndroidRuntime(1164): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
07-12 09:44:59.586: E/AndroidRuntime(1164): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
07-12 09:44:59.586: E/AndroidRuntime(1164): at java.net.URL.openStream(URL.java:462)
07-12 09:44:59.586: E/AndroidRuntime(1164): at com.ec.ec.ListeOffresActivity.onCreate(ListeOffresActivity.java:31)
07-12 09:44:59.586: E/AndroidRuntime(1164): at android.app.Activity.performCreate(Activity.java:5008)
07-12 09:44:59.586: E/AndroidRuntime(1164): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-12 09:44:59.586: E/AndroidRuntime(1164): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
07-12 09:44:59.586: E/AndroidRuntime(1164): ... 11 more
It appears that my emulator isn't connected to the Internet, right ? What should I do ?
Thanks for your help
You are running your Network request on main UI thread. use AsyncTask to execute network request.
The log is not very cleay. But I can see the below error -
07-12 09:44:59.586: E/AndroidRuntime(1164): at java.net.URL.openStream(URL.java:462)
So most likely the URL is not accesisble from emulator, as you are able to access and parse the XMl from your java code.
Can you launch the browser from your emulator and see if the URL or even the internet is accessible?
-dattatray.

Why is executing this HttpGet in Android raising a NullPointerException?

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.

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