android中ndk编译错误,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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值