Android SDK 工具:OpenCV 需要 Android SDK 工具版本 14 或更新版本 [英] Android SDK Tools: OpenCV requires Android SDK Tools revision 14 or newer

查看:26
本文介绍了Android SDK 工具:OpenCV 需要 Android SDK 工具版本 14 或更新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 kivy、opencv 创建一个简单的照片捕捉应用程序.当我尝试使用 buildozer 创建一个 .apk 文件,并将 opencv 放在 .spec 文件的要求中时,我遇到了这个错误

I'm trying to create a simple photo capture app using kivy, opencv. When I tried to create an .apk file using buildozer, and put opencv in requirements at .spec file then I faced this error

-- Android: fixup -g compiler option from Android toolchain
-- Update variable ANDROID_SDK from environment: /home/livon/.buildozer/android/platform/android-sdk
-- Android SDK Tools: ver. 2.0 (description: 'Android SDK Command-line Tools')
-- Android SDK Build Tools: ver. 30.0.0 (subdir 30.0.0 from 30.0.0)
CMake Error at cmake/android/OpenCVDetectAndroidSDK.cmake:176 (message):
Android SDK Tools: OpenCV requires Android SDK Tools revision 14 or newer.

Use BUILD_ANDROID_PROJECTS=OFF to prepare Android project files without
building them
Call Stack (most recent call first):
CMakeLists.txt:780 (include)


-- Configuring incomplete, errors occurred!
See also "/home/livon/Desktop/Ocv/.buildozer/android/platform/build-armeabi- 
v7a/build/other_builds/opencv/armeabi-v7a__ndk_target_21/opencv/build/CMakeFiles/CMakeOutput.log".
See also "/home/livon/Desktop/Ocv/.buildozer/android/platform/build-armeabi- 
v7a/build/other_builds/opencv/armeabi-v7a__ndk_target_21/opencv/build/CMakeFiles/CMakeError.log".er
# Command failed: /home/livon/venv/bin/python3 -m pythonforandroid.toolchain create --dist_name=test 
--bootstrap=sdl2 --requirements=python3,kivy,opencv --arch armeabi-v7a --copy-libs --color=always -- 
storage-dir="/home/livon/Desktop/Ocv/.buildozer/android/platform/build-armeabi-v7a" --ndk-api=21
# ENVIRONMENT:
#     ANDROIDNDK = '/home/livon/.buildozer/android/platform/android-ndk-r19c'
#     ANDROIDAPI = '27'
#     ANDROIDMINAPI = '21'

我也尝试过更新 ANDROID_SDK,我去了 (/home/livon/.buildozer/android/platform/android-sdk) 这个文件夹并使用更新它

I have also tried to update ANDROID_SDK, I went to (/home/livon/.buildozer/android/platform/android-sdk) this folder and updated it using

sudo apt-get upgrade

但更新到 30.0.0 后没有任何变化,错误依旧.

But after updated it to 30.0.0 nothing has changed, the error remain same.

我正在使用

  1. Ubuntu 19.10
  2. Python 3.7.5
  3. 基维 1.11.1
  4. Buildozer 1.2.0
  5. openCv 4

推荐答案

