Heyzap Mediation Sdk 9 - Android/eclipse [tutorial]

Discussion in 'Advertising' started by Christoph, Jun 2, 2016.

  1. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    IMPORTANT:
    This tutorial is for SDK 9 (which is not synced with Fyber servers yet). It is recommended by Heyzap to use SDK 9 until SDK 10 is more stable. BUT you have to use for now Buildbox 2.2.7 or earlier. SDK 9 won't work with Buildbox 2.2.8. For 2.2.8 use the SDK 10 by following this tutorial instead!

    I recently implemented Heyzap Mediation into my Android game and thought I'd share with you guys how it's done. If you have other knowledge regarding the implementation of useful third party software please make a tutorial and share it on the forum too. For example, we still need a step by step guide for Tapdaq and Google Analytics.

    Keep in mind, I'm not a coder by any means, so if you have any additional thoughts or changes to the tutorial, let me know and I'll happily update the post. Most of the information I found to make this work is from other threads in this forum (special thanks goes to @Jayson and @jcalle), from the official Heyzap docs and customer support, as well as by googling the specific problem.

    If you want to implement Heyzap Mediation into an iOS game don't post your questions here please. I made a separate tutorial in this thread. This tutorial is for Android only!

    [​IMG]
    MEDIATION SETUP SDK 9 FOR ANDROID
    PART 1

    The unofficial Buildbox Tutorial


    HEYZAP ACCOUNT & SETTING UP YOUR APP
    1. First of all, you need to register for an account on https://www.heyzap.com/register

    2. Then go to your "Dashboard" and choose "All apps" and "+ Claim an App" at the top of the left side panel
    [​IMG]

    3. Click on Android and add your app (if it is not yet in the Play Store, click on adding manually)
    claim.png


    BUILDBOX SETUP
    1. Go to https://developers.heyzap.com/account and copy your Publisher ID
    2. Open your Buildbox project and go to Settings/Advertisements
    3. Select Google Play Store as your Application Store
    4. Paste your Heyzap Publisher ID into the corresponding field
    5. Set up Facebook and AdMob in the Banners Priority List
    6. Click on OK
    advertisment settings.png

    NOTE: Do not set up any other Ad Networks here because we will run everything through Heyzap Mediation. Leave all other IDs blank.

    7. From the Buildbox Flow Chart page, select a box (for example Game Over). Under "Advanced Options" on the right sidebar, choose Heyzap for the "Ad Interstitial" and the "Banner" field. Then set the frequency of the ads and repeat this step for all other menus you want Heyzap Mediation ads to appear (Game Field, Pause Menu, Main Menu).
    Frequency.png

    8. Generate your Android project by selecting File/Export/Android. Ignore the warning from the pop-up and click on "Continue"
    export.png


    HEYZAP 3rd PARTY AD NETWORK SETUP
    1. Go to your Heyzap Dashboard Integration Wizard (https://developers.heyzap.com/integration_wizard)
    (if you have already set up your 3rd party Ad Networks skip to step 6 of this section)

    2. Select the Ad Networks you want to set up and click on “Continue"
    [​IMG]

    3. Choose your App and click on “Continue"
    index.png

    4. Add all your credentials from your 3rd party Ad Networks and click each time on “Continue”.

    Note: you need to register for all Ad Networks and setup your app on each dashboard to get all the information needed. Use different IDs for your Android game than the ones you used for iOS (and vice-versa). To make everything very quick and pain-free, use the links in each section provided by Heyzap. Example:
    admob.png

    5. After adding all your credentials - and as a final step - choose “Android" in the "SDK Integration” tab. A new page opens. Skip the next step in this section of the tutorial (step 6) and go directly to step 7.
    integration.png

    6. If you followed the tutorial up to here you already are on this page but if you came here directly because you already had set up your ad networks before, then browse now to the Android SDK/Setup and Requirements tab from the Heyzap Docs page (or click on this link: https://developers.heyzap.com/docs/android_sdk_setup_and_requirements). Choose manually all the Ad Networks you are going to use.

    7. The doc for "Android SDK Setup" is already adapted to your specific needs. Funny enough, Buildbox took care of a major part and therefore we will ignore almost the entire instructions. So just keep following this tutorial here and you are good to go.

    First we need to scroll down to step 4 in the Heyzap Doc and download all 3rd party SDKs. Note that you can skip AdMob, FBaudience and Heyzap jar files because they are already exported by BB.

    sdks.png

    Leave the browser with the Heyzap Doc open, we will need it later.

    8. Drag the downloaded files into a folder called "Heyzap Bundle Android".
    Note: Vungle is a zip file so unzip it first and copy the three files, including the additional files called dagger-x.jar and javax.inject-.jar.
    Your folder will look something like that:
    libs1.png
    Keep this folder for backup purpose. You will need the files again and again when you update your game or make a new build.
     
    Last edited: Mar 27, 2017
  2. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    [​IMG]
    MEDIATION SETUP FOR ANDROID - PART 2
    The unofficial Buildbox Tutorial

    ECLIPSE SETUP

    1. Open Eclipse

    2. Import your exported Android file by right clicking on the white space from the Package Explorer and choose “import”
    import.png


    3. Then select “Android/Existing Android Code Into Workspace” and click “Next >”.
    import 2.png

    4. Then "Browse…" to your Root Directory of your game (this is the folder you exported from Buildbox) and click on “Finish”. The game gets now loaded into Eclipse. After loading completely there shouldn’t be any errors. If there are you must first setup Eclipse correctly!!!
    Note: Warnings (the yellow sign) are normal
    import 3.png

    5. Click on your game folder (com.yourcompany.yourgame) and unfold the libs folder. It should look like that:
    libs2.png
    (as you can see, the Google Play Services, Facebook and Heyzap are already included)

    6. Now copy all the files from your “Heyzap Bundle Android” folder to the libs folder from Eclipse.
    libs3.png

    A pop-up window appears (File Operation). Select “Copy Files” and click on OK.
    libs5.png
    Note: If you use Vungle, Eclipse will notify you that javax.inject-1.jar already exist. When prompted to overwrite click “Yes”.

    libs4.png

    IMPORTANT: If you use Vungle, you also will notice that you now have two dagger-x.x.x.jar files in the libs folder. Delete the older one (dagger-1.2.2.jar).

    7. Now open the AndroidManifest.xml (double click on it) and go to the Manifest tab (2)
    manifest.png

    As always set up your “Version Code” and “Version Name” (3 & 4).

    Then also choose “Auto” from the Install location drop down (5). Note: this is optional but it allows users to decide where to install the game (on device or SD card) + it adds a new permission (WRITE EXTERNAL STORAGE) which we need anyway for AppLovin, Chartboost, UnityAds or Vungle.

    8. Go to the “AndroidManifest.xml” tab and search for the code <application (it’s the 7th line). Click with your mouse just after it and hit two times enter. Then add this code:
    Code:
    android:hardwareAccelerated="true"
    manifest 3.png

    9. Now scroll down in the AndroidManifest.xml until you find <!-- FACEBOOK SDK -->. This and the following ones are the activities Buildbox already set up but they most probably are not enough. Select everything between Facebook and the last one which should be <!--REVMOB --> , and delete the entire code.

    Example of the code you need to delete:
    manifest 4.png

    10. Leave the mouse cursor in its place and everything open. Then go back to the Heyzap Doc in your browser. In step 5 of the Doc you’ll find the ACTIVITIES you need for your chosen ad networks. Copy the entire code, go back to Eclipse and paste it in the exact same place you left in the step before.
    [​IMG]

    11. For some 3rd party Ad Networks we need to set up new Permissions. To make this happen, scroll even further down in the AndroidManifest.xml till you see this code:
    <uses-permission android:name="android.permission.INTERNET" />

    A)
    If you use AppLovin add this code at the end of the list:
    Code:
    <!-- Required by AppLovin --><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    It will look now like that:
    [​IMG]

    B) If you use AppLovin, Chartboost, UnityAds or Vungle and DID NOT set up “Auto” in step 7 of this section of the tutorial, you also need to add this code in the same way as explained above:
    Code:
    <!-- Required by AppLovin, Chartboost, UnityAds, and Vungle -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    12. This step is not necessary but recommended:
    Go to the Permissions tab and you’ll see that you have now 8 permissions set up. Most players of your game will not like it because they all need to be approved. Therefore, we can delete the ones we don’t need mandatorily. Namely: ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION and READ_PHONE_STATE. Select them and click on “Remove…”
    [​IMG]

    13. This step is very IMPORTANT: Click CMD+S (Mac) or CTRL+S (Windows) to save the Android Manifest. There is a * in front of the name and once you saved the file it will go away. Make sure you save it!!!


    And this is it, you just set up Heyzap Mediation for your Android Game. Export your APK and test on your device.
    Congratulations!!!!
     
    Last edited: Jun 2, 2016
  3. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    ADDITIONAL SETTINGS
    One last thing to consider is to check and adjust the publisher settings in your Heyzap Dashboard.
    Select your app on the top left corner and go the the "Publisher Settings" tab.

    [​IMG]

    Here you adjust how the ads behave.

    In the tab "Mediation Status" (https://developers.heyzap.com/dashboard/mediation_status) you can see if your Ad Networks are set up correctly (green).


    TEST YOUR 3rd-PARTY INTEGRATIONS
    The mediation SDK comes with a Mediation Test Suite that you can use to test each of the networks you've chosen:

    [​IMG]

    The first screen lets you isolate a network to test its integration with the Heyzap SDK. Once you choose a network, you'll see if:
    1. The network is installed correctly.
    2. The network has valid credentials on your dashboard.
    3. The network is enabled on your dashboard.
    To use the Mediation Test Suite you need to call the TestActivity method after starting the SDK:

    1. Go to com.yourcompany.yourgame/src/com.secrethq.ads/ and open "PTAdHeyzapBridge.java" with a double click


    testsuite.jpg

    2. Scroll down (approximately 2/3rd of the file) and search for this code:
    public static void startSession( String sdkKey ){

    3. After the start activity hit enter and paste this code:
    Code:
    HeyzapAds.startTestActivity(PTAdHeyzapBridge.activity);

    It will look like that:
    testsuite2.png

    4. Click CMD+S (Mac) or CTRL+S (Windows) to save the PTAdHeyzapBridge.java file.

    5. Export your APK and test on your device

    IMPORTANT: This code should be used for testing purpose and is for temporary use only. Once everything is working as it should, delete the code again, save the PTAdHeyzapBridge.java file and export a new build of your APK. Do NOT upload any build with the code enabled to the Play Store!!!


    DON'T HAVE AN ANDROID DEVICE?
    If you don't have an Android device you can use a simulator instead. The best one I have found is available here: http://www.droid4x.com/ for PC and Mac! Everything can be tested in this simulator, from Game Services to the ads up to the game-play itself.
     
    Last edited: Jun 2, 2016
  4. wesam_badr

    wesam_badr Miniboss Boxer

    Joined:
    Oct 10, 2015
    Messages:
    1,065
    Likes Received:
    479
  5. heathclose

    heathclose Miniboss Boxer

    Joined:
    Jan 28, 2016
    Messages:
    1,810
    Likes Received:
    1,026
    no doubt, awesome stuff
     
  6. jaoultimate

    jaoultimate Boxer

    Joined:
    Mar 24, 2016
    Messages:
    23
    Likes Received:
    1
    Thank for your tutorial. Can you make another tutorial about video reward?
     
  7. Arsmen Studio

    Arsmen Studio Avid Boxer

    Joined:
    Dec 6, 2015
    Messages:
    454
    Likes Received:
    170
  8. tarasgasparin

    tarasgasparin Boxer

    Joined:
    Sep 25, 2015
    Messages:
    46
    Likes Received:
    19
    @Christoph thanks for that! You save me a lot of time! Hope i can help you in something one day! ;)
     
    Christoph likes this.
  9. mikafabz

    mikafabz Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    100
    Likes Received:
    172
    GREAT... thanks a lot! Really appreciate!!
     
    Christoph likes this.
  10. heathclose

    heathclose Miniboss Boxer

    Joined:
    Jan 28, 2016
    Messages:
    1,810
    Likes Received:
    1,026
    This has gone Epic.... Thanks for the all the leg work @Christoph
     
    Christoph likes this.
  11. jcalle

    jcalle Miniboss Boxer

    Joined:
    Sep 25, 2015
    Messages:
    1,196
    Likes Received:
    543
    Hello, great job.
    Tutorials like these would have to be in a unique forum.
     
    tarasgasparin likes this.
  12. Brocky120

    Brocky120 Avid Boxer

    Joined:
    May 2, 2016
    Messages:
    127
    Likes Received:
    27
    My androidmanifest.xml spits the dummy out when I paste the activities into it......
     
  13. Two Frogs

    Two Frogs Boxer

    Joined:
    May 27, 2016
    Messages:
    14
    Likes Received:
    12
    Christoph likes this.
  14. jaoultimate

    jaoultimate Boxer

    Joined:
    Mar 24, 2016
    Messages:
    23
    Likes Received:
    1
    Hi @Christoph, i do as your tutorial but i got this problem :
    [​IMG]
    [​IMG]
    [​IMG]
    Do you know what am i missing?
     
  15. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    I suppose that network refers to your wifi network. Basically ou don't have Internet. This could be a) you are using an adblocker or b) you didn't set the network permission. Have you checked both?
     
  16. jaoultimate

    jaoultimate Boxer

    Joined:
    Mar 24, 2016
    Messages:
    23
    Likes Received:
    1
    I didn't use adblocker and i have set the network permission. The others ads network like admob, revmob, chartboost work fine but when i change to heyzap, i got this problem.
    PS: The Problem is solved, i add wrong package name on Heyzap.
    Thank for tutorial :).
     
    Last edited: Aug 7, 2016
  17. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    The first screenshot shows Chartboost which is not working. Did you set up other networks from within Buildbox? If yes, try another build without. Only use Heyzap ID in Buildbox.
     
  18. Jaky1

    Jaky1 Serious Boxer

    Joined:
    Aug 22, 2016
    Messages:
    523
    Likes Received:
    142
    @Christoph

    I am now getting this error when I am trying for the second time:

    Look at the red error: The Apk is not compiling..The outofbounds exception???? what is this??

    Furthermore I did it correctly for the first time, but not one ad was showing not reward nothing..What should I do Screenshot (16).png
     
  19. Cristian

    Cristian Avid Boxer

    Joined:
    Aug 1, 2016
    Messages:
    143
    Likes Received:
    27
    Hi @Christoph

    Really nice job here. I followed each step and have some issues if you have 2 min to point me in the right direction, it should be easy for you since you did this already, 1st time here.

    1. I created account for applovin, heyzapp, vungle.
    2. Copy pasted app ids and and signatures for each.
    3. Added the test SDK code for testing the ads. The screenshots from step 3 for testing how did you get there? Are those opening once you opened the app? Or is an app that will test that need to be installed?
    4. For some reason I have under Reporting Status all 3 with green on heyzapp dashboard but in the app nothing happens :/. Also the buttons that should be for continue after user died ( is set as heyzapp video) did not show. Neither the ads after 2 deaths. Set it to 2 for testing purposes.

    Any input will be a huge help,
    C
     
  20. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    What step 3? Sorry if I didn't get you.
     

Share This Page