Solution 1 :
I found the solution
the problem was in audio file extension , mp3 files for some reason are not working when I converted the mp3 file to wav extension it worked flawlessly
also wav keyword must be in the buildozer init
Solution 2 :
NoneType means that your function call failed or it returned an unexpected result.
In your case,
self.sound
expects to load the mp3 file and when it is called by self.sound.play()
, the file was either not fetched or it returned an unexpected result
Problem :
import kivy
from kivy.app import App
from kivy.uix.button import Label
from kivy.core.audio import SoundLoader
class HelloApp(App):
def build(self):
self.sound = SoundLoader.load('back.mp3') # open the background music
self.sound.play() # play the sound
return Label(text='>>>>>')
if __name__=="__main__":
HelloApp().run()
this is my code it works fine on linux
but when i try to make apk by buildozer
the app crashes upon start
and the logcat command gives this
[WARNING] [Audio ] Unable to find a loader for <back.mp3>
: Traceback (most recent call last):
: File “/home/moh/audio2/.buildozer/android/app/main.py”, line 15, in
: File “/home/moh/audio2/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myapp/kivy/app.py”, line 829, in run
File “/home/moh/audio2/.buildozer/android/app/main.py”, line 9, in build
AttributeError: ‘NoneType’ object has no attribute ‘play’
Python for android ended.
Comments
Comment posted by fsu870
how can I know what is the problem if it works fine on pc but on android it gives this attribute error
Comment posted by Jimit Vaghela
@fsu870 As I mentioned, the error is generated when the argument is failed to call the function. That is, NoneType of your object, which is loading the .mp3 file from some location. It is not being fetched from that location.