简体   繁体   English

Android Studio ndk-build找不到文件

[英]Android Studio ndk-build can't find files

I 'm trying to compile OPUS in Android Studio. 我正在尝试在Android Studio中编译OPUS。 When I call ndk-build from command line, everything works fine. 当我从命令行调用ndk-build时,一切正常。 When I build it from Android Studio, it fails. 当我从Android Studio构建它时,它失败了。

My app.gradle: 我的app.gradle:

externalNativeBuild {
    ndkBuild {
        path 'src/main/jni/Android.mk'
    }
}

Android.mk has some includes: Android.mk包括:

include celt_sources.mk

The error: 错误:

Error while executing process G:\ASDK\ndk-bundle\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=F:\TP2\ram\android\app\src\main\jni\Android.mk NDK_APPLICATION_MK=F:\TP2\ram\android\app\src\main\jni\Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=0 APP_PLATFORM=android-19 NDK_OUT=F:/TP2/ram/android/app/build/intermediates/ndkBuild/release/obj NDK_LIBS_OUT=F:\TP2\ram\android\app\build\intermediates\ndkBuild\release\lib APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}

Why NDK_PROJECT_PATH null? 为什么NDK_PROJECT_PATH为null? How do I tell Android Studio to set the current directory before calling ndk-build? 如何在调用ndk-build之前告诉Android Studio设置当前目录?

Best, 最好,

You probably followed this or similar solution to prepare opus for Android build. 您可能已遵循解决方案或类似的解决方案来为Android构建做准备。 The statements like 像这样的陈述

include celt_sources.mk

are not a good practice, because they force you to run ndk-build in the same directory as the Android.mk file. 这不是一个好习惯,因为它们会迫使您在与Android.mk文件相同的目录中运行ndk-build It's not too hard to force Android Studio work this way, add the following block to your build.gradle : 强制以这种方式运行Android Studio并不难,将以下代码块添加到build.gradle中

android {
    defaultConfig {
        externalNativeBuild {
            ndkBuild {
                arguments '-C src/main/jni'
            }
        }
    }
}

But it is much cleaner to follow one of the many other versions of Android.mk for opus that can be found on the WWW, eg this one which uses 但是,遵循WWW上可以找到的其他许多版本的Android.mk中的一种更为干净,例如, 该版本使用

include $(LOCAL_PATH)/celt_sources.mk

This way, the build doesn't depend on working directory for ndk-build command. 这样,生成就不依赖于ndk-build命令的工作目录。

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

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