Android错误“预期buildtargetScommandComponents [...]"

发布于 2025-02-13 12:14:32 字数 3396 浏览 1 评论 0原文

我正在开发一个用于简单面部识别的Android应用程序。

  • 我的应用程序在模拟器中构建和运行良好,
  • 但是应用程序无法在真实设备中安装,
  • 并且我们会因cmake相关任务而获得gradle错误,并带有错误:

任务:引擎:configurecmakedebug [arm64-v8a]失败 执行失败的任务':Engine:configurecmakedebug [ARM64-V8A]'。 [CXX1410] D:\ kam \ code \ aet \ aet \ aet \ Engine.cxx \ debug \ 3p465u2i \ arm64-v8a \ android_gradle_build.json ncnn-release-arm64-v8a.buildCommandComponents存在

cmakelist.txt:

cmake_minimum_required(VERSION 3.4.1)

set(CMAKE_BUILD_TYPE "release")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../../../distribution/${ANDROID_ABI})

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

add_library(ncnn STATIC IMPORTED)
set_target_properties(ncnn PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libncnn.a)

add_library(opencv_core STATIC IMPORTED)
set_target_properties(opencv_core PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libopencv_core.so)

add_library(opencv_imgproc STATIC IMPORTED)
set_target_properties(opencv_imgproc PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libopencv_imgproc.so)

add_library(opencv_codecs STATIC IMPORTED)
set_target_properties(opencv_codecs PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libopencv_imgcodecs.so)


file(GLOB jni_srcs
        "*.cpp"
        "detection/*.cpp"
        "live/*.cpp"
    )

add_library(engine SHARED ${jni_srcs})

target_link_libraries(engine log jnigraphics ncnn opencv_core opencv_imgproc opencv_codecs android -static-openmp -fopenmp)

build.gradle(模块:发动机):

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 30
    buildToolsVersion "29.0.3"

    defaultConfig {
        minSdkVersion 28
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles 'consumer-rules.pro'

        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11 -frtti -fexceptions"
                abiFilters 'arm64-v8a'
                arguments "-DANDROID_ARM_NEON=TRUE"
                arguments "-DANDROID_TOOLCHAIN=clang"
            }
        }
    }

    packagingOptions {
        pickFirst '**/*.so'
    }

    externalNativeBuild {
        cmake {
            version = "3.6.0"
            path "src/main/cpp/CMakeLists.txt"
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    ndkVersion '22.1.7171670'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.core:core-ktx:1.3.2'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}


I try to find the reason but no luck. So far find only [this][1].
Any help or resource will be great for me. Thanks

I'm developing an Android application for simple Facial recognition.

  • My Application build and run fine in emulator,
  • But App can't install in real device,
  • And we get Gradle error for CMake related task, with error-message:

Task :engine:configureCMakeDebug[arm64-v8a] FAILED
Execution failed for task ':engine:configureCMakeDebug[arm64-v8a]'.
[CXX1410] D:\KAM\code\AET\AET\engine.cxx\Debug\3p465u2i\arm64-v8a\android_gradle_build.json debug|arm64-v8a : expected buildTargetsCommandComponents or ncnn-release-arm64-v8a.buildCommandComponents to exist

CMakeList.txt:

cmake_minimum_required(VERSION 3.4.1)

set(CMAKE_BUILD_TYPE "release")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../../../distribution/${ANDROID_ABI})

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

add_library(ncnn STATIC IMPORTED)
set_target_properties(ncnn PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libncnn.a)

add_library(opencv_core STATIC IMPORTED)
set_target_properties(opencv_core PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libopencv_core.so)

add_library(opencv_imgproc STATIC IMPORTED)
set_target_properties(opencv_imgproc PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libopencv_imgproc.so)

add_library(opencv_codecs STATIC IMPORTED)
set_target_properties(opencv_codecs PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/libopencv_imgcodecs.so)


file(GLOB jni_srcs
        "*.cpp"
        "detection/*.cpp"
        "live/*.cpp"
    )

add_library(engine SHARED ${jni_srcs})

target_link_libraries(engine log jnigraphics ncnn opencv_core opencv_imgproc opencv_codecs android -static-openmp -fopenmp)

build.gradle(Module: engine):

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 30
    buildToolsVersion "29.0.3"

    defaultConfig {
        minSdkVersion 28
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles 'consumer-rules.pro'

        externalNativeBuild {
            cmake {
                cppFlags "-std=c++11 -frtti -fexceptions"
                abiFilters 'arm64-v8a'
                arguments "-DANDROID_ARM_NEON=TRUE"
                arguments "-DANDROID_TOOLCHAIN=clang"
            }
        }
    }

    packagingOptions {
        pickFirst '**/*.so'
    }

    externalNativeBuild {
        cmake {
            version = "3.6.0"
            path "src/main/cpp/CMakeLists.txt"
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    ndkVersion '22.1.7171670'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.core:core-ktx:1.3.2'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}


I try to find the reason but no luck. So far find only [this][1].
Any help or resource will be great for me. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

山川志 2025-02-20 12:14:32

我刚刚遇到了类似的“预期buildtargetScommandComponents ...”错误日志。

与其他时候一样,删除构建目录并重新启动IDE解决了问题。

I just met similar "expected buildTargetsCommandComponents ..." error log.

And like many other times, deleting the build directory and restarting IDE fixed the issue.

堇色安年 2025-02-20 12:14:32

首先重建您的应用程序,然后检查此位置

PROJECT PATH...\app\build\intermediates\cmake\debug\obj

至少应有4个文件夹,用于不同的ABI的

X86- X64 -ARM64/V7A -ARM64/V8

如果不存在,

则将其应用于您的build.gradle.gradle

abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'

first rebuild your app and then check this location

PROJECT PATH...\app\build\intermediates\cmake\debug\obj

There should be at least 4 folders for different abi's

x86 - x64 -- arm64/v7a -- arm64/v8

if its not exist there

apply this to your build.gradle

abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文