gpt4 book ai didi

java - 无法使用 Buildozer 编译 APK

转载 作者:行者123 更新时间:2023-12-02 01:36:29 25 4
gpt4 key购买 nike

我正在尝试使用 buildozer 将 python 文件编译为 APK。安装所有依赖项(包括 SDK 和 NDK)并运行 buildozer android deploy run 后,出现以下错误:

/home/caliph/.buildozer/android/platform/android-sdk
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
# Command failed: /home/caliph/.buildozer/android/platform/android-sdk/tools/bin/sdkmanager tools platform-tools
#
# 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

我的 python 代码是一个简单的类,位于名为 main.py 的文件中:

__version__ = '1.1'

class MyNewClass:
'''This is a docstring. I have created a new class'''
pass

如何克服这个问题并创建 APK。请帮忙!

最佳答案

原因

该错误是由于 buildozer 与所使用的 Java 版本不兼容造成的。在Parrot OS中,默认的Java版本是openJDK11。

解决方案

  1. 安装openJDK8:sudo apt install openjdk-8jdk
  2. 将 JDK8 设置为 java 的 Activity 版本:sudo update-alternatives --config java
  3. 将 JDK8 设置为 javac 的 Activity 版本:sudo update-alternatives --config javac

Ubuntu 操作系统

在新版本的 Buildozer v0.39 中,CrystaX 已被弃用。

升级 Buildozer

Ubuntu/Linux - Python 3

pip3 install --upgrade buildozer

Ubuntu 18.04(64 位)

sudo pip install --upgrade cython==0.28.6
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386

Ubuntu 16.04(64 位)

sudo pip install --upgrade cython==0.21
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386

关于java - 无法使用 Buildozer 编译 APK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55184079/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com