简体   繁体   English

Android NDK ndk-build错误

[英]android NDK ndk-build error

I'm new to Android studio and android NDK. 我是Android Studio和android NDK的新手。 I'm trying to compile a simple hello.c program with android NDK for a class assignment. 我正在尝试使用android NDK编译一个简单的hello.c程序进行类分配。 I've followed the following project instructions but get an error: 我已按照以下项目说明进行操作,但出现错误:

  1. Create ac program 创建交流程序

  2. create Android.mk with following contents: 使用以下内容创建Android.mk:

    LOCAL_PATH := $(call my-dir) LOCAL_PATH:= $(调用my-dir)
    include $(CLEAR_VARS) 包括$(CLEAR_VARS)
    LOCAL_MODULE := hello.out LOCAL_MODULE:= hello.out
    LOCAL_SRC_FILES :=hello.c LOCAL_SRC_FILES:= hello.c
    include $(BUILD_EXECUTABLE) 包括$(BUILD_EXECUTABLE)

  3. Create Application.mk with following content: 创建具有以下内容的Application.mk:

    APP_ABI := armeabi APP_ABI:= armeabi
    APP_PLATFORM := android-10 APP_PLATFORM:= android-10
    APP_STL := stlport_static APP_STL:= stlport_static
    APP_BUILD_SCRITP := Android.mk APP_BUILD_SCRITP:= Android.mk

  4. Put hello.c, Android.mk, Application.mk into same folder x. 将hello.c,Android.mk,Application.mk放入同一文件夹x。

  5. go to folder x 转到文件夹x

  6. run command: 运行命令:

    export NDK_PROJECT_PATH=. 导出NDK_PROJECT_PATH =。

  7. Run command 运行命令

    [NDK_dir]/ndk-build NDK_APPLICATION_MK=./Application.mk [NDK_dir] / ndk-build NDK_APPLICATION_MK =。/ Application.mk

  8. the executable will be generated at ./libs/armeabi/hello.out 可执行文件将在./libs/armeabi/hello.out中生成

But I get this error when following those instructions: 但是按照这些说明操作时,我会收到此错误:

/home/justin/Desktop/android-ndk-r16/build/core/add-application.mk:49: Application.mk: No such file or directory
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-14.    
Android NDK: There is no Android.mk under ./jni    
Android NDK: If this is intentional  please define APP_BUILD_SCRIPT to point   
Android NDK: to a valid NDK build script.    
/home/justin/Desktop/android-ndk-r16/build/core/add-application.mk:116: *** Android NDK: Aborting...    .  Stop.

I installed android NDK components through Andoird studio SDK and my [NDK_DiR] is /home/justin/Android/Sdk/ndk-bundle 我通过Andoird studio SDK安装了android NDK组件,我的[NDK_DiR]是/ home / justin / Android / Sdk / ndk-bundle

The easy fix is to move all three files to a subdirectory called jni . 简单的解决方法是将所有三个文件移动到名为jni的子目录中。 You don't need to export NDK_PROJECT_PATH, and your command will look like 您无需导出NDK_PROJECT_PATH,您的命令将类似于

<path-to/>ndk-build -C <path-to/>x/jni

If you need to avoid jni directory at any price, try 如果您需要不惜一切代价避免使用jni目录,请尝试

<path-to/>ndk-build NDK_PROJECT_PATH=<path-to/>x NDK_APPLICATION_MK=<path-to/>x/Application.mk APP_BUILD_SCRIPT=<path-to/>x/Android.mk

which is almost equivalent to 这几乎等于

<path-to/>ndk-build -C <path-to/>x NDK_PROJECT_PATH=. NDK_APPLICATION_MK=Application.mk APP_BUILD_SCRIPT=Android.mk

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM