Reputation: 123
I add a gradle project to Android Studio. The project is built like this previously: First call a python script, the script will call ndk-build to build a .so, then call gradle script to archive a .apk.
After import to Android Studio, I add a externalNativeBuild block to the build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "org.cocos2dx.Game"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
externalNativeBuild {
ndkBuild {
abiFilters "x86"
arguments "-j3"
}
}
}
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
jniLibs.srcDir "libs"
manifest.srcFile "AndroidManifest.xml"
assets.srcDir "assets"
}
signingConfigs {
release {
if (project.hasProperty("RELEASE_STORE_FILE")) {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
}
debug {
debuggable true
jniDebuggable true
externalNativeBuild {
ndkBuild {
cFlags "-DDEBUG=1"
}
}
}
}
externalNativeBuild {
ndkBuild {
path "jni/Android.mk"
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':libcocos2dx')
}
task cleanAssets(type: Delete) {
delete 'assets'
}
task copyAssets(type: Copy) {
from '../../Resources'
into 'assets'
}
clean.dependsOn cleanAssets
preBuild.dependsOn copyAssets
The project successfully compiled, and installed, and run.But when signal happens, all function names in stack are in gray color, Clicking the function cannot navigate to c++ code (But the name of the function is right). If open the code manually, it always showing "This file is not part of the project" on top of the code.
I'm pretty sure the c++ codes are well compiled, How did this happen?
Upvotes: 2
Views: 959
Reputation: 123
Fixed it by myself. I changed the NDK version from 9b to 13, problem solved. Nobody tells me about this, I tried everything and finally found the solution was so simple. So I post this answer, just in case I can save some other's time.
The error report won't tell you "go and upgrade the NDK", but if some odd thing happens, try this first. In this case, I think it is because of some bugs in ndk toolchain, which are fixed in the higher version.
Upvotes: 1