2015-11-30 142 views
0

请帮助我。这是我在NDK中的第一个代码。 我将一切如何在此视频Using Native code (C,C++)表现,但我得到未发现本机方法: C文件名是“ndktest.c”未找到本地方法:

#include <jni.h> 
#include <string.h> 

extern "C" jstring Java_com_checksound_visualisator_MainActivity_helloWorld(JNIEnv* env, jobject obj) { 
    return (*env)->NewStringUTF(env, "Hello Urma"); 
} 

我的Java类是

package com.checksound.visualisator; 

public class MainActivity extends AppCompatActivity... 

public native String helloWorld(); 

static { 
    System.loadLibrary("ndktest"); 
} 
+0

你可以在'local.properties'和'build.gradle'文件中共享ndk的设置吗? – phongvan

+1

构建期间是否生成* .so文件? – Ajitha

+0

mdtuyen是ndk.dir = E \:\\ programms \\ android \\ android-ndk-r10e –

回答

0

@宗婷,

您可能想要检查C文件是否在JNI文件夹中。

其次,

在你的build.gradle,试加: 模型{

// The android{} block configure all android specific building options 

android { 
    compileSdkVersion 22 
    buildToolsVersion "23.0.3" 

    defaultConfig { 
     applicationId "com.checksound.visualisator" 
     minSdkVersion.apiLevel 22 
     targetSdkVersion.apiLevel 22 
     versionCode 1 
     versionName "1.0" 
    } 

    ndk { 
     moduleName = "native" 
    } 
} 

}

祝你好运!

相关问题