- 用javah產生 *.h 檔時:
/opt/java/jdk1.7.0_67/bin/javah -classpath /opt/eclipse/android-sdk-linux/platforms/android-17/android.jar:../bin/classes ManiActivity
在開發app時需注意 android:minSdkVersion="19" 要符合上述的 level (android-17)
這裡一個寫17,一個寫19,會有問題 - 碰到JNIEnv cannot be resolved,擅用 Build Project 可以解決 (專案滑鼠右鍵)
- 專案 > 滑鼠右鍵 > Properties > C/C++ General > Paths and Symbols > Include 下
確定有 android:minSdkVersion 和 android:maxSdkVersion 有對應的ndk path
/opt/android-ndk-r10b/platforms/android-17/arch-arm/usr/include
/opt/android-ndk-r10b/platforms/android-19/arch-arm/usr/include - error: parameter name omitted
JNIEXPORT jint JNICALL Java_com_uart_NativeUART_sendinfo (JNIEnv *env, jobject obj, jint i, jstring str);
從 *.h 拷貝到 *.c 時,參數要記得填上 ( c++ 好像可以不用填) - Type 'JNICALL' could not be resolved
專案目錄下 > vim .project > 把 ccnature 整行拿掉<
natures
>
<
nature
>com.android.ide.eclipse.adt.AndroidNature</
nature
>
<
nature
>org.eclipse.jdt.core.javanature</
nature
>
<
nature
>org.eclipse.cdt.core.cnature</
nature
>
<
nature
>org.eclipse.cdt.core.ccnature</
nature
>
<
nature
>org.eclipse.cdt.managedbuilder.core.managedBuildNature</
nature
>
<
nature
>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</
nature
>
<
nature
>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</
nature
>
</
natures
>
ref:
沒有留言:
張貼留言