Android : Android - Google Analytics V4 Exception

on Saturday, September 13, 2014


So, I followed this ( http://java.dzone.com/articles/working-google-analytics-api ) tutorial to add Google Analytics v4 to my application but after everything that is there when I try to run it i get an error that looks like this:



09-13 12:52:01.122 31624-31624/com.rivert.unlockscope E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.rivert.unlockscope, PID: 31624
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rivert.unlockscope/com.rivert.unlockscope.unlockscope}: java.lang.ClassCastException: android.app.Application cannot be cast to com.rivert.unlockscope.MyApplication
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2187)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2236)
at android.app.ActivityThread.access$800(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5034)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.rivert.unlockscope.MyApplication
at com.rivert.unlockscope.unlockscope.onCreate(unlockscope.java:37)
at android.app.Activity.performCreate(Activity.java:5241)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2151)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2236)
at android.app.ActivityThread.access$800(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5034)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
at dalvik.system.NativeStart.main(Native Method)
09-13 12:52:02.594 31624-31624/com.rivert.unlockscope I/Process﹕ Sending signal. PID: 31624 SIG: 9


My code from line 37 is:


((MyApplication) getApplication()).getTracker(MyApplication.TrackerName.APP_TRACKER);


Can anyone help me? Thanks


0 comments:

Post a Comment