我正在尝试使用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。请帮忙!
答案 0 :(得分:1)
您需要使用jdk8。我在Linux上使用的是openjdk-8-jdk。
您可以使用以下方法切换jdk: sudo update-alternatives --config java
最重要的是,为了避免出现jdk的某些问题,我们将使用JVM的选项
DEFAULT_JVM_OPTS ='“-Dcom.android.sdklib.toolsdir = $ APP_HOME” -XX:+ IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
,然后使用清洁您的东西: buildozer android clean
然后重新制作。
答案 1 :(得分:0)
该错误是由于buildozer与所使用的Java版本不兼容所致。在Parrot OS中,默认的Java版本是openJDK11。
sudo apt install openjdk-8jdk
sudo update-alternatives --config java
sudo update-alternatives --config javac
在新版本的Buildozer v0.39中,不推荐使用CrystaX。
pip3 install --upgrade buildozer
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
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