kivmob不会在Android应用程式python kivy中显示广告 [英] kivmob doesn't show ads in android app python kivy

查看:78
本文介绍了kivmob不会在Android应用程式python kivy中显示广告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的应用中添加广告.我添加了我的buildozer.spec:

I try to add ads in my app. I added in my buildozer.spec:

android.permissions = INTERNET, ACCESS_NETWORK_STATE
requirements = python3,kivy, jnius, kivmob
android.api = 28
android.minapi = 21
android.sdk = 24
android.ndk = 19b
android.gradle_dependencies = 'com.google.firebase:firebase-ads:10.2.0'
p4a.branch = master
android.meta_data = com.google.android.gms.ads.APPLICATION_ID=#here id of my app

我有代码:

from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivmob import KivMob
class TestApp(App):
    def build(self):
        try:
            fl = FloatLayout()
            self.ads = KivMob('')#here my app
            self.ads.add_test_device(here my id)
            self.ads.new_banner('', top_pos=True)#here my banner
            self.ads.request_banner()
            self.ads.show_banner()
        except Exception as error:
            fl.add_widget(Label(text=str(error), font_size=(30)))
        return fl
    def on_resume(self):
        self.ads.request_banner()

if __name__ == '__main__':
    TestApp().run()

当我启动此应用程序时,我看到黑屏,什么也没有.我期望横幅.如何解决?我希望你能帮助我

when I start this app, I see black screen and nothing else. I expected banner. How to fix it? I hope you help me

更新: 如果我使用TestIds.APPTestIds.BANNER,则可以正常工作并显示广告.为什么会发生?如何使用真实的广告横幅?

UPDATE: if I use TestIds.APP and TestIds.BANNER it works and shows ad. Why does it happen? How to use real ad banner?

推荐答案

因此,首先在buildozer.spec中的要求中添加android. android.api = 28

So firstly add android in requirements in buildozer.spec. android.api = 28

是的,使用TestIds可以将广告显示在任何设备上,因为它们是Google的示例广告.

Yes using TestIds provide ads to be displayed on any device because they are sample ads by google.

但是,当您使用自己的广告单元时,您是通过admob帐户创建的. 您必须在代码中提供测试设备ID,以便识别Google您正在测试自己的广告.

But when you are using your own ad units you create from admob account. You have to provide your test device id in your code in order to recognise google that you are testing your own ads.

在构建方法中使用self.ads.add_test_device(YOUR_DEVICE_ID).

Use self.ads.add_test_device(YOUR_DEVICE_ID) in your build method.

您在哪里获得了设备ID 好了,您必须在logcat输出中找到设备ID.

And where did you get your device ID Well you have to find your device id in logcat output.

希望有帮助.

这篇关于kivmob不会在Android应用程式python kivy中显示广告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