You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu环境下Android NDK编译报错求助:模块缺失与文件依赖问题

Fixing Your Android NDK Build Errors on Ubuntu

Hey Andy, let's tackle these two issues one by one—they're both basic setup snags that are easy to fix!

1. Error: ndk-build cannot find module with tag 'cxx-stl/system' in import path

First off, the system STL is the default runtime for NDK builds, so you don't need to explicitly import it with an import-module call. That line in your Android.mk is unnecessary and causing the error.

Here's what to do:

  • Open your jni/Android.mk file.
  • Delete any line that looks like $(call import-module,cxx-stl/system).
  • If you want to explicitly confirm you're using the system STL, add LOCAL_STL := system to your module definition (this is optional, since it's the default behavior).

Also, a quick heads-up: this error might also pop up if you're working directly with the compressed NDK archive instead of an extracted directory—we'll fix that in the next section.

2. Error: make: *** No rule to make target '/hello.c', needed by 'obj/local/armeabi/objs/helloARM/hello.o'. Stop.

Looking at your command path, you're trying to run ndk-build directly on the .tar.bz2 compressed file like it's a folder—that's the core issue here! The NDK needs to be extracted to a regular directory first, otherwise the build system can't find the example source files.

Follow these steps to fix this:

  1. Extract the NDK archive:
    Run this terminal command to unpack the NDK (adjust the path if your download is in a different location):

    tar -xvf ~/Downloads/android-ndk-r11-linux-x86_64.tar.bz2 -C ~/Downloads/
    

    This will create a directory named android-ndk-r11 in your Downloads folder.

  2. Verify the example files exist:
    Navigate to the hello example's jni directory:

    cd ~/Downloads/android-ndk-r11/sources/hello/jni
    

    Run ls to check for hello.c—you should see it alongside Android.mk.

  3. Run ndk-build correctly:
    From the jni directory, just run:

    ndk-build
    

    If you're running it from another location, use the -C flag to point to the hello example's root folder:

    ndk-build -C ~/Downloads/android-ndk-r11/sources/hello
    

Quick Final Check

To make running ndk-build easier long-term, you can add the NDK's root directory to your system PATH, or always call it using the full path:

~/Downloads/android-ndk-r11/ndk-build

内容的提问来源于stack exchange,提问作者Andy Lee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:01:27