My application does not display in full screen on android - android

I want to display my application on my samsung A13 phone in full screen mode. However, no matter what I do, it doesn't want to: the phone's time and navigation system remain visible. I use Buildozer on Ubuntu Mate 20.04 to compile kivy in apk file .
I have tried :
from kivy.config import Config
Config.set('graphics', 'width', '491')
Config.set('graphics', 'height', '1000')
Config.set('graphics', 'resizable', '0')
Config.set('graphics', 'borderless', '1')
Config.set('graphics', 'fullscreen', 'True')
On my pc the display is full screen, on my phone not.
from kivy.config import Config
Config.set('graphics', 'width', '491')
Config.set('graphics', 'height', '1000')
Config.set('graphics', 'resizable', '0')
Config.set('graphics', 'borderless', '1')
from kivy.core.window import Window
Window.fullscreen = True
It bugs my pc and the application is not visible. On my phone no visible effect.
How to display in full screen mode my application on android?

Related

jnius.find_javaclass , jnius.JavaException: Class not found 'android/webkit/WebView'

I am getting this error while trying to use jnius's autoclass to get the android webview inside Kivy app. What could be the fix?
Thanks
My code looks like this:
import kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.utils import platform
from kivy.uix.widget import Widget
from kivy.clock import Clock
from jnius import autoclass
#from android.runnable import run_on_ui_thread
WebView = autoclass('android.webkit.WebView')
WebViewClient = autoclass('android.webkit.WebViewClient')
activity = autoclass('org.renpy.android.PythonActivity').mActivity
class Wv(Widget):
def __init__(self, **kwargs):
super(Wv, self).__init__(**kwargs)
# Clock.schedule_once(self.create_webview, 0) `
# #run_on_ui_thread
# def create_webview(self, *args):
# webview = WebView(activity)
# webview.getSettings().setJavaScriptEnabled(True)
# wvc = WebViewClient();
# webview.setWebViewClient(wvc);
# activity.setContentView(webview)
# webview.loadUrl('http://www.google.com')
class ServiceApp(App):
def build(self):
return Wv()
if __name__ == '__main__':
ServiceApp().run
First, you should check if you are running the code in an Android enviroment as the android.webkit.WebView runs only under Android and not on a PC under Windows or Linux.
Recommended is an Android device and run the app using Buildozer command buildozer android debug deploy run with debugging options.
In case, you want to run it on a PC then you can install the Android VM from Kivy and follow the following steps on https://kivy.org/docs/guide/packaging-android-vm.html:
Download the Kivy / Buildozer VM, in the Virtual Machine section. The
download is 1.2GB. Extract the file and remember the location of the
extracted directory.
Download the version of VirtualBox for your machine from the VirtualBox download area and install it.
Start VirtualBox, click on “File”, “Import Appliance”.
Select the extracted directory, file should be named “Buildozer VM.ovf”
Start the Virtual machine and click on the “Buildozer” icon.
and let in run in kivy.org/docs/guide/packaging-android-vm.html
If you still face the problem of a jnius.JavaException: Class not found 'android/webkit/WebView' exception, then you have to add that jar file to the classpath:
import os
os.environ['CLASSPATH'] = 'absolute/path/file.jar'
In case of the Class not found 'android/webkit/WebView' exception you could either locate the jar on your device or download it and add the path where you store it to the classpath.
Use Pydroid3 to test your apps without compiling them

Building Python packages succeeds, but Scikit-learn is improperly built

I created an app using Scikit-learn and Kivy and it was built with Buildozer.
This is the code of main.py :
# coding=utf-8
import kivy
import sys
kivy.require('1.9.0')
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
try:
from sklearn import svm, datasets
except:
return Label(text=str(sys.exc_info()[1]))
else:
return Label(text='Scikit-learn OK')
if __name__ == '__main__':
MyApp().run()
I specified Scikit-learn in the requirements in buildozer.spec :
[app]
title = Kivyris
package.name = kivyris
package.domain = org.test
source.dir = .
source.include_exts = py,png,jpg,kv,atlas
version = 0.1
requirements = kivy,numpy,scipy,scikit-learn
orientation = landscape
fullscreen = 1
log_level = 2
warn_on_root = 1
I ran buildozer android_new debug deploy run (no error, APK file created and deployed) but I have the following error when the app is launched :
Cannot load library:
Contents of /data/data/org.test.kivyris/files/app/lib/python2.7/site-packages/sklearn/check_build:
__init.pyo setup.pyo _check_build.so
It seems that sckikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget to build the package before using it; run python setup.py install or make in the source directory.
If you have used an installer, please check that it is suited for your Python version, your operating system and your platform.
On Windows and Ubuntu using python main.py it works well :
Scikit-Learn OK
I installed Scikit-learn using sudo apt-get install python-scikits-learn on Ubuntu 16.04 LTS. This is some informations from the device on which I ran the app :
import platform failed; platform.platform() : I couldn't get this info (app failed to launch), but it's an Android 5.1.1
import sys OK; sys.version : 2.7.2 (default, Mar 6 2017, 06:05:36) [GCC 4.8]
import numpy OK; Numpy.version : 1.9.2
import scipy OK; Scipy.version : 0.18.1
import sklearn : error (see above).
I tried a few things unsuccessfully, so I looked online :
https://unix.stackexchange.com/questions/240239/building-python-packages-succeeds-but-package-is-improperly-built/240260 : didn't work for me.
Import scikit in C# application : not really what I was looking for.
https://github.com/scikit-learn/scikit-learn/issues/433 : works for Mac, not for Ubuntu.
Cannot import Scikit-Learn : scipy works for me.
I didn't find anything useful and I have no idea how to solve that. Any idea please ?
Thank you.
When you're trying to build your app for Android with module that uses pure Python, everything is ok: this module would be run by Python interpreter built for Android and shipped with your app.
Things much worse when your trying to build app for Android with module contains C extension or dependencies with C extensions (such as Scikit-learn). On Windows or Linux C Extensions would be compiled using distutils, but for Android it's problem: C Extensions can't be compiled this way.
python-for-android handles this problem providing mechanism of recipes:
recipe: A recipe is a file that defines how to compile a requirement.
Any libraries that have a Python extension must have a recipe in p4a,
or compilation will fail. If there is no recipe for a requirement, it
will be downloaded using pip.
You can see list of existing recipes here. As you can see no one did one for Scikit-learn, so I assume it can't be build for Android right now.
You can try to create recipe for this module manually or ask someone to help in kivy Google group. Note, that it's probably not trivial task.

Kivy app using socket module crashed when building by buildozer

I have an issue that I can't explain why it happened because I try to debug this for hours.
My application runs succeed so it is nothing about import Python library. But it always crash when i press a button to send message through bluetooth using python socket. (App written using kivy framework and using buildozer to build apk file)
import socket
def callback(self,instance,pos): # function called when button click to send text typed in text input box
a = self.text # it is text that in text input box
macadd = '20:15:ff:7e:bc:9a'
port = 1
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) # this line cause the crash
Then I type command:
buildozer init
buildozer -v android debug
file buildozer.spec doesn't change. Everything is ok and I install in my Android 4.0 using API 21. Here is the problem: WHEN I COMMENT
#s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
My app run and when click the button to submit, nothing happend, it's ok as function does.
BUT WHEN I REMOVE COMMENT:
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
My app run and when click the button to submit, it's crashed. I don't know what to do now. I really need somebody can help me with this situation. So thank you.

packaging kivy application to android

I never had a problem compiling my kivy applications before(done it many times) but i have one now : it throws the application normally on my Phone but when i open it it freezes on the presplash icon and gives me a message : "could not extract public data". i thought it was my sqlite3 file.
So i have changed its name and added to ./distribute.sh -m "sqlite3 kivy" and still have the problem.my build.py looks like this:
./build.py --dir /home/toufic/Desktop/Pay4 --name "Lebanese PayCalc" --package org.demo.PayCalc --version 1.2.4 --icon /home/toufic/Desktop/Pay4/lp.png --presplash /home/toufic/Desktop/Pay4/onmyown.png --permission INTERNET --permission WRITE_EXTERNAL_STORAGE --window debug installd
if i try to compile it with buildozer i have the following error :
File "/usr/lib/python2.7/bsddb/__init__.py", line 270, in <lambda>
return _DeadlockWrap(lambda: self.db[key]) # self.db[key]
bsddb.db.DBPageNotFoundError: (-30985, 'DB_PAGE_NOTFOUND: Requested page not found')
in my main.py file i have the following dependencies:
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.properties import ObjectProperty
from net_pay_oop import * # it's a class i have written and using its instance in my code
from kivy.uix.popup import Popup
from kivy.uix.label import Label
import sqlite3
import datetime
import os
import math
import smtplib
from kivy.core.window import Window
from kivy.uix.screenmanager import ScreenManager,Screen
import sys
long story short i need the right way to compile it either with python-for-android or the Buildozer utility(i'm new to this). can anyone please help according to the modules that i am using or is there a way to debug the build and know where the problem hides?
Edit: so I kind of made the app open but SMTP services at not working. Should I do ./distribute.sh "openssl sqlit3 kivy"?
the solution to smtp services to be enabled was to includ in distribute.sh the openssl option but still the error dispayed by my device : "could not extract public data" was not solved. i guess it is an sqlite3 issue but the thing is that this only happens upon first installation and my application loads normally afterwards and displays all saved data and browses them normally.

cgi server on android device without root?

I realized a cgi-server on my android device (Acer Iconia Tab A511, Android 4) by a short python script:
import BaseHTTPServer
import CGIHTTPServer
import cgitb; cgitb.enable()
import os
os.chdir('/sdcard/sl4a')
server = BaseHTTPServer.HTTPServer
handler = CGIHTTPServer.CGIHTTPRequestHandler
server_adress = ('', 8000)
print('CGIHTTPServer an Port 8000 gestartet')
httpd = server(server_adress, handler)
httpd.serve_forever()
and tried to start a python cgi-script , e.g.:
#! /system/bin/python
print "Content-Type: text/html\n\n"
print "Hello World!"
Altough this works on a windows machine (by minor changes) without any problems I didn't find a way to make it work on my android device. Do I need root to make it work, e.g. I can't chmod my cgi script to executable, or what else should I think of?

Categories

Resources