1

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 Java's world.

The problem

Now that I try to import it, I fail to do so on both Eclipse and Android-Studio.

For Android-Studio, I can understand, since it doesn't really support it well yet, but for Eclipse, I've done it many times and it worked fine. I've even made a tutorial based on the problems I've collected over time.

No matter what I do, this is what I get:

enter image description here

A lot of errors in the form of "Type 'X' could not be resolved" .

This also leads to failure in creating the files the sample needs in order to run.

On Android Studio, I get this error:

enter image description here

System Info

Windows 8.1 64bit, Eclipse 4.4.1, ADT 23.0.4.1468518, NDK r10d 64bit

The question

How do I fix it?

What is wrong with my library?

Also, what should I do in order to allow Android Studio users import it?

jww
  • 83,594
  • 69
  • 338
  • 732
android developer
  • 106,412
  • 122
  • 641
  • 1,128
  • I'm not an Eclipse guy but it looks like something is wrong with NDK configuration/location. – Denis Kniazhev Jan 12 '15 at 21:28
  • But NDK is installed just fine... It's just a file that I extract... Can you please try it out? to see if you can import and run the sample? – android developer Jan 12 '15 at 21:34
  • I don't have eclipse installed, but in Android Studio I can import and run the example just fine. – Denis Kniazhev Jan 12 '15 at 21:41
  • Really? can you please post it ? Maybe via Google Drive? So that I could import and run it? – android developer Jan 12 '15 at 21:57
  • Post what? I use the copy from the master of your github repo. Have you tried to google what may be causing it, for example https://www.google.com.ua/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=android+ndk+aborting+stop – Denis Kniazhev Jan 12 '15 at 22:00
  • yes, but nothing has helped. Please just compress what you have that works, and let me try it out. maybe something went completely wrong here. – android developer Jan 12 '15 at 22:08
  • *A lot of errors in the form of "Type 'X' could not be resolved..."* - does it build? I have a similar open question at [How to change built-in C/C++ paths pointing to a deleted android-ndk-r9 installation?](http://stackoverflow.com/q/27898114/608639). I think I have the some of the same symptoms, but the project builds and the `libs` directory is populated. – jww Jan 13 '15 at 00:42
  • @jww All of the errors are in this format, so there isn't much to look at . Also, it's not blurry at all. Just open the image on a new tab. about it being built, if I run the app, it crashes because it can't find the needed compiled C/C++ code... – android developer Jan 13 '15 at 06:25
  • I clone your project and do the same step in `README.md`, and didn't find the errors as you described. Eclipse 4.4.1 with latest ADT installed. – alijandro Jan 13 '15 at 07:50
  • @alijandro I know. I didn't have those issues in the past. I have no idea what's going on... Have you also tried opening the C/CPP file and seeing if it shows any errors? It's quite annoying to edit this file this way... Have you also tried Android-Studio? – android developer Jan 13 '15 at 10:51
  • The C/C++ files are fine in Eclipse, no error show and the whole project can be built and run without error. Sadly I had the error when do the `:JniBitmapOperationsLibrary:compileDebugNdk` compile tasks in Android studio. – alijandro Jan 13 '15 at 12:07
  • @alijandro so you don't see what I've shown on the screenshot (on Eclipse) ? how odd. I've tried to re-install the NDK and Eclipse, but it still occurred . About Android Studio, that's even harder, as I'm quite a newb with it. Wish it was simpler and easier. It's just a single file... – android developer Jan 13 '15 at 17:23
  • Related: there's now an open bug report on AOSP for this issue under Eclipse: [Eclipse/ADT plugin cannot locate symbols for r10d NDK](https://code.google.com/p/android/issues/detail?id=97023). – jww Jan 14 '15 at 06:14
  • @jww So others have it too? – android developer Jan 14 '15 at 06:17
  • @jww I have : Eclipse 4.4.1, ADT 23.0.4.1468518 , NDK r10d 64bit, Windows 8.1 64bit. – android developer Jan 14 '15 at 06:33
  • Possible duplicate of [Android NDK build, Method could not be resolved](http://stackoverflow.com/questions/23155676/android-ndk-build-method-could-not-be-resolved) – jww Jun 05 '15 at 07:25
  • @jww Now that Eclipse's ADT&NDK plugins are no longer being supported by Google, my question goes to how to do it on Android Studio – android developer Jun 05 '15 at 19:33

2 Answers2

0

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

jww
  • 83,594
  • 69
  • 338
  • 732
0

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 1 and Android Plugin Version leave 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 2015
distributionBase=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