使用命令行构建INSTALL_FAILED_NO_MATCHING_ABIS,即使架构匹配

时间:2018-02-07 22:16:05

标签: android cmake android-ndk adb

我现在正在结束我的智慧。 我正在尝试通过命令行内容构建我的应用程序,基于此repo。 建设进展顺利,我能够生成.apks。

但是,当我想通过adb install部署我的apk时,我得到:

  

失败[INSTALL_FAILED_NO_MATCHING_ABIS]

接下来是一堆

  

E / SMD(21205):smd接口打开失败errno为2 -1

错误应该是错误的。但是,我的手机(三星Galaxy S4)和我的应用都使用armv7-a架构,所以我现在完全无能为力。当我解压缩我的apk时,lib目录中只有arm7v-a,我仔细检查了我的手机。

我错过了什么吗? Here is my cmake

cmake_minimum_required(VERSION 3.3)
project(NativeActivity)

# -> dirs
set(TOOLCHAIN    "/home/name/Projects/C++/external/androidndk/ndk-r16b/native-toolchain/arm")
set(ANDROID_HOME "/home/name/Projects/C++/external/androidsdk")
set(BUILD_TOOLS  "/home/name/Projects/C++/external/androidsdk/build-tools/21.1.2")
set(ANDROID_NDK  "/home/name/Projects/C++/external/androidndk/ndk-r16b")
set(JAVA_HOME $ENV{JAVA_HOME})
# <-

# -> compiler
set(ARCH "armv7-a")
set(API "21")
set(COMP_FLAGS -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb)
set(LINK_FLAGS -march=armv7-a -Wl,--fix-cortex-a8)


set(ARCH_TOOLS "arm-linux-androideabi")
set(CC ${TOOLCHAIN}/bin/${ARCH_TOOLS}-gcc)
set(CXX ${TOOLCHAIN}/bin/${ARCH_TOOLS}-g++)
set(AR ${TOOLCHAIN}/bin/${ARCH_TOOLS}-ar)

set(CXX_FLAGS "")
set(CXX_INCLUDES "${ANDROID_NDK}/sources/android/native_app_glue")
# <-

set(HOME_DIR ${CMAKE_CURRENT_SOURCE_DIR})

set(SOURCE_FILES_CPP
        )

set(SOURCE_FILES_H
        )


set(CMAKE_VERBOSE_MAKEFILE 0)

add_custom_target(deploy
        COMMAND ${ANDROID_HOME}/platform-tools/adb install -r bin/NativeActivity.apk
        COMMAND ${ANDROID_HOME}/platform-tools/adb logcat -c
        COMMAND ${ANDROID_HOME}/platform-tools/adb logcat *:W
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Deploying apk.")

add_custom_target(build
        DEPENDS bin/NativeActivity.apk
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Building apk.")

add_custom_target(dummy
        DEPENDS ${HOME_DIR}/lib/${ARCH}/libnative-activity.so
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Doing dummy stuff.")


add_custom_command(OUTPUT ${HOME_DIR}/bin/NativeActivity.apk
        COMMAND ${BUILD_TOOLS}/zipalign -f 4 bin/NativeActivity.signed.apk bin/NativeActivity.apk
        DEPENDS bin/NativeActivity.signed.apk
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Creating bin/NativeActivity.apk.")

add_custom_command(OUTPUT ${HOME_DIR}/bin/NativeActivity.signed.apk
        COMMAND $(JAVA_HOME)/bin/jarsigner -keystore ToyKey.keystore -storepass armena -keypass armena 
        -signedjar ${HOME_DIR}/bin/NativeActivity.signed.apk bin/NativeActivity.unsigned.apk NativeActivityKey
        DEPENDS bin/NativeActivity.unsigned.apk ToyKey.keystore
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Creating bin/NativeActivity.signed.apk.")

add_custom_command(OUTPUT ${HOME_DIR}/bin/NativeActivity.unsigned.apk
        COMMAND ${BUILD_TOOLS}/aapt package -f -M AndroidManifest.xml -S res
        -I ${ANDROID_HOME}/platforms/android-${API}/android.jar -F bin/NativeActivity.unsigned.apk bin
        COMMAND ${BUILD_TOOLS}/aapt add ${HOME_DIR}/bin/NativeActivity.unsigned.apk lib/${ARCH}/libnative-activity.so
        DEPENDS bin/classes.dex lib/${ARCH}/libnative-activity.so
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Creating bin/NativeActivity.unsigned.apk.")

add_custom_command(OUTPUT ${HOME_DIR}/bin/classes.dex
        COMMAND ${BUILD_TOOLS}/dx --dex --output=bin/classes.dex obj
        DEPENDS obj/com/example/native_activity/R.class
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Creating bin/classes/dex.")

add_custom_command(OUTPUT ${HOME_DIR}/obj/com/example/native_activity/R.class
        COMMAND $(JAVA_HOME)/bin/javac -source 1.7 -target 1.7 -d obj -classpath ${ANDROID_HOME}/platforms/android-${API}/android.jar -sourcepath src src/com/example/native_activity/R.java
        DEPENDS src/com/example/native_activity/R.java
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Creating obj/com/example/native_activity/R.class.")

add_custom_command(OUTPUT ${HOME_DIR}/src/com/example/native_activity/R.java
        COMMAND ${BUILD_TOOLS}/aapt package -f -m  -S res -J src -M AndroidManifest.xml -I ${ANDROID_HOME}/platforms/android-${API}/android.jar
        DEPENDS res/values/strings.xml
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Creating src/com/example/native_activity/R.java.")

add_custom_command(OUTPUT ${HOME_DIR}/ToyKey.keystore
        COMMAND $(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=somecompany,O=Android,C=JPN" -keystore ToyKey.keystore
        -storepass armena -keypass armena -alias NativeActivityKey -keyalg RSA
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Creating ToyKey.keystore.")



add_custom_command(OUTPUT ${HOME_DIR}/jni/libnative_app_glue.a
        COMMAND ${CC} -Wall -march=${ARCH} ${COMP_FLAGS} -c ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c -o jni/native_app_glue.o
        COMMAND ${AR} rcs ${HOME_DIR}/jni/libnative_app_glue.a jni/native_app_glue.o
        BYPRODUCTS jni/native_app_glue.o
        DEPENDS ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Creating native_app_glue static library.")




add_custom_command(OUTPUT ${HOME_DIR}/lib/${ARCH}/libnative-activity.so 
        COMMAND ${CXX} -Wall -I ${CXX_INCLUDES} -march=${ARCH} ${FLCOMP_FLAGSAGS} --sysroot=${TOOLCHAIN}/sysroot -std=gnu++11 -fPIC -c jni/main.cpp -o jni/main.o
        COMMAND ${CXX} -I ${CXX_INCLUDES} -L jni -shared jni/main.o ${LINK_FLAGS} -o lib/${ARCH}/libnative-activity.so -llog -landroid -lEGL -lGLESv1_CM -lnative_app_glue
        BYPRODUCTS jni/main.o
        DEPENDS jni/main.cpp jni/libnative_app_glue.a
        WORKING_DIRECTORY ${HOME_DIR}
        COMMENT "Creating c++ shared libraries.")

0 个答案:

没有答案