我想在函数PrintLog()中使用类成员“tvLog”,它将在C ++中的JNI中调用。但它导致了“关闭虚拟机......致命异常:主要......”错误。谁能告诉我为什么?
simple_test.java:
public class simple_test extends Activity {
private TextView tvLog = (TextView)findViewById(R.id.LogTextView);
public int PrintLog(int i) {
tvLog.setText("Log from JNI");
return 0;
}
}
demo_jni.cpp
...
mid = env->GetMethodID(cls, "PrintLog", "(I)I");
...
int ret = env->CallIntMethod(obj, mid, 1);
...
main.xml中:
<TextView android:text="" android:layout_x="14dp" android:layout_y="147dp" android:layout_width="290dp" android:layout_height="98dp" android:id="@+id/LogTextView"></TextView>
答案 0 :(得分:0)
private TextView tvLog
==&gt;
static private TextView tvLog