Updated Flurry Example?

Does anyone have a working Flurry analytics example that is newer than a year old? I've got the new Flurry jar file wrappered in a Bindings Library. All objects are referenceable and the project compiles. But I get the error below at runtime. Maybe, I'm calling it from the wrong place or failed to initialize something. I don't know because I can't find a current example.

Does anyone know if it would be possible to simply use the Windows Phone version of the Flurry DLL as a simple API endpoint? I know the Android version deals with Android's vagueness of a "session" (I can do manually) and can automatically get GPS (which I disable anyway due to the risk of bad battery management).

Java.Lang.NoClassDefFoundError: Exception of type 'Java.Lang.NoClassDefFoundError' was thrown.
at Android.Runtime.JNIEnv.FindClass (System.String classname) [0x00087] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/163212a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:396
at Android.Runtime.JNIEnv.FindClass (System.String className, System.IntPtr& cachedJniClassHandle) [0x00014] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/163212a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:409
at Com.Flurry.Android.FlurryAgent.get_class_ref () [0x00000] in c:\Data\Projects\Qonqr.Client\Qonqr.Droid.Wrapper\obj\Release\generated\src\Com.Flurry.Android.FlurryAgent.cs:14
at Com.Flurry.Android.FlurryAgent.OnStartSession (Android.Content.Context p0, System.String p1) [0x00011] in c:\Data\Projects\Qonqr.Client\Qonqr.Droid.Wrapper\obj\Release\generated\src\Com.Flurry.Android.FlurryAgent.cs:269
at Qonqr.Droid.Shared.Helpers.AnalyticsHelper.LogAppLaunch (System.String version, Boolean isResumeFromSuspend) [0x00002] in c:\Data\Projects\Qonqr.Client\Qonqr.Droid.Shared\Helpers\AnalyticsHelper.cs:42
--- End of managed exception stack trace ---
java.lang.NoClassDefFoundError: com/flurry/android/FlurryAgent
at qonqr.droid.black.QonqrApplication.n_onCreate(Native Method)
at qonqr.droid.black.QonqrApplication.onCreate(QonqrApplication.java:26)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4268)
at android.app.ActivityThread.access$1400(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1297)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4938)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.flurry.android.FlurryAgent
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
... 14 more

