Integrate AdMob in Android code ported from Xcode and C++

  • abhishek
    Likes 0

    Problem Description

    Hi Sonar Systems,
    I checked out the following 2 tutorials on your channel:
    Video 1 - C++ | iOS Cocos Helper - Setting Up AdMob https://www.youtube.com/watch?v=9Ei8tAs22DI
    Video 2 - JavaScript | Android Cocos Helper - Setting Up AdMob https://www.youtube.com/watch?v=nfN3wQBcZPQ

    These 2 videos are really helpful, but the first video focuses on iOS and C++ whereas the second video focuses on Android and JavaScript.
    I always work in C++ and so i port my Xcode project to Android using the build_native.py command. 
    My requirement is that I want to integrate ads only in this Android version that I imported, but my original project is on C++.

    So I know that Video 1 is not of help for what I need.
    Video 2 is related to my requirement, but the base project itself is in JavaScript. 

    So can you help me out with integrating AdMob in Android, but for a project that has been created in C++?
    I really need to implement this feature, please help me out.
    Thanks
     

  • abhishek
    Likes 0

    Hi Sonar Systems,
    Thank you so much for the above video link. This is exactly what I needed.
    I followed both the tutorials (Initial Setup and AdMob Integration).  

    I implemented it on the Mac using Xcode and Eclipse (so whenever i had to add files etc.. i did it in Xcode and then ran the build_native command to ensure that my project was updated).

    BUT I AM NOT ABLE TO RUN THE APP AT ALL ON ANY ANDROID DEVICE!
    When I build the app and try to run it on a device, i reach the stage where Eclipse installs the APK file on the device.
    But then, I simply get a message box on the android device saying - the app has stopped (the app does not start at all.. i directly get the pop-up message).

    I dont know what went wrong..
    I have sent you the screenshot of the LogCat and also request you to take a look at image 3.. why is the system trying to search for MoPubAds?

    Please help me out with this. I think I am almost there, but I dont exactly know whats wrong.
    Thanks
     


    This reply has been verified.
  • Sonar Systems admin
    Likes 0

    Does a fresh project work on Android?

  • abhishek
    Likes 0

    Hi SS,
    I am very sorry.. it was my mistake.. actually.. the settings file that you ask us to copy paste.. (where we set ad_mob = true/false and rev_mob = true/false etc)
    in that, the mopub part was set to true by default.. so i just changed it back to false and the code is working now.

    I only want to show interstitial ads in my app..
    But i am not getting any ad displayed when i trigger the event

    THIS IS WHAT I GET IN THE LOG:

    07-09 18:08:50.816: I/Ads(27485): Starting ad request.
    07-09 18:08:50.821: I/Ads(27485): Use AdRequest.Builder.addTestDevice("A9922A5932FED1A5CFA9587E4A07A684") to get test ads on this device.
    07-09 18:08:50.876: W/Ads(27485): There was a problem getting an ad response. ErrorCode: 2
    07-09 18:08:50.896: W/Ads(27485): Failed to load ad: 2

    Now since i want to show fullscreen ad, where do i put this test device id?
    Because this id is to be used only for banner ads right?

    Can you please help.
    Thanks

    EDIT: I just confirmed that I have entered the right ad id.. so there is no mistake in the id that has been entered. There are no unwanted spaces either.


     


  • abhishek
    Likes 1

    Hi SS,
    Thank you.. thank you.. thank you..
    I finally got it working.. and the app is running perfect.. and even the ads are being showed properly !!
    You guys are really helping us a lot..
    :)

  • Sonar Systems admin
    Likes 0

    Your very welcome :D

Login to reply