I have a gradle-experimental 0.6.0-alpha1 compliant build.gradle file:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 21
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "com.company.application"
minSdkVersion.apiLevel = 21
targetSdkVersion.apiLevel = 21
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.pro'))
}
}
android.ndk {
moduleName = "moduleName"
}
}
dependencies {
compile project(':libcocos2dx')
}
And I am using cocos2dx as my engine. I have a folder hierarchy that looks like this:
- Classes (which contains all the C++ code of my project)
- proj.android/src/main/projectName/jni (which contains the main.cpp file for cocos2d to hook on)
I also have many other cpp classes that are in a different folders outside the proj.android one (the cocos2d cpp file for example are at proj.android/../../../dependencies/XXXX/cocos2d-x and the engine files are at proj.android/../../../dependencies/XXXX/engine, and all my C++ code is at proj.android/../Classes, as in every cocos2dx project)
I am trying to build my application using the latest gradle experimental plugin (gradle-experimental-0.6.0-alpha1).
I first try to build it as-is, project compile and run but was empty (no libMyApp.so was generated), because I didn't included any C++ source file in my gradle build.
I then made some symbolic link to the source file folder so that gradle could pick them:
ln -s proj.android/../../../dependencies/XXXX/cocos2d-x proj.android/src/main/projectName/jni
Now when I am building (./gradlew assembleDebug), I get it compile symboliquely linked C++ files, but it fails on the first include of header everytime, no matter what I try.
I have tried to add source file/ header include as described here using:
android.sources {
main {
jni {
source {
srcDir "src"
}
exportedHeaders {
srcDir "src"
}
}
}
}
but I couldn't get it to find the missing ".h" headers. If anybody has tried to build a consequent C++ project using cocos2Dx, gradle-experimental and android-studio please feel free to share any experience. I will try to compile some sort of guide when I will be able to compile it (one day :))
for reference: latest gradle doc:
https://docs.gradle.org/2.9/userguide/nativeBinaries.html
usefull link: