Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot call instance method 'addContentView' on class 'org/kivy/android/PythonActivity' #116

Open
zuku7 opened this issue Jul 24, 2022 · 9 comments
Assignees
Labels

Comments

@zuku7
Copy link

zuku7 commented Jul 24, 2022

Hi,
I try to integrate my Kivy app with AdMob using KivMob, however so far I'm not able even to successfully run demo app. Application runs, but no ads are shown and following error is thrown in logcat:

python  : [INFO   ] [GL          ] NPOT texture support is available
python  : [INFO   ] [KivMob      ] __init__ called.
python  : [INFO   ] [KivMob      ] Android platform detected.
python  : [INFO   ] [KivMob      ] new_banner() called.
python  : [INFO   ] [KivMob      ] new_interstitial() called.
python  : [INFO   ] [KivMob      ] request_banner() called.
python  : [INFO   ] [KivMob      ] request_interstitial() called.
python  : [INFO   ] [KivMob      ] set_rewarded_ad_listener() called.
python  : [INFO   ] [KivMob      ] load_rewarded_ad() called.
python  : [WARNING] [Base        ] Unknown <android> provider
python  : [INFO   ] [Base        ] Start application main loop
python  :  Traceback (most recent call last):
python  :    File "/home/zuku/projects/KivMob/demo/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/kivmob/armeabi-v7a/android/runnable.py", line 38, in run
python  :    File "/home/zuku/projects/KivMob/demo/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/kivmob/armeabi-v7a/kivmob.py", line 217, in new_banner
python  :    File "jnius/jnius_export_class.pxi", line 844, in jnius.jnius.JavaMethod.__call__
python  :  jnius.jnius.JavaException: Cannot call instance method b'addContentView' on class b'org/kivy/android/PythonActivity'
python  : [INFO   ] [KivMob      ] onRewardedVideoAdLoaded() called.

There's one thing I had to change in buildozer.spec - I updated android.ndk version to 23. For 19b buildozer immediately crashes with error:

[ERROR]: Build failed: The minimum supported NDK version is 23. You can download it from https://developer.android.com/ndk/downloads/.

Can this be the reason?

@konsvoulgaris
Copy link

I also have the same problem.

@arncode90
Copy link

Same error happened to me..
Any solution?

: [INFO ] [KivMob ] init called.
: [INFO ] [KivMob ] Android platform detected.
: [INFO ] [KivMob ] new_banner() called.
: [INFO ] [KivMob ] request_banner() called.
: Traceback (most recent call last):
: File "/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/testsapp22/arm64-v8a/android/runnable.py", line 38, in run
: File "/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/testsapp22/arm64-v8a/kivmob.py", line 217, in new_banner
: File "jnius/jnius_export_class.pxi", line 844, in jnius.jnius.JavaMethod.call
: jnius.jnius.JavaException: Cannot call instance method b'addContentView' on class b'org/kivy/android/PythonActivity'

@MichaelStott
Copy link
Owner

Will try to find some time to look into this, it may be that these methods have changed or are no longer supported.

@MichaelStott MichaelStott self-assigned this Jul 31, 2022
@konsvoulgaris
Copy link

Any solution found?

@MichaelStott
Copy link
Owner

Not at the moment, haven't been able to make time for this project as of recently. Will try to make time this weekend.

@zuku7
Copy link
Author

zuku7 commented Aug 20, 2022

Through trial and error I was able to make KivMob working in my app. Basically all I had to do was change line 261 (new_banner method) from:
activity.addContentView(layout, layoutParams)
to
activity.mActivity.addContentView(layout, layoutParams)
According to the docs mActivity is the instance of the current Activity, however I'm not familiar with Pyjnius at all so I cannot tell if anything was changed there recently.

Problem seems to be related only to the banner, other ads work for me without any modifications.

@ElMastro
Copy link

Greetings,
I am experiencing the same Issue on Kivmob 2.0.
Unfortunately, changing 'activity.addContentView(layout, layoutParams)' (that in this kivmob.py it is on line 217) doesn't solve anything.
Maybe someone could share some suggestion, please?

@ElMastro
Copy link

ElMastro commented Dec 7, 2022

According to this the commands work. The problem I was talking about could depend upon having an Admob account linked to the app.

May someone please confirm it?

@ElMastro
Copy link

If someone is interested I have created an Admod account, and now the error messages disappeared. Unfortunately the banners still don't work, but at this point I don't know if this depend on the application itself or on the admod account (which settings seems incredibly difficult to me)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants