-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Issue Compiling Matplotlib for Android (Buildozer) #3120
Comments
I tried this minimal example: """Basic example for kivy_matplotlib_widget
Note:
MatplotFigure is used when you have only 1 axis with lines only.
For general purpose, please use MatplotFigureSubplot widget.
"""
from kivy.utils import platform
#avoid conflict between mouse provider and touch (very important with touch device)
#no need for android platform
if platform != 'android':
from kivy.config import Config
Config.set('input', 'mouse', 'mouse,disable_on_activity')
from kivy.lang import Builder
from kivy.app import App
import matplotlib.pyplot as plt
import kivy_matplotlib_widget #register all widgets to kivy register
import numpy as np
KV = '''
Screen
figure_wgt:figure_wgt
BoxLayout:
orientation:'vertical'
BoxLayout:
size_hint_y:0.1
Button:
text:"home"
on_release:app.home()
ToggleButton:
group:'touch_mode'
state:'down'
text:"pan"
on_release:
app.set_touch_mode('pan')
self.state='down'
ToggleButton:
group:'touch_mode'
text:"zoom box"
on_release:
app.set_touch_mode('zoombox')
self.state='down'
MatplotFigure:
id:figure_wgt
'''
plt.style.use('dark_background')
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
class Test(App):
def build(self):
self.screen=Builder.load_string(KV)
# Setup plot
self.fig, self.ax1 = plt.subplots()
self.ax1.set(xlabel='time (s)', ylabel='voltage (mV)', title='Test Matplot in Kivy')
self.ax1.grid(alpha=0.5)
return self.screen
def on_start(self, *args):
self.ax1.plot(t, s)
self.screen.figure_wgt.figure = self.fig
def set_touch_mode(self,mode):
self.screen.figure_wgt.touch_mode=mode
def home(self):
self.screen.figure_wgt.home()
Test().run() And compiles without problems with the develop branch of P4A and buildozer 1.5.1.dev0. buildozer.spec: requirements = python3,kivy,numpy,matplotlib,kivy-matplotlib-widget
android.minapi = 24
android.archs = arm64-v8a
p4a.branch = develop
log_level = 2 Final log:
|
Hello, @mriscocThanks for Testing This! 🎉It looks like your build works fine with the develop branch of P4A and Buildozer 1.5.1.dev0.
I'll try switching to the develop branch and updating Buildozer to 1.5.1.dev0 to see if that resolves the issue. Question:Did you need to manually install or modify anything else in your environment, or did it work out of the box after setting Thanks again for your help! 😊 |
📝 Subject: Issue Compiling Matplotlib for Android (Buildozer)
Hey everyone, I'm trying to package my Kivy/KivyMD app for Android using Buildozer,
but it's failing when trying to compile Matplotlib from source.
📌 Issue
Buildozer gets stuck at:
🛠 What I’ve Tried
1️⃣ Added
matplotlib
torequirements
inbuildozer.spec
.2️⃣ Checked dependencies (e.g.,
numpy
,cycler
).3️⃣ Looked for a precompiled Matplotlib
.whl
but couldn’t find one.❓ Questions
1️⃣ Is there a prebuilt Matplotlib wheel for Android that I can use instead of compiling?
2️⃣ If Matplotlib needs to be compiled, what dependencies do I need to include?
3️⃣ Any known workarounds to avoid this issue?
🙏 Any help would be greatly appreciated! Thanks in advance! 😊
The text was updated successfully, but these errors were encountered: