GithubHelp home page GithubHelp logo

Comments (5)

ArtemSBulgakov avatar ArtemSBulgakov commented on July 25, 2024 1

Apk from this build installs correctly on my Samsung S21.

What error do you get?

from buildozer-action.

ArtemSBulgakov avatar ArtemSBulgakov commented on July 25, 2024 1

Glad to hear it, good luck with your projects!

from buildozer-action.

ArtemSBulgakov avatar ArtemSBulgakov commented on July 25, 2024

Hi! You can use python-for-android hooks for this.

Add line to buildozer.spec:

# (str) Filename to the hook for p4a
p4a.hook = p4a/hook.py

Add file p4a/hook.py with your code (you need hook after_apk_build, it is called from here).

I use this to change android.screenOrientation, you can change for your case:

import os
import shutil
from pathlib import Path
from pythonforandroid.toolchain import ToolchainCL

def after_apk_build(toolchain: ToolchainCL):
    manifest_file = Path(toolchain._dist.dist_dir) / "src" / "main" / "AndroidManifest.xml"
    old_manifest = manifest_file.read_text(encoding="utf-8")
    new_manifest = old_manifest.replace(
        'android:screenOrientation="portrait"',
        'android:screenOrientation="userPortrait"',
    )
    manifest_file.write_text(new_manifest, encoding="utf-8")
    if old_manifest != new_manifest:
        print("Set orientation SUCCESSFULLY")
    else:
        print("Set orientation FAILED")

from buildozer-action.

manatlan avatar manatlan commented on July 25, 2024

Thanks, you are a god ! You save me ...
it now works (it builds an apk !) : https://github.com/manatlan/htagapk

But how can you explain ?!

The resulted apk/package can't be installed on my phone (xiaomi mi9)....

While, locally (on my ubu lts, the same repo/srcs), a simple buildozer android debug deploy run install it and run it, without trouble ?!

Have you got an idea ?

But thanks for the p4a tips !!!!

from buildozer-action.

manatlan avatar manatlan commented on July 25, 2024

Update !

It works like a charm ! forget my latest comment !
(In fact, "Google Files" refused to install the github/apk .... but using another process : it installs, and it works !)

Big thanks to you !!

from buildozer-action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.