android.mk文件在,gradle - 如何在Android Studio中使用我自己的Android.mk文件 - 堆栈内存溢出...

我在Android.mk文件中定义了一些变量(我为编译器传递了一些标志),但是每次构建项目时, Android.mk被覆盖。 我假设Gradle负责任,我应该去那里找吗? 如何使用自己的Android.mk文件?

背景信息:

Ubuntu 64位, Android Studio 1.0.1,JDK7。 我已经包裹着我的NDK版本的O型LLVM NDK ,因此上午编辑Android.mk位于文件app/build/intermediates/ndk/debug (这是唯一Android.mk我的项目目录中的文件),不同的O-LLVM的文档提供示例的位置。

另外,没有Application.mk文件,因此我再次假设Gradle负责对编译器的调用?

更新信息

build.gradle- (应用程序)

//The following code until the "----" line is the new build.gradle config file

// that disables automatic Android.mk file generation

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'

android {

compileSdkVersion 21

buildToolsVersion "21.1.2"

defaultConfig {

applicationId "com.md.helloworld"

minSdkVersion 15

targetSdkVersion 21

versionCode 1

versionName "1.0"

ndk {

moduleName "MyLib"

}

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

sourceSets.main {

jniLibs.srcDir 'src/main/libs' //set libs as .so's location instead of jni

jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk file

}

// Call regular ndk-build (.cmd) script from the app directory

task ndkBuild(type: Exec) {

commandLine 'ndk-build', '-C', file('src/main/').absolutePath

}

tasks.withType(JavaCompile) {

compileTask -> compileTask.dependsOn ndkBuild

}

}

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:21.0.3'

}

/*

//The following code is the original Android.mk file

apply plugin: 'com.android.application'

android {

compileSdkVersion 21

buildToolsVersion "21.1.2"

defaultConfig {

applicationId "com.md.helloworld"

minSdkVersion 15

targetSdkVersion 21

versionCode 1

versionName "1.0"

//The only modified line

ndk {

moduleName "MyLib"

}

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

}

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:21.0.3'

}

*/

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := helloWorld

LOCAL_SRC_FILES := main.c

LOCAL_LDLIBS := -static

include $(BUILD_EXECUTABLE)

Application.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

APP_ABI := armeabi

NDK_TOOLCHAIN_VERSION := clang3.4-obfuscator

include $(BUILD_EXECUTABLE)

请注意:我现在还没有传递任何标志,我正在尝试首先使用Vanilla构建

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值