2

I am trying to integrate flurry android integration tool to my app. I have integrated the jar library but I'm stuck at this point as I'm getting some error. Error says Cannot resolve method 'onCreate()' and Cannot resolve symbol 'XY**********P2P'

 import com.flurry.android.FlurryAgent;
    import com.getbase.floatingactionbutton.FloatingActionButton;


    public class MainActivity extends Activity {


        @Override
        public void onCreate() {
            super.onCreate();
            // init Flurry
            FlurryAgent.init(this, XYB***********2P);
            //....
        }

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
Ahmed Raza
  • 73
  • 6
  • Why is there one more `onCreate` in Activity? – Raghunandan Jul 27 '15 at 10:25
  • I'm new in java and android I'don't know if I can use two onCreate methods or not. If not then how would I implement this ? Can you guige me with the code? – Ahmed Raza Jul 27 '15 at 10:41
  • You should not. Just move your code in onCreate to the second onCreate – Raghunandan Jul 27 '15 at 10:42
  • Itried it like this @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); super.onCreate(); // init Flurry FlurryAgent.init(this, XYB7G3B*********2P); //.... – Ahmed Raza Jul 27 '15 at 10:43
  • And the problem is?? – Raghunandan Jul 27 '15 at 10:44
  • Same error with this code as well – Ahmed Raza Jul 27 '15 at 10:45
  • Change to `private final static String FLURRY_KEY = "XYB***********2P"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Flurry FlurryAgent.init(this, FLURRY_KEY); }` – Raghunandan Jul 27 '15 at 10:46
  • Do I need to add this flurry code in all the activities to be able to use flurry analytics? – Ahmed Raza Jul 27 '15 at 11:05
  • 1
    That can be checked on the documentation @ flurry.com. Generally these go into application class since its global – Raghunandan Jul 27 '15 at 11:06

1 Answers1

3

The first error is due to the @Override annotation on top of your first onCreate method. onCreate is a method of your superclass, Activity, and is defined like your second onCreate method, it needs to be protected and take a Bundle object as argument, otherwise it doesn't override the superclass method. To fix this, simply delete your first onCreate method and move the code you need to the second one.

The second error is due to the fact that you haven no variable with the name XYB***********2P so the compiler doesn't know what to do with that.

Since the init method of FlurryAgent (see docs) takes a String, you could define one like so :

private final static String FLURRY_KEY = "XYB***********2P";

then use it like this :

FlurryAgent.init(this, FLURRY_KEY);
2Dee
  • 8,609
  • 7
  • 42
  • 53
  • And make sure you import ll the right classes, it seems you're missing the import of Activity, at least. – 2Dee Jul 27 '15 at 10:46
  • Do I need to add this flurry code in all the activities to be able to use flurry analytics? – Ahmed Raza Jul 27 '15 at 11:05
  • 1
    I'm no expert, but according to the docs, you can simply initialize it once in the Application class. Have a look at their [Getting Started page](https://developer.yahoo.com/flurry/docs/analytics/gettingstarted/android/), it should get you going. – 2Dee Jul 27 '15 at 11:55