12
Je suis en train de compiler les éléments suivants pour le NDK AndroidAndroid C++ NDK
#include <jni.h>
#include <string.h>
extern "C" {
JNIEXPORT jstring JNICALL Java_com_knucklegames_helloCpp_testFunction(JNIEnv * env, jobject obj);
};
JNIEXPORT jstring JNICALL Java_com_knucklegames_helloCpp_testFunction(JNIEnv *env, jobject obj) {
return env->NewStringUTF(env, "Hello from native code!");
}
mais il donne l'erreur suivante
Compile++ thumb: helloCpp <= /cygdrive/c/workspace/helloCpp/jni/main.cpp
/cygdrive/c/workspace/helloCpp/jni/main.cpp: In function '_jstring* Java_com_knucklegames_hello
Cpp_testFunction(JNIEnv*, _jobject*)':
/cygdrive/c/workspace/helloCpp/jni/main.cpp:10: error: no matching function for call to '_JNIEn
v::NewStringUTF(JNIEnv*&, const char [24])'
/cygdrive/d/android/android-ndk-r4b/build/platforms/android-8/arch-arm/usr/include/jni.h:839: note: candidates
are: _jstring* _JNIEnv::NewStringUTF(const char*)
make: *** [/cygdrive/c/workspace/helloCpp/obj/local/armeabi/objs/helloCpp/main.o] Error 1
Merci cela a résolu l'erreur, mais il est maintenant la fermeture de force lors de la tentative de chargement de la librairie. Il est dans le dossier lib sous le nom de libhelloCpp.so et static {System.loadLibrary ("helloCpp"); } est le problème – Will03uk
Si vous avez une autre question, vous devriez faire un autre post. Plus de gens sont susceptibles de voir cela de cette façon. –
Assurez-vous que .so est sous libs/armeabi; lorsque l'APK est installé sur l'appareil, vous devriez le voir sous /data/data/com.knucklegames.helloCpp/lib/libhelloCpp.so – I82Much