我也遇到这个错误,烦了好久:(

I get this error too and fretted for a long time : (

经过一堆谷歌搜索,我找到了一些可能有帮助的解决方案.

After a bunch of google searches, I found some solutions that may help.

至少它可以在我的 Ubuntu 20.04 VM 上运行.

At least it works on my Ubuntu 20.04 VM.

(下载 Android Studio 并复制粘贴 dir 部分(最后 3 步)的说明可能会解决您的问题,因为我也遇到了与您相同的错误)

( The instruction to download Android Studio and copy-paste the dir part (last 3 steps) may solve your problem , as I also got the same error as you )

  • 先更新apt

sudo apt-get update

  • 升级包

  • upgrade pkgs

    sudo apt-get upgrade
    

  • 安装python3 + pip

  • install python3 + pip

    sudo apt-get install python3 python3-pip
    

  • 配置默认 Python 版本(ref_1 ) ( ref_2 )

    sudo update-alternatives --install /usr/bin/python python /usr/bin/python<X.X.X> 1
    sudo update-alternatives --config python
    

    其中 <X.X.X> 是所需的 Python 版本.

    where <X.X.X> is the desired Python ver.

    安装开发工具+依赖项

    sudo apt-get install build-essential 
      libssl-dev 
      libffi-dev 
      python3-dev 
      dh-autoreconf 
      autoconf 
      libtool 
      pkg-config 
      zlib1g-dev 
      libncurses5-dev 
      libncursesw5-dev 
      libtinfo5 
      cmake 
      ccache
    

  • 安装 kivy

  • install kivy

    • 通过apt

    sudo apt-get install python3-kivy
    

  • 通过 Python pip(我的首选方式)

  • through Python pip ( my preferred way )

    python3 -m pip install kivy==2.0.0
    

  • 安装 cython

    pip3 install Cython
    sudo apt-get install cython
    

    //我是这样做的

    安装javac

    sudo apt-get install openjdk-11-jdk openjdk-8-jdk
    

  • 检查是否安装了javajavac

    java -version
    javac -version
    

  • 配置.java + javac (我将它配置为 openjdk8-jdk )

  • config. java + javac ( I config. it to openjdk8-jdk )

    sudo update-alternatives --config java
    

    sudo update-alternatives --config javac
    

  • 安装cmake(我都做了)(参考 )

    • 蟒蛇方式

    • python way

    pip3 install cmake
    

  • 手动方式

  • manual way

    cd /tmp
    wget https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0.tar.gz
    tar -zxvf cmake-3.20.0.tar.gz
    cd cmake-3.20.0
    ./bootstrap
    make
    sudo make install
    

  • 安装 buildozer(我用 官方方式重新安装了)

    install buildozer ( I reinstalled it using the official way )

    • 官方方式

    • official way

    pip3 install --user --upgrade buildozer
    

  • 通过 git clone

  • through git clone

    sudo apt-get install git
    git clone https://github.com/kivy/buildozer.git
    cd buildozer
    sudo python3 setup.py install
    

  • 安装Python IDLE(可选)(以下任意一种)

    install Python IDLE ( optional ) ( either one of the following )

    sudo apt-get install idle3
    

  • 安装 Android Studio

  • install Android Studio

    我尝试了不安装 Android Studio 的方法(仅使用 cmdline-tools),但就是想不通:(

    I tried the way not to install Android Studio ( using cmdline-tools only ), but just can't figure it out : (

    sudo snap install android-studio --classic
    

    然后运行它,让它自己设置一切.

    and run it and let it set up everything by itself.

    然后,关闭它

    一切设置完成后:(ref)

    打开文件

    复制 ~/Home/Android/Sdk/中的 tools 目录

    copy the tools dir located in ~/Home/Android/Sdk/

    将其粘贴到 ~/Home/.buildozer/android/platform/android-sdk 压缩位于那里的原始 tools 目录(通过右键单击 --> compress )(如果看不到目录,请确保选中文件选项中的 show hidden file 复选框)

    paste it at ~/Home/.buildozer/android/platform/android-sdk after compressing the original tools dir located there ( by right click --> compress ) ( if you can't see the dir, make sure to check the show hidden file checkbox in the file's option )

    然后转到~/Home/.buildozer/android/platform/android-sdk/tools/bin并在终端打开

    ./sdkmanager --install "tools"
    exit
    

  • 再次重建项目转到您项目的目录

  • rebuild the project again go to your project's dir

    buildozer init  # if you haven't got the buildozer.spec in your project's dir
    buildozer android debug
    

    *.apk 将在 bin

    我的 buildozer.spec:

    title = Screen_Recorder
    package.name = screen_recorder
    package.domain = org.test
    souce.dir = .
    source.include_exts = py,png,jpg,kv,atlas
    requirements = python3,kivy==2.0.0,android,opencv==4.5.3,numpy,pillow,EasyProcess,entrypoint2,mss,jeepney,plyer,pyscreenshot
    osx.python_version = 3
    osx.kivy_version = 2.0.0
    android.permission = CAMERA,RECORD_AUDIO,WRITE_EXTERNAL_STORAGE,READ_EXTERNAL_STORAGE
    

    参考

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