慕勒5262818
2018-01-23 21:05
老师,为什么最后在module/build.gradle中编译了之后,native的sayhello方法还是报错没有关联头文件,用的as3.0.0
在jni目录下创建Android.mk文件,在module/build.gradle中关联配置,如下
module/build.gradle的内容
apply plugin: 'com.android.application' android { compileSdkVersion 26 defaultConfig { applicationId "com.example.sun.jnidemo" minSdkVersion 15 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" ndk{ abiFilters "armeabi","armeabi-v7a" } } externalNativeBuild{ ndkBuild{ path "src/main/jni/Android.mk" } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' }
Android.mk文件的内容
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := hello LOCAL_SRC_FILES := Hello.cpp # for logging LOCAL_LDLIBS += -llog include $(BUILD_SHARED_LIBRARY)
Android-NDK进阶
10299 学习 · 21 问题
相似问题