# fix the crashing of google pinyin



## touchmypad (Jan 21, 2012)

Some of you might have encountered this annoying problem: once you change the input method to "Google Pinyin Chinese Input Method", it force closes and you have to go the setting and change the default input method to english. The patch is shown below, if you want to compile yourself.

If you just want to get it work, then download the attached file libjni_pinyinime.so and do:

```
<br />
$unzip libjni_pinyinime.zip # I zipped the .so file, since it exceeds the size limit of the forum attachment<br />
$adb shell mount -o rw,remount /system<br />
$adb push libjni_pinyinime.so /system/lib<br />
$adb shell mount -o ro,remount /system<br />
```


```
<br />
From bac4452b0112800aecd849777de96956c08e1808 Mon Sep 17 00:00:00 2001<br />
From: Shixin Zeng <[email protected]><br />
Date: Thu, 9 Feb 2012 02:11:35 +0100<br />
Subject: [PATCH] Fix the failure to register the methods<br />
For some reason, nativeImOpenDecoder couldn't be registered and cause<br />
the libjni_pinyinime.so fail to load. Since it was not used anywhere,<br />
I just commented it out and it fixes the problem. Still don't quite<br />
understand why.<br />
---<br />
...oid_inputmethod_pinyin_PinyinDecoderService.cpp |    2 ++<br />
.../inputmethod/pinyin/PinyinDecoderService.java   |    2 ++<br />
2 files changed, 4 insertions(+), 0 deletions(-)<br />
diff --git a/jni/android/com_android_inputmethod_pinyin_PinyinDecoderService.cpp b/jni/android/com_android_inputmethod_pinyin_PinyinDecoderService.cpp<br />
index dcb63a1..095f8e4 100644<br />
--- a/jni/android/com_android_inputmethod_pinyin_PinyinDecoderService.cpp<br />
+++ b/jni/android/com_android_inputmethod_pinyin_PinyinDecoderService.cpp<br />
@@ -310,8 +310,10 @@ JNIEXPORT jboolean JNICALL nativeSyncClearLastGot(JNIEnv *env, jclass clazz) {<br />
static JNINativeMethod gMethods[] = {<br />
	 /* name, signature, funcPtr */<br />
	 /* ------Functions for Pinyin-to-hanzi decoding begin--------->> */<br />
+#if 0<br />
	 { "nativeImOpenDecoder", "([B[B)Z",<br />
			 (void*) nativeImOpenDecoder },<br />
+#endif<br />
	 { "nativeImOpenDecoderFd", "(Ljava/io/FileDescriptor;JJ[B)Z",<br />
			 (void*) nativeImOpenDecoderFd },<br />
	 { "nativeImSetMaxLens", "(II)V",<br />
diff --git a/src/com/android/inputmethod/pinyin/PinyinDecoderService.java b/src/com/android/inputmethod/pinyin/PinyinDecoderService.java<br />
index a4a3ac4..aee6e49 100644<br />
--- a/src/com/android/inputmethod/pinyin/PinyinDecoderService.java<br />
+++ b/src/com/android/inputmethod/pinyin/PinyinDecoderService.java<br />
@@ -36,8 +36,10 @@ import android.util.Log;<br />
  * service so that both IME and IME-syncer can use it.<br />
  */<br />
public class PinyinDecoderService extends Service {<br />
+	   /** unused<br />
	 native static boolean nativeImOpenDecoder(byte fn_sys_dict[],<br />
			 byte fn_usr_dict[]);<br />
+	   */<br />
	 native static boolean nativeImOpenDecoderFd(FileDescriptor fd,<br />
			 long startOffset, long length, byte fn_usr_dict[]);<br />
--<br />
1.7.1<br />
```


----------

