1

I create my first NDK project, that show some text on screen. I use native method in class NativeLib in java and implement in a class in C. But I received an error base operand of '->' has non-pointer type 'JNIEnv {aka _JNIEnv}

 #include <jni.h>
 #include <string.h>
 #include <stdio.h>
 #include <android/log.h>

#define DEBUG_TAG "MY_NDK_DEMO"
JNIEXPORT jstring JNICALL Java_com_example_helloworld_NativeLib_helloWorld
  (JNIEnv * env, jobject obj) {
    return (*env)->NewStringUTF("Hello World JNI!");
}
Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Minato
  • 111
  • 1
  • 4
  • 9
  • Possible duplicate of [error: base operand of ‘->’ has non-pointer type ‘JNIEnv’](http://stackoverflow.com/questions/15764948/error-base-operand-of-has-non-pointer-type-jnienv) – Ciro Santilli OurBigBook.com Jun 22 '16 at 17:27

2 Answers2

6

try return env->NewStringUTF("Hello World JNI!");

Tpec1k
  • 363
  • 2
  • 10
1

c++ is different from c so to make it work use env->NewStringUTF("Hy");