我正在尝试在 Kivy 上安装 AdMob。我成功导入 AdRequest 但无法创建其实例。
AdRequest = autoclass("com.google.android.gms.ads.AdRequest")
print "AdRequest: ", AdRequest
print dir(AdRequest)
在 logcat 中,我可以通过 dir() 看到 AdRequest 的属性和方法:
AdRequest <class 'jnius.reflect.com.google.android.gms.ads.AdRequest'>
['DEVICE_ID_EMULATOR', 'ERROR_CODE_INTERNAL_ERROR', 'ERROR_CODE_INVALID_REQUEST',
'ERROR_CODE_NETWORK_ERROR', 'ERROR_CODE_NO_FILL', 'GENDER_FEMALE', 'GENDER_MALE',
'GENDER_UNKNOWN', 'MAX_CONTENT_URL_LENGTH', '__class__', '__cls_storage',
'__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__',
'__init__', '__javaclass__', '__javaconstructor__', '__module__', '__new__',
'__pyx_vtable__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
'__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'equals', 'getBirthday',
'getClass', 'getContentUrl', 'getCustomEventExtrasBundle', 'getGender', 'getKeywords',
'getLocation', 'getNetworkExtras', 'getNetworkExtrasBundle', 'hashCode',
'isTestDevice', 'notify', 'notifyAll', 'toString', 'wait']
AttributeError: type object 'com.google.android.gms.ads.AdRequest' has no attribute
'Builder'
Python for android ended.
我找不到 Builder 方法 https://developer.android.com/reference/com/google/android/gms/ads/AdRequest.html 这是构建 AdRequest 的类方法