Friday, December 3, 2010

[android-developers] Re: Analytics receiver doesn't close database cursor!

Actually, I guess i'm supposed to stop the tracker on my onDestroy,
but this doesn't seem to relate to the problem.

-Eric

On Dec 3, 7:04 pm, miniondev <erics...@gmail.com> wrote:
> Hi,
>
> I'm trying to integrate google analytics into my android application
> and I also want to use the INSTALL_REFERRER feature.  I've followed
> the documentation, and when my app installs from the market, I can see
> that the com.google.android.apps.analytics.AnalyticsReceiver gets the
> referrer info successfully.  I know this because in the log, I see:
>
> DEBUG/googleanalytics(6730): Stored referrer:utmcsr=ericsite|
> utmccn=testing|utmcmd=email
>
> Now, my app uses the GoogleAnalyticsTracker instance in the usual way,
> starting it in the onCreate method of my main activity, stopping it in
> my onStop, and dispatching events in between.  However, on the first
> run of the application (after initial install), a stacktrace is dumped
> in the log.  It's a bit funny because it's not an uncaught exception,
> it's evidently an exception that was caught and logged when the
> AnalyticsReceiver received the INSTALL_REFERRER intent.  This happened
> during install, but I guess android is logging it in my application
> when it first runs, because it's the only time i'd actually see it?
> It's a bit weird, anyway, here's the exception that's logged:
>
> WARN/SQLiteCompiledSql(6675): Releasing statement in a finalizer.
> Please ensure that you explicitly call close() on your cursor: INSERT
> INTO install_referrer(referrer) VALUES(?);
> WARN/SQLiteCompiledSql(6675):
> android.database.sqlite.DatabaseObjectNotClosedException: Application
> did not close the cursor or database object that was opened here
> WARN/SQLiteCompiledSql(6675):     at
> android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:
> 62)
> WARN/SQLiteCompiledSql(6675):     at
> android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
> WARN/SQLiteCompiledSql(6675):     at
> android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:
> 36)
> WARN/SQLiteCompiledSql(6675):     at
> android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java :
> 1145)
> WARN/SQLiteCompiledSql(6675):     at
> android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase. java:
> 1536)
> WARN/SQLiteCompiledSql(6675):     at
> android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:
> 1410)
> WARN/SQLiteCompiledSql(6675):     at
> com.google.android.apps.analytics.PersistentEventStore.setReferrer(Persiste ntEventStore.java:
> 235)
> WARN/SQLiteCompiledSql(6675):     at
> com.google.android.apps.analytics.AnalyticsReceiver.onReceive(AnalyticsRece iver.java:
> 35)
> WARN/SQLiteCompiledSql(6675):     at
> android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
> WARN/SQLiteCompiledSql(6675):     at android.app.ActivityThread.access
> $3200(ActivityThread.java:125)
> WARN/SQLiteCompiledSql(6675):     at android.app.ActivityThread
> $H.handleMessage(ActivityThread.java:2083)
> WARN/SQLiteCompiledSql(6675):     at
> android.os.Handler.dispatchMessage(Handler.java:99)
> WARN/SQLiteCompiledSql(6675):     at
> android.os.Looper.loop(Looper.java:123)
> WARN/SQLiteCompiledSql(6675):     at
> android.app.ActivityThread.main(ActivityThread.java:4627)
> WARN/SQLiteCompiledSql(6675):     at
> java.lang.reflect.Method.invokeNative(Native Method)
> WARN/SQLiteCompiledSql(6675):     at
> java.lang.reflect.Method.invoke(Method.java:521)
> WARN/SQLiteCompiledSql(6675):     at com.android.internal.os.ZygoteInit
> $MethodAndArgsCaller.run(ZygoteInit.java:858)
> WARN/SQLiteCompiledSql(6675):     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
> WARN/SQLiteCompiledSql(6675):     at
> dalvik.system.NativeStart.main(Native Method)
> ERROR/Database(6675): close() was never explicitly called on database
> '/data/data/com.miniondev.pegsolitaire/databases/google_analytics.db'
> ERROR/Database(6675):
> android.database.sqlite.DatabaseObjectNotClosedException: Application
> did not close the cursor or database object that was opened here
> ERROR/Database(6675):     at
> android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:
> 1810)
> ERROR/Database(6675):     at
> android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:
> 817)
> ERROR/Database(6675):     at
> android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase. java:
> 851)
> ERROR/Database(6675):     at
> android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase. java:
> 844)
> ERROR/Database(6675):     at
> android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:540)
> ERROR/Database(6675):     at
> android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:
> 203)
> ERROR/Database(6675):     at
> android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:
> 203)
> ERROR/Database(6675):     at
> android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelp er.java:
> 98)
> ERROR/Database(6675):     at
> com.google.android.apps.analytics.PersistentEventStore.setReferrer(Persiste ntEventStore.java:
> 232)
> ERROR/Database(6675):     at
> com.google.android.apps.analytics.AnalyticsReceiver.onReceive(AnalyticsRece iver.java:
> 35)
> ERROR/Database(6675):     at
> android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
> ERROR/Database(6675):     at android.app.ActivityThread.access
> $3200(ActivityThread.java:125)
> ERROR/Database(6675):     at android.app.ActivityThread
> $H.handleMessage(ActivityThread.java:2083)
> ERROR/Database(6675):     at
> android.os.Handler.dispatchMessage(Handler.java:99)
> ERROR/Database(6675):     at android.os.Looper.loop(Looper.java:123)
> ERROR/Database(6675):     at
> android.app.ActivityThread.main(ActivityThread.java:4627)
> ERROR/Database(6675):     at
> java.lang.reflect.Method.invokeNative(Native Method)
> ERROR/Database(6675):     at
> java.lang.reflect.Method.invoke(Method.java:521)
> ERROR/Database(6675):     at com.android.internal.os.ZygoteInit
> $MethodAndArgsCaller.run(ZygoteInit.java:858)
> ERROR/Database(6675):     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
> ERROR/Database(6675):     at dalvik.system.NativeStart.main(Native
> Method)
>
> This exception, it would seem, didn't stop my app from starting the
> tracker instance, or dispatching events, but still...  it doesn't fill
> me with confidence.  Does anybody know why the receiver is failing
> (sorta) ?
>
> Thanks!
>
> -Eric
>
> PS:
>
> There is some talk around the internet about an Analytics readme that
> contains the comment:
>
> "(NOTE: do not start the GoogleAnalyticsTracker in your Application
> onCreate() method if using referral tracking)."
> source:  http://stackoverflow.com/questions/3110394
>
> I can't find this readme, so i'm hesitant to put too much stock into
> the comment.  Maybe it's from an old version of the analytics sdk?
> Anybody know anything about this?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment