9

I have an Android project with native code. I'm able to build native code from command line by calling ndk-build command with no errors or warnings. But when I open it in ADT it shows the following error.

enter image description here

Error message: Method CallStaticIntMethod could not be resolved. There are many files with similar errors in the project.

I double checked configuration and here is what I have. Android build, tool chain and includes are properly configured (see pictures below)

enter image description here

enter image description here

enter image description here

Required includes are also visible in the Project Explorer and they are valid (not empty and point to correct header files).

enter image description here

But when I Clean the project and Build it, the errors are still there. Any ideas on how to solve this?

Configuration: ADT 22.6.2, NDK r9d (64-bit), OSX 10.9.2

jww
  • 83,594
  • 69
  • 338
  • 732
sergej shafarenka
  • 19,464
  • 6
  • 62
  • 82

3 Answers3

11

After some struggling with preferences, I finally found a solution. This is a bug in NDK plugin which was reported to AOSP but not yet fixed. A past of the answer is described in comment #50. Here is the sequence which worked our for me.

  1. Open Project Properties -> C/C++ Build -> Tool Chan Editor
  2. In the section Used Tools replace Android GCC Compiler with GCC C Compiler. If section is empty, just add GCC C Compiler entry in there. enter image description here
  3. Open Project Properties -> C/C++ General -> Paths and Symbols and add directories, where your h-files to be included are located. Use Move up button to add a folder with your local includes (/AudioPlayer/jni in my case) to the first place. Then add platform and toolchains includes. Built-in includes should stay at the very bottom. enter image description here In my case the full paths to the toolchain includes were like below. These are built-in paths of original Android GCC Compiler toolchain, which we have replaced at step 2.

    /Tools/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.6/include
    /Tools/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.6/include-fixed
    
  4. Press OK button, clean and re-build the project. All errors must go away. If they stay, try to remove them from Problems view and re-build project once again.

Update: I have found another place, where you can add paths to include files. However it appears to be Eclipse version dependent. Project Settings -> C/C++ General -> Processor Include Paths, Macros etc. -> CDT User Settings Entries -> Add. After I added the paths listed above, there is no compilation issues anymore. Development is fun again.

sergej shafarenka
  • 19,464
  • 6
  • 62
  • 82
  • 1
    I did not have to do steps 1 and 2, so maybe not needed. Else this answer worked well for me. Thanks. – haffax Aug 10 '14 at 21:17
  • Hi, i have tried this solution. My all errors in C code gone but the project name still shows error symbol and due to this i am unable to run the project. I don't know exactly whats going wrong. Please suggest further – huzefa p Nov 30 '15 at 13:19
0

Yes, its caused by the IDE not knowing where all of your headers and any libs you linking again are. The errors are generated by the IDE's autocomplete/bug system. You can either fix your includes within eclipse or remove them as errors in the preferences. 

user2415486
  • 91
  • 1
  • 2
-1

I had a similar error and solved it by going to project->properties->discovery options and changing the discovery profile from managed build system to GCC, after changing to GCC C Complier from Android GCC Compiler and updating the include directories.

sig_seg_v
  • 530
  • 3
  • 14
  • How is this answer any different from beworker's answer 6 months earlier? Also see "me too" answers in [What is a “protected” question?](http://meta.stackexchange.com/q/52764) – jww Jun 05 '15 at 10:04
  • this is a different solution. beworker's answer didn't work for me. after I tried his solution, I fixed the problem by changing the discovery profile under discovery options. I'm not sure whether beworker's answer had anything to do with fixing the problem for me, I just thought I would mention that I tried his solution first just in case both steps were necessary. – sig_seg_v Jun 10 '15 at 02:58