模型部署:(四)安卓端部署Yolov8-v8.2.99实例分割项目全流程记录
模型部署:(四)安卓端部署Yolov8-v8.2.99实例分割项目全流程记录
- 1、下载ncnn
- 2、下载opencv-mobile
- 3、文件拷贝
- 4、andorid_studio相关配置
- 5、文件内参数设置
- 5、重构项目:
- 6、打包apk
1、下载ncnn
地址:
https://github.com/Tencent/ncnn/tree/20230223
下载的版本是
ncnn-20230223-android-vulkan
2、下载opencv-mobile
下载的版本是:opencv-mobile-4.6.0-android
官网地址:
https://github.com/nihui/opencv-mobile/releases?page=2
3、文件拷贝
将上述下载的ncnn-20230223-android-vulkan与opencv-mobile-4.6.0-android分别解压,拷贝到
目录D:\ncnn-android-yolov8-seg\app\src\main\jni下
4、andorid_studio相关配置
我的这个版本是:Android Studio Flamingo | 2022.2.1 Patch 1
配置SDK Platforms
配置SDK Platforms
5、文件内参数设置
文件:build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {repositories {jcenter()google()}dependencies {classpath 'com.android.tools.build:gradle:3.5.0'}
}allprojects {repositories {jcenter()google()}
}
文件:build.gradle (Module: app)
apply plugin: 'com.android.application'android {compileSdkVersion 24buildToolsVersion "29.0.2"defaultConfig {applicationId "com.tencent.yolov8ncnn"archivesBaseName = "$applicationId"minSdkVersion 24}externalNativeBuild {cmake {version "3.10.2"path file('src/main/jni/CMakeLists.txt')}}dependencies {implementation 'com.android.support:support-v4:24.0.0'}ndkVersion '24.0.8215888'
}
文件:gradle-wrapper.properties
#Sun Sep 08 23:09:42 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-5.4.1-all.zip
文件:local.properties
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri Sep 12 17:47:07 CST 2025
cmake.dir=D\:\\Android_SDK\\Sdk\\cmake\\3.10.2.4988404
ndk.dir=D\:\\Android_SDK\\Sdk\\ndk\\24.0.8215888
sdk.dir=D\:\\Android_SDK\\Sdk
文件:settings.gradle
文件:CMakeLists.txt
5、重构项目:
6、打包apk
但是打包过程中会出现报错,提示信息如下:
Execution failed for task ':app:stripDebugDebugSymbols'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
解决方案:
同时安装低版本的ndk(如version=21.0.6113669),将低版
本ndk中toolchains 文件夹下的arm-linux-androideabi等文件复制到高版
本ndk的toolchains 文件夹中
复制后如下所示::复制到24.0.8215888对应的目录下
再次重构,打包,效果如下所示: