Android错误“预期buildtargetScommandComponents [...]"
我正在开发一个用于简单面部识别的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚遇到了类似的“预期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.
首先重建您的应用程序,然后检查此位置
至少应有4个文件夹,用于不同的ABI的
X86- X64 -ARM64/V7A -ARM64/V8
如果不存在,
则将其应用于您的build.gradle.gradle
first rebuild your app and then check this location
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