我得到了NDK函数的这些未定义错误:
In file included from /home/user/orwell2/myapp_flutter_app/android/app/src/main/cpp/MediaCodecDecoder.cpp:5:
/home/user/myapp3/myapp_flutter/android/app/src/main/cpp/MediaCodecDecodedFrame.h:24:3: error: use of undeclared identifier 'AMediaCodec_releaseOutputBuffer'
AMediaCodec_releaseOutputBuffer(aMediaCodec, outputBufferIndex, false);
^
/home/user/myapp3/myapp_flutter/android/app/src/main/cpp/MediaCodecDecoder.cpp:31:22: error: use of undeclared identifier 'AMediaFormat_new'; did you mean 'AMediaFormat'?
format.reset(AMediaFormat_new());
^
/home/user/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/media/NdkMediaFormat.h:47:29: note: 'AMediaFormat' declared here
typedef struct AMediaFormat AMediaFormat;
^
但我包括了它的标题:
#include "media/NdkMediaFormat.h"
#include "media/NdkMediaMuxer.h"
#include "media/NdkMediaCodec.h"
#include "media/NdkMediaExtractor.h"
我没有包含错误。我正在安卓工作室上构建。以前是有效的,现在不行了。我不知道是什么原因造成的。
我也试过
#include <NdkImage.h>
#include <NdkImageReader.h>
#include <NdkMediaCodec.h>
#include <NdkMediaCrypto.h>
#include <NdkMediaDrm.h>
#include <NdkMediaError.h>
#include <NdkMediaExtractor.h>
#include <NdkMediaFormat.h>
#include <NdkMediaMuxer.h>
就像这里说的:https://developer.android.com/ndk/reference/group/media但没有奏效。
我的NDK版本是21.3.6528147
和
minSdkVersion 18
targetSdkVersion 28
我也试过ndk21.1.6352462
解决方案:将最低sdk版本提高到21,因为这就是插入的地方
minSdkVersion 21