【发布时间】:2015-10-04 10:38:11
【问题描述】:
我正在将 Android 库 (.aar) 编译为包含一些本机代码并需要一些库的模块。这是build.gradle:
apply plugin: 'com.android.model.library'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
defaultConfig.with {
//
// NOTE: change the application ID to match the play console linked application.
//
applicationId = "org.anima.mrubybridge"
minSdkVersion.apiLevel = 18
targetSdkVersion.apiLevel = 18
}
}
android.ndk {
moduleName = "mrubybridge"
CFlags += "-I/home/dragos/Downloads/mruby-1.1.0/include"
CFlags += "-I/home/dragos/Downloads/mruby-1.1.0/include"
ldLibs += ["mruby"]
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.productFlavors {
create ("arm7") {
ndk.abiFilters += "armeabi-v7a"
ndk.ldFlags += "-L/home/dragos/Downloads/mruby-1.1.0/build/armeabi-v7a/lib"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
这会编译所有内容(我检查了 .class 和 .so 文件),但 .aar 档案几乎是空的,没有类或动态库。 (约 2.3KB)
在第二个模块中,我将其添加为依赖项:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.1"
defaultConfig.with {
//
// NOTE: change the application ID to match the play console linked application.
//
applicationId = "com.example.dragos.mrubytest"
minSdkVersion.apiLevel = 18
targetSdkVersion.apiLevel = 18
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
}
dependencies {
compile project(':mrubybridge')
compile fileTree(dir: 'libs', include: ['*.jar'])
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
但是当我尝试从其他模块添加 Java 类时,我得到:Error:(12, 29) error: package org.anima.mrubybridge does not exist,很可能是因为它们不在 .aar 中。
我已将该模块添加为依赖项 (compile project(':mrubybridge')),但它并没有真正的帮助。
【问题讨论】:
标签: android android-ndk android-gradle-plugin build.gradle