Google Analytics Integration

Hello everybody !

I reacently wanted to integrate Google Analytics with SDKBOX but I have a lot of problem.
I’m new to cocos but I work on a project already started.
I use cocos from source so I had to put the .jar in cocos2d/cocos/platform/android/java/libs.

I read the “installation_guide.pdf” but i dont realy understand some point.

meta-data in AndroidManifest.xml

@integer/google_play_services_version

where is the file ? i get this error :

Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version'). 

project.properties

document say’s an exemple of what it look like :

android.library.reference.1= ./android/sdk.latest/extras/google/google_play_services/libproject/google-play-services_lib

but I already have :

android.library.reference.1=../cocos2d/cocos/platform/android/java

even after install the google play services.

Game code to invoke Google Analytics

 #include "PluginGoogleAnalytics/PluginGoogleAnalytics.h"

I don’t understand why I get a :

PluginGoogleAnalytics/PluginGoogleAnalytics.h: No such file or directory

my Android.mk is ok imo.

Any help ?

Sure. You probably need to download Google Play. Use the sdk installer and choose extras-> Google Play Services.

For project.properties this path is to where your Google Play lives after installed. This path given is just an example. @nite. What does someone do if they already have an android.library.reference.1=?

Invoking: Did you drop in the jars and JNI folders? Added PluginGoogleAnalytics.h to LOCAL_SRC_FILES?

Perhaps pasting in your Android.mk would be good for us to see.

If you already have

android.library.reference.1

you can use

android.library.reference.2

and so on

Integrated the sdk today and finally managed to get to building the app. The information in the sdk documentation is unhelpful in certain areas.

  1. Install google play services from the android sdk manager.
  2. add path to google play services lib in project.properties as android.library.reference.2 = <path>
  3. Copy the file PluginGoogleAnalyticsJS_api.js from plugins/jsbindings/api to your projects src/ folder and also add it to your project.json.
  4. Do not copy paste the onResume() , onPause() and onActivityResult(arguments) in the Cocos2dxActivity.java file from the docs, but rather just add PluginWrapper.onResume(), PluginWrapper.onPause() in the respective existing functions (otherwise there are errors during compile as there are already protected overridden functions for the same)
  5. Create a file at frameworks/runtime-src/proj.android/res/xml/global_tracker.xml to insert the global tracker config data mentioned in the docs.
  6. Copy paste the *.jar files to frameworks/js-bindings/cocos2d-x/cocos/platform/android/java/libs/ rather than the place mentioned in the docs.
  7. Replace the SDKBoxJSHelper.cpp and SDKBoxJSHelper.h files with the one provided by the commenter here - Chartboost compilation fails - (actual github gist - https://gist.github.com/darkdukey/5b2b8dc4542243dbd5c2 ).
  8. +$(call import-module, ./PluginGoogleAnalytics) instead of -$(call import-module, ./plugingoogleanalytics) in the Android.mk file.

I’m sorry if this seems a little haphazard but the list has been compiled by going over git log changes as new errors were encountered and presumably fixed.

I still have to send actual events to test whether the whole thing works at all. It compiles at least. The only thing i am still unsure about is the capitalization of pluginsgoogleanalytics. My final compiling code has the word in camel case because the folder in which the header file resides is in camel case.

Thanks for providing a detailed feedback, can you tell me which version of cocos2d-js are you using, I’m trying to fix the SDKBoxJSHelper.h for the bundle.

Cocos2d JS 3.6

I think android ndk ignores the case, so it’s fine

Don’t do that… it will make PluginGoogleAnalytics useless. we provide this file so you can have code completion in case you’re using cocos code ide.

But then sdkbox is undefined. :frowning:

adb logcat gives that error and game fails to load.

Sorry, you need to call this in your AppDelegate.cpp

sc->addRegisterCallback(register_all_PluginGoogleAnalyticsJS);

Hey thanks! It seems to be working now. Logcat showed these messages ->
D/PluginFactory(28114): Java class name of plugin PluginGoogleAnalytics is : org/cocos2dx/plugin/PluginGoogleAnalytics I/PluginWrapper(28114): class name : ----org/cocos2dx/plugin/PluginGoogleAnalytics----

I hope they aren’t anything beyond just logging messages. (Emacs shell colored the first statement red for some reason :stuck_out_tongue:)

It’s just debug and info messages.

You see the first character at the beginning of the lines?
They mean the follwoing:.

V — Verbose (lowest priority)
D — Debug
I — Info
W — Warning
E — Error
F — Fatal
S — Silent (highest priority, on which nothing is ever printed)

Hey, thanks a lot for all the help :smile:

I put the PluginGoogleAnalytics.h in the Classes folder and it’s work.

I managed to compile with GoogleAnalytics sdkbox, but now my Device won’t install the apk

INSTALL_FAILED_NO_MATCHING_ABIS

Greetings everyone,

I’m new to SDKBOX, and I’m currently trying to implement Google Analytics (GA) and Vungle into my Cocos2d-x game. Unfortunately, none of them works and I’ve made the necessary changes to my codes according to the installation guides of GA and Vungle. I’d like to ask: Do GA and Vungle automatically work if every step in the installation guides are followed? If I just follow the guides, what is the result I’m expecting when I build and run the game? I’m using Visual Studio 2012, Cocos2dx version 2.2.6 and Eclipse Juno 4.2.0 to develop the Android game.

Thank you.

It depend, I had a lot of trouble to install GA.
Try to read all the Integration help topic, maybe your issue is already in it.

@DuncanTeckHean

Can I ask you to follow a new installation guide for Vungle and GA? We have made many refinements. We also have a new version, 1.1 coming out tomorrow. I’d also like to as you to try it.

I have attached the latest install documents.

Archive.zip (385.5 KB)

I am not an expert Android developer, but perhaps this can help: http://stackoverflow.com/questions/24572052/install-failed-no-matching-abis-when-install-apk

Thank you for the response. However, for the Vungle installation guide Part 3.3 Showing Ads (page 6), I do not understand this line:

sdkbox::PluginVungle::show("<AD_NAME>");

What “AD_NAME” should I insert as parameter? Is it “incentivized” or “interstitial”? Or is it other ad name? Sorry, I am a beginner in Vungle and ad implementation.

take a look at sdkbox_config.json and see what they are called.

A typical setup is similar to this:

"Vungle" :
{
    "id":"<vungle id>",
    "ads":{
        "video":{

        },
        "reward":{
            "incentivized" : true
        }
    }
}

So you would use video and/or reward for <Ad_NAME>. I will make a change to this doc that specifically states these two. It will get published today alongside the new 1.1 bundles.

Thanks for your response, slackmoehrle. Unfortunately, I still could not run my game on Eclipse because it could not find any attached source/javadoc in the cocos2dx library for the PluginWrapper.java. I would like to ask on whether JNI, EasyNDK and/or other libraries are involved in the implementation of Vungle and Google Analytics? Or I just have to follow ONLY the steps prescribed in the installation guide?