简体   繁体   English

Android App 在模拟器中运行良好,但无法在真实设备中安装

[英]Android App running fine in Emulator but can't install in real device

I'm developing an android application for simple Facial recognition.我正在开发一个用于简单面部识别的 android 应用程序。 My Application build and run fine in emulator but get Cmake Error when try to install in real device.我的应用程序在模拟器中构建并运行良好,但尝试在真实设备中安装时出现 Cmake 错误。 Error Message:错误信息:

Task :engine:configureCMakeDebug[arm64-v8a] FAILED Execution failed for task ':engine:configureCMakeDebug[arm64-v8a]'.任务 :engine:configureCMakeDebug[arm64-v8a] FAILED 任务 ':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 [CXX1410] D:\KAM\code\AET\AET\engine.cxx\Debug\3p465u2i\arm64-v8a\android_gradle_build.json debug|arm64-v8a:预期buildTargetsCommandComponents 或 ncnn-release-arm64-v8a.buildCommandComponents 存在

CMakeList.txt: 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): 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

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不同的 abi 应该至少有 4 个文件夹

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

if its not exist there如果那里不存在

apply this to your build.gradle将此应用于您的 build.gradle

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在模拟器中,我的应用可以正常运行,但不能在真实设备中运行 - In emulator my app running fine but not in real device Android 应用程序不在模拟器上运行,而是在真实设备上运行 - Android App NOT Running on Emulator, but on real device Android应用未在模拟器上运行,也未在真实设备上运行 - Android app not running on emulator nor real device Android 应用程序在模拟器上运行良好,但在真实设备上运行时会出现错误解析包 - Android app running fine on emulator but gives error parsing package when made to run on real device Android应用程式可在模拟器上正常运作,但在真实装置中当机 - Android app works fine in emulator but crashes in real device Android:构建Android应用程序以检查应用程序是否在模拟器或真实设备上运行 - Android: build android application to check app is running at emulator or real device 应用程序在模拟器上运行正常,但在真实设备上崩溃 - App runs fine on emulator, but crashes on real device 应用程序在模拟器上运行良好,但在真实设备上崩溃 - App working fine on emulator but crashes on real device Android应用程序可以在模拟器中正常运行,但不能在真实设备中运行? - Android application works fine in emulator but not in real device? Android应用程序可以在模拟器上正常运行,但不能在真实设备上运行 - Android Application works fine on emulator but not on a real device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM