C/c++ File On Jni Folder Filled With Errors
Solution 1:
What is wrong with my library?
I don't think anything is wrong with your library. I believe this is a bug in ADT under Eclipse. See these AOSP bugs:
- Issue 33788: [ADT 20] Indexer support regression
- Issue 97023: Eclipse/ADT plugin cannot locate symbols for r10d NDK
How do I fix it?
Well, there are lots of workarounds offered in Issue 33788: [ADT 20] Indexer support regression. Some of them are from AOSP and some of them are from regular users.
what should I do in order to allow Android Studio users import it?
Sorry, I can't help here because I don't use Android Studio. I know Android Studio ignores Application.mk
and Android.mk
, so you might need to add the paths through gradle.build
(I think that's what its called).
(It appears the ADT plugin under Eclipse builds paths by parsing Application.mk
and Android.mk
).
Solution 2:
As you know Google announced the new update of Android studio 1.3 RC3, and finally we get C++ support. I configure my app this way and everything working just fine.
Fallow this steps...
- Run Android Studio 1.3 RC3 and click
Import Project (Eclipse ADT, Gradle, etc.)
- See this and this to configure your app.
In
project structure
(cmd + ; in Mac OS) setGradle version
to1
and Android Plugin Version
leave blank
Then configure you app.gradle file
android.ndk { moduleName = "MY_MODULE_NAME"// this is your additional include files, // do this if you have subfolder inside of JNI folder cppFlags += "-I${file("src/main/jni/myFolder/Sources")}".toString() cppFlags += "-I${file("src/main/jni/myFolder/Sources/Helper")}".toString() cppFlags += "-I${file("src/main/jni/myFolder/Sources/Image")}".toString() cppFlags += "-I${file("src/main/jni/myFolder/Sources/Utils")}".toString() // add c++ 11 support cppFlags += "-std=c++11"// your libs ldLibs += ["log", "jnigraphics"] stl = "gnustl_static" }
if you want to use for example cpufeatures , you must add it to your JNI folder. Then in app.gradle file specify path to it in this way .
cppFlags += "-I${file("src/main/jni/cpufeatures")}".toString()
My app.gradle file
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 21
buildToolsVersion = "22.0.1"
defaultConfig.with {
applicationId = "com.example.testapp"
minSdkVersion.apiLevel = 17
targetSdkVersion.apiLevel = 22
}
}
android.ndk {
moduleName = "MY_MODULE_NAME"// this is your additional include files, // do this if you have subfolder inside of JNI folder
cppFlags += "-I${file("src/main/jni/myFolder/Sources")}".toString()
cppFlags += "-I${file("src/main/jni/myFolder/Sources/Helper")}".toString()
cppFlags += "-I${file("src/main/jni/myFolder/Sources/Image")}".toString()
cppFlags += "-I${file("src/main/jni/myFolder/Sources/Utils")}".toString()
// add c++ 11 support
cppFlags += "-std=c++11"// your libs
ldLibs += ["log", "jnigraphics"]
stl = "gnustl_static"
}
// jni is the default dir; config this if yours is in different directory
android.sources {
main {
jni {
source {
srcDirs 'src/main/jni'
}
}
}
}
android.buildTypes {
release {
isMinifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}
android.productFlavors {
create ("arm7") {
ndk.abiFilters += "armeabi-v7a"
}
create ("arm8") {
ndk.abiFilters += "arm64-v8a"
}
create ("x86-32") {
ndk.abiFilters += "x86"
}
// for detailed abiFilter descriptions, refer to "Supported ABIs" @// https://developer.android.com/ndk/guides/abis.html#sa// build one including all productFlavors
create("fat")
}
}
My project gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript{
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
My gradle-wrapper.properties file
#Mon Jul 20 16:12:41 AMT 2015distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-rc-1-all.zip
P.S my reputation is not allowing me to post images, sorry
Post a Comment for "C/c++ File On Jni Folder Filled With Errors"