Posts

  • ScottDavisScottDavis USMember ✭✭

    Scratch the Windows Phone DLL idea. It has a dependency on Windows Phone core library. Need to solve the Bindings Library issue.

  • AndyFlisherAndyFlisher GBBeta, University ✭✭✭

    I've got a class that I've built in the last 6 months that gives me basic flurry functionality in ios and android, but not sure how old the SDK in the jar is. I can probably share if you like, but will need to clean some guff out. If memory serves you have to manually end the session on Android else nothing gets posted

  • ScottDavisScottDavis USMember ✭✭

    Hi Andy,

    It would be great to have an example posted. We already manually do all session management in our Android application. We need to "resync" the client with the server when the application is "reactivated". I'm comfortable our solution for the poor application state management in Android, would probably work for Flurry too.

  • AndyFlisherAndyFlisher GBBeta, University ✭✭✭

    I'll try and extract it from my class, or trim the fat, but think it only boils down to a about 3 lines of code for flurry

  • AndyFlisherAndyFlisher GBBeta, University ✭✭✭

    Ok, I have a generic analytics class which normally has a lot more 'bits', but the flurry component looks like (hope this is syntactically correct!)

    using System;
    using System.IO;
    
    #if __IOS__
    using FA=FlurryAnalytics;
    #endif 
    #if __ANDROID__
    using Android.Content;
    using FA;
    
    #endif
    
    namespace MyApp.Core
    {
        public class Analytics
        {
            #if __ANDROID__
            private Context _context;
            #endif
    
            string FlurryKey;
    
    
            public Analytics(FlurryKey)
            {
                this.FlurryKey = FlurryKey;
    
                #if __IOS__
                FA.Flurry.StartSession (this.FlurryKey);
                #endif 
    
            }
    
            #if __ANDROID__
            public void EndSession(Context context)
            {
                Flurry.OnEndSession(_context);
            }
    
            public void SetContext(Context context)
            {
                _context = context;
                Flurry.OnStartSession(_context, this.FlurryKey);
                this.CheckOnline ();
            }
            #endif
    
    
            public void LogEvent(string eventToLog)
            {
    
                    #if __IOS__
                        FA.Flurry.LogEvent(string.Format(eventToLog));
                    #endif 
                    #if __ANDROID__
                        Flurry.LogEvent(eventToLog);
                    #endif
            }
    
            public void LogPage(string pageName)
            {
    
                    #if __IOS__
                        FA.Flurry.LogPageView (); 
                    #endif 
                    #if __ANDROID__
                        Flurry.OnPageView();
                    #endif
            }
        }
    }
    

    then within the app, I simply call e.g. in my main application class something like;

    using System;
    using Android.App;
    using Android.Content;
    using Android.Runtime;
    using Android.Views;
    using Android.Widget;
    using Android.OS;
    using MyApp.Core;
    
    namespace MyApp.Droid
    {
        [Application]
        public class MainApp : Application
        {
            Analytics analytics = null; //Doesn't exist as a Service yet so can't reslve it
    
            public MainApp(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
            {
    
            }
    
            public override void OnCreate()
            {
                base.OnCreate ();
    
    
                analytics =  new Analytics("MYFLURRYKEY");
    
                analytics.SetContext (this);
    
                analytics.LogEvent ("Running");
    
            }
    
            protected override void OnStop()
            {
                base.OnStop();
                analytics.EndSession(this);
            }
    
        }
    
    }
    

    Hope that makes sense

  • ScottDavisScottDavis USMember ✭✭
    edited August 2014

    Dang. My steps match yours. I'm going to try to make a sandbox simplify the test.

    Perhaps it is the newest Flurry jar. I had to use this in my Metadata.xml to get the link binding project to build. The obfuscated jar creates other problems otherwise. Maybe this is part of the problem.

    lt;remove-node path="/api/package[@name='com.flurry.sdk']" /gt;

    Thanks for the help Andy.

  • AndyFlisherAndyFlisher GBBeta, University ✭✭✭

    Hmm, odd, if you have no joy let me know and I'll share the jar and binding I'm using

  • mattleibowmattleibow ZAXamarin Team Xamurai

    Hi @ScottDavis‌ and @AndyFlisher‌

    There is now a Flurry NuGet:
    https://www.nuget.org/packages/Flurry.Analytics/

    And a portable version:
    https://www.nuget.org/packages/Flurry.Analytics.Portable/

    The full code is on GitHub:
    https://github.com/mattleibow/Flurry.Analytics

    I recently added Unified support and updated to the latest libraries.

  • IlyaChernetskiyIlyaChernetskiy RUMember
    edited February 2015

    Hey @mattleibow !

    I've tried your lib from github with our unified app and I've got this error

    Error MT5211: Native linking failed, undefined Objective-C class: OBJC_CLASS$Flurry. If '_OBJC_CLASS$_Flurry' is a protocol from a third-party binding, please check that it has the [Protocol] attribute in its api definition file, otherwise verify that all the necessary frameworks have been referenced and native libraries are properly linked in. (MT5211)

    I've tried these workarounds
    http://forums.xamarin.com/discussion/16489/new-type-registrar-in-xamarin-ios-7-2-1-errors-mt5210-and-mt5211
    but it's still didn't work for me :(

  • mattleibowmattleibow ZAXamarin Team Xamurai
    edited February 2015

    Hi @IlyaChernetskiy,

    I had a look at this error, but was unable to reproduce it.
    I am building the sample in the FlurryAnalytics/samples/Flurry.Analytics.iOS.Sample-unified, and I get no errors.

    Could you maybe provide a few extra details on what version you are using?

    You can also try the NuGet: https://www.nuget.org/packages/Flurry.Analytics
    This has all the compiled assemblies that you will need. Version 1.1.1.2 has been reported to work on all platforms.

Sign In or Register to comment.