Skip to content Skip to sidebar Skip to footer

C/c++ File On Jni Folder Filled With Errors

Background In the past, I've made a nice Android library (link here) that allows the developers to contain a bitmap within C/C++ world, play with it, and later convert it back to J

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:


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...

  1. Run Android Studio 1.3 RC3 and click Import Project (Eclipse ADT, Gradle, etc.)
  2. See this and this to configure your app.
  3. In project structure (cmd + ; in Mac OS) set Gradle version to 1and Android Plugin Versionleave blank

  4. 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"