Issue
I'm porting C++ library to Android now. I did initial work already and got it build in Application.mk/Android.mk way.
The upcoming Java demo application for library is developing in Android Studio now. I can built everything (demo + library) together - thanks to StackOverflow community.
However I have no access to native debugging in these builds. But debugging is necessary - library is not stable enough yet. Pure console GDB debugging takes too much time for now and can consume more hours in future.
So I decided to make build with Android Studio and Gradle to use integrated debugger.
I have dedicated library module with NDK and Java (wrapper) parts. However C/C++ source files are not under jni/ subdirectory. They are located in another directory.
Therefore I can configure Gradle to get sources from that directory. I tried smth like this:
apply plugin: 'com.android.model.library'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
minSdkVersion.apiLevel = 10
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
}
ndk {
moduleName = "inttalksdk"
stl "gnustl_shared"
cppFlags.add("-std=c++11")
cppFlags.add("-fexceptions")
ldLibs.addAll(['log'])
}
}
android.sources {
main.jni.source {
srcDirs.add(["src"])
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-android.txt'))
}
}
}
But AS cannot sync project even. Error message is:
Gradle 'Android' project refresh failed
Error:Attempt to read a write only view of model of type 'java.lang.Object' given to rule 'android.sources { ... } @ inttalksdk/build.gradle line 24, column 5'
My true question is: how to add these external C/C++ files into Gradle build?
I use latest AS 2.0 + 0.7.0 beta3 experimental plugin.
Please help.
Solution
Problem was in 0.7.0-beta3 experimental plugin. I reverted to 0.6.0 version. This syntax was ok:
android.sources {
main {
jni {
source {
srcDir "${project.ext.inttalksdk}/src/Components/Util/"
}
}
}
Answered By - Dmytro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.