課程
/移動(dòng)開(kāi)發(fā)
/Android
/Android-NDK進(jìn)階
老師,為什么最后在module/build.gradle中編譯了之后,native的sayhello方法還是報(bào)錯(cuò)沒(méi)有關(guān)聯(lián)頭文件,用的as3.0.0
2018-01-23
源自:Android-NDK進(jìn)階 2-1
正在回答
在jni目錄下創(chuàng)建Android.mk文件,在module/build.gradle中關(guān)聯(lián)配置,如下
module/build.gradle的內(nèi)容
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文件的內(nèi)容
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)
舉報(bào)
本課程為NDK開(kāi)發(fā)進(jìn)階教程,帶領(lǐng)大家掌握在Android Studio中開(kāi)發(fā)NDK的技能
1 回答Android Studio3.0 ndk無(wú)法自動(dòng)補(bǔ)全
1 回答gradle中ndk{}里邊的屬性怎么定位到屬性定義的類中?
2 回答求助:關(guān)于3.2 NDK C無(wú)法自動(dòng)補(bǔ)全問(wèn)題
1 回答通過(guò)您這種ndk開(kāi)發(fā)方式如何指定要編譯的c++文件?
1 回答調(diào)用已有好的 .so 庫(kù)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-01-23
在jni目錄下創(chuàng)建Android.mk文件,在module/build.gradle中關(guān)聯(lián)配置,如下
module/build.gradle的內(nèi)容
Android.mk文件的內(nèi)容