BlueRiverInteractive / robovm-ios-bindings

[Deprecated] New bindings: https://github.com/robovm/robovm-robopods. A collection of third party bindings for RoboVM iOS
Apache License 2.0
162 stars 101 forks source link

Google Analytics missing sample & possibly not working #48

Closed jpancik closed 9 years ago

jpancik commented 10 years ago

Hello,

I have a problem with google analytics. My tracking code is not sending any data (tested with realtime and also checked on the next day). It worked in previous versions and I have updated my libs properly.

As there is no sample to check against, I will post my code here and if I'm doing something wrong please point it out. Maybe somebody could share their working tracking code?

Thanks.

public class IOSAnalyticsClient implements GoogleAnalyticsClient {
    private String id;

    private GAIDefaultTracker tracker;

    public IOSAnalyticsClient(String id) {
        this.id = id;
    }

    @Override
    public void startSession() {
        GAI.getSharedInstance().setDryRun(false);
        GAI.getSharedInstance().setDispatchInterval(20.0);

        tracker = GAI.getSharedInstance().getTracker(id);
    }

    @Override
    public void stopSession() {
        try {
            tracker.dispose();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

    @Override
    public void trackEvent(String category, String action, String label, long value) {
        tracker.send(GAIDictionaryBuilder.createEvent(category, action, label, NSNumber.valueOf(value)).build());
    }

    @Override
    public void trackPageView(String name) {
        tracker.set("kGAIScreenName", name);
        tracker.send(GAIDictionaryBuilder.createAppView().build());
    }

    @Override
    public void trackTiming(String category, long timeInMilliseconds, String name, String label) {
        tracker.send(GAIDictionaryBuilder.createTiming(category, NSNumber.valueOf(timeInMilliseconds), name, label).build());
    }

    @Override
    public void trackException(String description, Throwable t, boolean fatal) {
        tracker.send(GAIDictionaryBuilder.createException(description, fatal).build());
    }

    @Override
    public void dispatch() {
        //System.out.println("dispatching");
        GAI.getSharedInstance().dispatch();
    }
}
Don-F commented 9 years ago

EDIT: I've fixed the problem by creating my own jar from the corrected analytics classes. It works fine now. I can share the jar if anybody needs (though no idea what's the best way to share such file).


Hey guys, sorry to unearth this old discussion but I am currently having the exact same problem. Here is what I've tried:

I guess it comes from a gradle or robovm seting or property but I have no idea which one. Anybody has an idea? Otherwise, anybody could point me to a .jar for analytics? That would solve my problem too.

AgrarPirat commented 9 years ago

@marcinjakubowski, thank you for the fix. I've added it and the app compiles and runs just fine. The only problem is that Google Analytics does not receive any events. I suppose it's because the Google Analytics native library (libGoogleAnalyticsServices.a) is still missing. Just a guess though, but how can it be added to the project? Whats the right way to ensure it's getting picked up by roboVM? Any advice how to get it running is welcome. Thank you.

ollyde commented 9 years ago

I'm having the same issue, using LibGDX jar. Still not working :-1:

perchi commented 9 years ago

Me too! :-1:

zfmbek commented 9 years ago

Can anyone share the corect *.jar file (for libgdx) of @marcinjakubowski fixed version?

thanks in advance

zfmbek commented 9 years ago

@Don-F Can anyone share the corect *.jar?

BleedObsidian commented 9 years ago

Here is the compiled and working jar containing @marcinjakubowski fix. Download (Dropbox): https://www.dropbox.com/s/n6p7qrns5qetia7/Google-Analytics-Binding_Fix.jar?dl=0

zfmbek commented 9 years ago

@BleedObsidian Thank you

rotter commented 9 years ago

Has anyone managed to use Google Analytics on current RoboVM version? Since a couple RoboVM updates it doesnt run anymore for me (crashes game on start).

On Sun, Jun 21, 2015 at 5:27 AM, zfmbek notifications@github.com wrote:

@BleedObsidian https://github.com/BleedObsidian Thank you

— Reply to this email directly or view it on GitHub https://github.com/BlueRiverInteractive/robovm-ios-bindings/issues/48#issuecomment-113876497 .

BlueRiverInteractive commented 9 years ago

The Google Analytics bindings are deprecated. Please use the new iOS RoboPod for Google Analytics: https://github.com/robovm/robovm-robopods. Essentially you only need to add a maven or Gradle dependency to your robovm project, like:

org.robovm:robopods-google-analytics-ios:1.0.0-SNAPSHOT

or

<dependency>
   <groupId>org.robovm</groupId>
   <artifactId>robopods-google-analytics-ios</artifactId>
   <version>1.0.0-SNAPSHOT</version>
</dependency>

If you find any issues with the robopods, please post in the respective repository. Thanks