Google Analytics problem


#1

Hey iam using Dan Wilson’s Google Analytics plugin https://github.com/danwilson/google-analytics-plugin.git and followed this post https://blog.nraboy.com/2014/06/using-google-analytics-ionicframework/ and i used the following code in app.js

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {

if(typeof analytics !== "undefined") {
            console.log('analytics working');
            console.log('analytics working fine');
            analytics.startTrackerWithId("UA-XXXXXXXX-XX");

        } else {
            console.log("Google Analytics Unavailable");
        }

console.log('in platform.ready method');


if (window.cordova && window.cordova.plugins.Keyboard) {
  cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
  // org.apache.cordova.statusbar required
  StatusBar.styleDefault();
}

});
})

and i got an error in the code, which i got in adb logcat console saying that

W/System.err( 1788): java.lang.ClassNotFoundException: com.danielcwilson.plugins.analytics.UniversalAnalyticsPlugin
W/System.err( 1788): at java.lang.Class.classForName(Native Method)
W/System.err( 1788): at java.lang.Class.forName(Class.java:251)
W/System.err( 1788): at java.lang.Class.forName(Class.java:216)
W/System.err( 1788): at org.apache.cordova.PluginEntry.getClassByName(PluginEntry.java:117)
W/System.err( 1788): at org.apache.cordova.PluginEntry.createPlugin(PluginEntry.java:93)
W/System.err( 1788): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:281)
W/System.err( 1788): at org.apache.cordova.PluginManager.execHelper(PluginManager.java:232)
W/System.err( 1788): at org.apache.cordova.PluginManager.exec(PluginManager.java:227)
W/System.err( 1788): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:53)
W/System.err( 1788): at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err( 1788): at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
W/System.err( 1788): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 1788): at android.os.Looper.loop(Looper.java:136)
W/System.err( 1788): at android.os.HandlerThread.run(HandlerThread.java:61)
W/System.err( 1788): Caused by: java.lang.NoClassDefFoundError: com/danielcwilson/plugins/analytics/UniversalAnalyticsPlugin
W/System.err( 1788): … 14 more
W/System.err( 1788): Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.danielcwilson.plugins.analytics.UniversalAnalyticsPlugin” on path: DexPathList[[zip file “/data/app/com.ionicframework.myapp526572-2.apk”],nativeLibraryDirectories=[/data/app-lib/com.ionicframework.myapp526572-2, /vendor/lib, /system/lib]]
W/System.err( 1788): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/System.err( 1788): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
W/System.err( 1788): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
W/System.err( 1788): … 14 more
I/System.out( 1788): Error adding plugin com.danielcwilson.plugins.analytics.UniversalAnalyticsPlugin.
D/PluginManager( 1788): exec() call to unknown plugin: UniversalAnalytics
D/CordovaLog( 1788): file:///android_asset/www/js/app.js: Line 23 : in platform.ready method
I/chromium( 1788): [INFO:CONSOLE(23)] “in platform.ready method”, source: file:///android_asset/www/js/app.js (23)

can any one know how to solve this problem.


#2

I got the same issue and solved it by removing and re-adding pluggin, it works.
Could you try it :slight_smile:


#3

thanks for your reply @silverhair2010 , i tried it, but that didn’t solve the issue.