admobtitaniumtitanium-sdk

How to use ti.admob with Android App ? Example not working


I am trying to use the Ti.admob module in a simple Android app. I downloaded it and try to run the example code.

Found here : https://github.com/appcelerator-modules/ti.admob/tree/master/android/example

I added this in tiapp.xml

        <application>
            <activity android:configChanges="keyboardHidden|orientation" android:theme="@android:style/Theme.Translucent"/>
            <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-YYYYYYYYYY~XXXXXXXXX"/>
        </application>

and in the example file :

/ then create an adMob view
var adMobView = Admob.createView({
    publisherId:"ca-app-pub-YYYYYYYYYY~XXXXXXXXX",
    adUnitId:"ca-app-pub-3940256099942544/6300978111",
    testing:false, // default is false
    //top: 10, //optional
    //left: 0, // optional
    //right: 0, // optional
    bottom: 0, // optional
    adBackgroundColor:"FF8855", // optional
    backgroundColorTop: "738000", //optional - Gradient background color at top
    borderColor: "#000000", // optional - Border color
    textColor: "#000000", // optional - Text color
    urlColor: "#00FF00", // optional - URL color
    linkColor: "#0000FF" //optional -  Link text color
    //primaryTextColor: "blue", // deprecated -- now maps to textColor
    //secondaryTextColor: "green" // deprecated -- now maps to linkColor

});
//listener for adReceived
adMobView.addEventListener(Admob.AD_RECEIVED,function(){  // alert("ad received");   
    Ti.API.info("ad received");
    });
//listener for adNotReceived
adMobView.addEventListener(Admob.AD_NOT_RECEIVED,function(){    
//alert("ad not received");     
Ti.API.info("ad not received");});

win.add(adMobView);

ALl seems to be ok when trying to launch it on the phone but there's an error in the log :

[ERROR] : FA: GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.

Anyone has a valid sample for appcelerator using admob in an android App ?

Thanks


Solution

  • I found the solution

    In Publisher ID, you have to put the adUnitId !!! and not the publisher id !!

    var adMobView = Admob.createView({ publisherId:"ca-app-pub-YYYYYYYYYY~XXXXXXXXX", adUnitId:"ca-app-pub-3940256099942544/6300978111",