4

i am trying to use the NDK in eclipse but when following a tutorial this error pops up and i do not understand where it comes from

this is my .h file

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_example_myproject_MainActivity */

#ifndef _Included_com_example_myproject_MainActivity
#define _Included_com_example_myproject_MainActivity
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     com_example_myproject_MainActivity
 * Method:    getMyData
 * Signature: ()Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_com_example_myproject_MainActivity_getMyData
  (JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

Error = Type 'JNICALL' could not be resolved

i also have syntax errors in the code view but these do not show up between the errors these appear with JNIEXPORT

aerlfredith
  • 1,123
  • 4
  • 12
  • 18
  • Read my answer here: http://stackoverflow.com/questions/11666711/type-jint-could-not-be-resolved-and-jnienv-jclass/12568538#12568538 Maybe it will help you. – Yury Sep 24 '12 at 15:51

3 Answers3

3

For the most part, JNICALL is used in windows. I'm 99% sure you can add

#define JNICALL

(define it as a blank)

Same with JNIEXPORT.

yhyrcanus
  • 3,743
  • 2
  • 23
  • 28
  • shouldn`t these be declared in a file or system that eclipse and JDK know already, yes those defines will get rid of the errors but wil make any intended functionality void, wont it?? thanks, – aerlfredith Jul 19 '12 at 13:06
  • Well ususally JNI.h has defines for if _WIN32_ that basically assign JNICALL to __stdcall and JNIIMPORT to __declspec(dllimport). Unix systems don't need these extra tags, so they define them away. – yhyrcanus Jul 19 '12 at 13:09
  • Solved My tutorial neglected to mention some extra includes, apparently in their version of the ndk and eclipse these include can be added later thanks anyhow – aerlfredith Jul 19 '12 at 13:19
1

Go to Project Properties->C/C++ General->Paths and Symbols.

  1. Select Include tab and click on Add button right side of window
  2. Choose include directory from File system

For example: C:\Program Files (x86)\Android\android-sdk\NDK\android-ndk-r10\platforms\android-L\arch-arm\usr\include.

It will ask you if you want to rebuild, click on yes...Done

Dayanand Waghmare
  • 2,979
  • 1
  • 22
  • 27
0

I just encountered this problem, here is my solution. If you worked on Linux with Java 7, make sure these two include paths were added to you Includes

/usr/lib64/jvm/java-7-oracle/include/linux
/usr/lib64/jvm/java-7-oracle/include
alijandro
  • 11,627
  • 2
  • 58
  • 74