Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8587555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:35:50+00:00 2026-06-11T22:35:50+00:00

I am working with the new Google Analytics Beta for Mobile. I am getting

  • 0

I am working with the new Google Analytics Beta for Mobile. I am getting the following exception sometimes when I run my code:

E/AndroidRuntime(29101): java.lang.RuntimeException: Unable to start
activity
ComponentInfo{com.wsoft/com.wsoft.ui.AppActivity}:
java.lang.IllegalStateException: You must call
EasyTracker.getInstance().setContext(context) or
startActivity(activity) before calling getTracker()
E/AndroidRuntime(29101): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
E/AndroidRuntime(29101): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
E/AndroidRuntime(29101): at
android.app.ActivityThread.access$600(ActivityThread.java:130)
E/AndroidRuntime(29101): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
E/AndroidRuntime(29101): at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(29101): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(29101): at
android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime(29101): at
java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(29101): at
java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(29101): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime(29101): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime(29101): at dalvik.system.NativeStart.main(Native
Method) E/AndroidRuntime(29101):

Caused by:
java.lang.IllegalStateException: You must call
EasyTracker.getInstance().setContext(context) or
startActivity(activity) before calling getTracker()
E/AndroidRuntime(29101): at
com.google.analytics.tracking.android.EasyTracker.getTracker(EasyTracker.java:113)
E/AndroidRuntime(29101): at
com.wsoft.ui.AppActivity.setupApp(AppActivity.java:425)
E/AndroidRuntime(29101): at
com.wsoft.ui.AppActivity.onCreate(AppActivity.java:121)

To setup the analytics, I initialized the EasyTracker in the onStart() method (per documentation) like so:

public void onStart() {
        super.onStart();
        EasyTracker.getInstance().activityStart(this); 
    }

The IllegalStateException get’s thrown out of code, that is executing in my onCreate() method – which of course gets run before onStart() – so I understand why this is being thrown.

I am thinking of moving the EasyTracker initialization inside the onCreate(), instead of onStart().

Any reasons why I shouldn’t do this? Any suggestions on how to setup EasyTracker more reliable (in regards to Activity lifecycle? )

Or, if anyone has any good suggestions on how to ensure the EasyTracker is initialized before I use it (this causes a FC, which is obviously a bad thing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:35:51+00:00Added an answer on June 11, 2026 at 10:35 pm

    Actually the docs say to initialize in onStart when you want to use Automatic Screen Tracking (EasyTracker), this is similar to the old V1 version of EasyTracker which did the same thing, but you would extend your class from a tracked version such as TrackedActivity.
    But the docs do state that if you are doing any manual screen tracking, that you make sure to call setContext before calling something like trackEvent.
    Docs are a little sparse with specifics on how to do this.
    Anyway, I just created my own trackEvent, and trackView classes, that take a context as a parameter, to make sure it is always set.

    public static void trackView(Context ctx, String sScreenName){
        EasyTracker.getInstance().setContext(ctx);
        EasyTracker.getTracker().trackView(sScreenName);
    
    }
    public static void trackEvent(Context ctx, String sCategory, String sAction, String sLabel, Long lOptVal){
        EasyTracker.getInstance().setContext(ctx);
        EasyTracker.getTracker().trackEvent(sCategory, sAction, sLabel, lOptVal);
    }
    

    solves the problem for me. Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following javascript code is not working which has a query to google fusion
I have integrated a Custom Google Search on a new site I am working
I'm was following http://googcloudlabs.appspot.com/ tutorial to create new Google App Engine project. It throws
I am using Google visualization api. Following is my sample code. Either of the
I've been working with this plugin: http://www.neilcrookes.com/2009/09/27/get-google-analytics-data-in-your-cakephp/ but honestly it's over my head. Under
I have jQuery mobile working with google maps so that I can display one,
Hi I am working with google maps API I have this huge code, so
I'm trying to get Google Analytics working on my blog , but the events
I'm working on google map api v3 code. I saved all my markers in
I'm trying to work with another companies google analytics code. Unfortunately I don't have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.