androidstudio中用ndk编译的问题
我在Ubuntu上将已编译好的ffmpeg放入我的androidstudio工程,配置OK后,为什么他提示
Error:(319, 10) fatal error: 'libavcodec/avcodec.h' file not found
而同样的我在cmd里,进入到项止jni目录,用ndk-build直接编译就不会出现这个问题,求大神指点
这是我gradle的代码
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.zyt.vm.lp"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
jniDebuggable true
}
}
sourceSets.main {
jni.srcDirs = [] // This prevents the auto generation of Android.mk
jniLibs.srcDir 'src/main/libs' // This is not necessary unless you have precompiled libraries in your project.
//jniLibs.srcDirs = ['src/main/libs','src/main/jniLibs']
}
externalNativeBuild{
ndkBuild{
path file('src\\main\\jni\\Android.mk')
}
}
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build.cmd",
'-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source
'-j', Runtime.runtime.availableProcessors(),
'all',
'NDK_DEBUG=1',
'NDK_LOG=1'
}
task cleanNative(type: Exec, description: 'Clean JNI object files') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build.cmd",
'-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source
'clean'
}
clean.dependsOn 'cleanNative'
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.0'
testCompile 'junit:junit:4.12'
}
########################################################################################################################################################
# LivePublisher Complie
########################################################################################################################################################
include $(CLEAR_VARS)
LOCAL_MODULE := LivePublisher
LOCAL_SRC_FILES := LivePublisher.c
#LOCAL_C_INCLUDES := \
#$(FFInclude)
LOCAL_LDLIBS:=-llog -lz -lm -landroid
LOCAL_SHARED_LIBRARIES := avformat avutil avcodec avfilter postproc swresample swscale
#LOCAL_CFLAGS:= "-I$(FF)/ffmpeg/include"
include $(BUILD_SHARED_LIBRARY)
编译好的几个库大体都是这样写的
#libavformat
include $(CLEAR_VARS)
LOCAL_MODULE := avformat
LOCAL_SRC_FILES := $(FF)/libavformat.so
LOCAL_EXPORT_C_INCLUDES := $(FFInclude)
include $(PREBUILT_SHARED_LIBRARY)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论