android 将默认加载屏幕图像替换为自定义动画

k2arahey  于 2022-12-02  发布在  Android
关注(0)|答案(2)|浏览(123)

我用kivy框架做了一个android应用程序,我注意到在buildozer.spec文件中;有些行建议实现动画以替换默认加载屏幕的可能性。
我说的台词是...

# (string) Presplash animation using Lottie format.
# see https://lottiefiles.com/ for examples and https://airbnb.design/lottie/
# for general documentation.
# Lottie files can be created using various tools, like Adobe After Effect or Synfig.
#android.presplash_lottie = "path/to/lottie/file.json"

我想从buildozer.spec文件中引用一个lottie动画。以便自定义加载动画替换*默认加载屏幕图像**。
应用程序已经完成了。我在编译阶段与buildozer。我使用的方法是...

1.模块lottie .json动画加载到THIS COLAB NOTEBOOK的示例中。
2.运行单元格,直到包含!buildozer init命令的代码单元格。
3.修改buildozer.spec文件以引用我的
.json扩展名动画

我所做的修改具体在buildozer.spec文件的第89行:
从......

#android.presplash_lottie = "path/to/lottie/file.json"

为了...

android.presplash_lottie = "loading.json"

**#注意:**下面我展示了一些方法的替代例子,我试图修改文件,并得到类似的结果。
**4.**完成此修改后,继续执行以下代码单元:!buildozer -v android debug。执行完成后,我收到以下错误消息:

[INFO]:    COMMAND:
cd /content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/myapp && /content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/myapp/gradlew assembleDebug

[WARNING]: ERROR: /content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/myapp/gradlew failed!
WARNING: Received a --sdk argument, but this argument is deprecated and does nothing.
No setup.py/pyproject.toml used, copying full private data into .apk.
Applying Java source code patches...
Applying patch: src/patches/SDLActivity.java.patch
# Command failed: /usr/bin/python3 -m pythonforandroid.toolchain apk --bootstrap sdl2 --dist_name myapp --name 'My Application' --version 0.1 --package org.test.myapp --minsdk 21 --ndk-api 21 --private /content/.buildozer/android/app --android-entrypoint org.kivy.android.PythonActivity --android-apptheme @android:style/Theme.NoTitleBar --presplash-lottie /content/"loading.json" --orientation portrait --window --copy-libs --arch arm64-v8a --arch armeabi-v7a --color=always --storage-dir="/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a" --ndk-api=21 --ignore-setup-py --debug
# ENVIRONMENT:
#     CUDNN_VERSION = '8.0.5.39'
#     PYDEVD_USE_FRAME_EVAL = 'NO'
#     LD_LIBRARY_PATH = '/usr/local/nvidia/lib:/usr/local/nvidia/lib64'
#     CLOUDSDK_PYTHON = 'python3'
#     LANG = 'en_US.UTF-8'
#     ENABLE_DIRECTORYPREFETCHER = '1'
#     HOSTNAME = '4e5cfbd61f47'
#     OLDPWD = '/'
#     CLOUDSDK_CONFIG = '/content/.config'
#     USE_AUTH_EPHEM = '1'
#     NVIDIA_VISIBLE_DEVICES = 'all'
#     DATALAB_SETTINGS_OVERRIDES = '{"kernelManagerProxyPort":6000,"kernelManagerProxyHost":"172.28.0.3","jupyterArgs":["--ip=172.28.0.2"],"debugAdapterMultiplexerPath":"/usr/local/bin/dap_multiplexer","enableLsp":true}'
#     ENV = '/root/.bashrc'
#     PAGER = 'cat'
#     NCCL_VERSION = '2.7.8'
#     TF_FORCE_GPU_ALLOW_GROWTH = 'true'
#     JPY_PARENT_PID = '45'
#     NO_GCE_CHECK = 'False'
#     PWD = '/content'
#     HOME = '/root'
#     LAST_FORCED_REBUILD = '20220726'
#     CLICOLOR = '1'
#     DEBIAN_FRONTEND = 'noninteractive'
#     LIBRARY_PATH = '/usr/local/cuda/lib64/stubs'
#     GCE_METADATA_TIMEOUT = '3'
#     GLIBCPP_FORCE_NEW = '1'
#     TBE_CREDS_ADDR = '172.28.0.1:8008'
#     TERM = 'xterm-color'
#     SHELL = '/bin/bash'
#     GCS_READ_CACHE_BLOCK_SIZE_MB = '16'
#     PYTHONWARNINGS = 'ignore:::pip._internal.cli.base_command'
#     MPLBACKEND = 'module://ipykernel.pylab.backend_inline'
#     CUDA_VERSION = '11.1.1'
#     NVIDIA_DRIVER_CAPABILITIES = 'compute,utility'
#     SHLVL = '1'
#     PYTHONPATH = '/env/python'
#     NVIDIA_REQUIRE_CUDA = ('cuda>=11.1 brand=tesla,driver>=418,driver<419 '
 'brand=tesla,driver>=440,driver<441 brand=tesla,driver>=450,driver<451')
#     TBE_EPHEM_CREDS_ADDR = '172.28.0.1:8009'
#     COLAB_GPU = '0'
#     GLIBCXX_FORCE_NEW = '1'
#     PATH = '/root/.buildozer/android/platform/apache-ant-1.9.4/bin:/opt/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin'
#     LD_PRELOAD = '/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4'
#     GIT_PAGER = 'cat'
#     _ = '/usr/local/bin/buildozer'
#     PACKAGES_PATH = '/root/.buildozer/android/packages'
#     ANDROIDSDK = '/root/.buildozer/android/platform/android-sdk'
#     ANDROIDNDK = '/root/.buildozer/android/platform/android-ndk-r23b'
#     ANDROIDAPI = '27'
#     ANDROIDMINAPI = '21'
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

我知道问题在于我在buildozer.spec文件中所做的修改,因为当我跳过这一步执行相同的过程时,apk文件会正确生成。
这就是问题所在。也就是说,我继续声明可能对任何想帮助我的人有用的信息。
Hello world in kivy(你好,kivy里的世界)
(So 您不必编写或搜索)

主文件.py

import kivy
from kivy.app import App
from kivy.uix.label import Label

class MyApp(App):
    def build(self):
        return Label(text='Hello World')

if __name__ == "__main__":
    MyApp().run()

lottie中的免费示例.json动画

Loading animation

已尝试但无效的解决方案列表

1.将推土机规范第89行替换为
android.presplash_lottie = "path/to/lottie/loading.json"
1.将替换为
android.presplash_lottie = "loading.json"
1.将替换为
android.presplash_lottie = "/content/loading.json"
1.将替换为
android.presplash_lottie = %(source.dir)s/data/loading.json
1.将json添加到
source.include_exts = py,png,jpg,kv,atlas
提前感谢!希望有用。

e5nszbig

e5nszbig1#

edit portion在buildozer.spec文件中,您有一个布尔选项android.useandroidx,默认为false,您需要将其设置为true,进一步,您需要编辑python for android部分并更改p4a.branch = develop,这应该可以完成工作

qgelzfjb

qgelzfjb2#

进行以下更改!!
1.将json添加到列表中:
source.include_exts = py,png,jpg,kv,atlas,json
1.将assets/*.json添加到列表中:
source.include_patterns = assets/*.txt,assets/*.json,assets/*.kv,data/*.png
1.在行中定义路径:
android.presplash_lottie = "assets/lottie.json"
全部完成!!

相关问题