【发布时间】:2019-11-17 11:41:09
【问题描述】:
我正在尝试在一个简单的 Android 应用程序中使用 Ti.admob 模块。 我下载了它并尝试运行示例代码。
在这里找到:https://github.com/appcelerator-modules/ti.admob/tree/master/android/example
我在 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>
在示例文件中:
/ 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);
尝试在手机上启动它时似乎一切正常,但日志中有错误:
[错误] : FA: GoogleService 初始化失败,状态:10,缺少来自名称为 google_app_id 的字符串资源的 google 应用 ID 值。
任何人都有一个在 android 应用中使用 admob 的 appcelerator 的有效示例?
谢谢
【问题讨论】:
标签: admob titanium appcelerator titanium-mobile