Yesterday I received a bug about an exception reported after calling the Google input method. The log information is probably that the JNI method nativeimopendecoder () cannot be found (),
The target_build_variant option before compiling the system is user, which is different from that used in normal time. If you re-run the ENG and user versions, the problem exists, I didn't want to directly go to the Make script at the beginning, because it must be different. After half an hour, I was dizzy. The most important thing was that I didn't see it clearly and gave up...
Later, I compared the userversion with the Google pinyin.apk version of engzhou, and found that the size of the user version is less than 100 bytes. The original code is missing and the user version is online.
Find the decompilation tool, and finally confirm it in pinyindecoderservice. the nativeimopendecoder () method is missing in the Java class. This method is the native method, so it is loaded. when the so file does not find this method, an exception is reported, and the reference is found in the project, it is known that the entire project has not called this method, at this point, we can determine that the system has been optimized during compilation, and useless code has been filtered out. Well, I will keep this method forcibly during compilation. I learned that the Android system uses proguard for code optimization and obfuscation. OK, refer to other android systems. parameters are added to the MK file:
Local_proguard_flags: =-include $ (local_path)/proguard. flags
The proguard. Flags file is created, with the following content:
-Keep class com. Android. inputmethod. Pinyin. pinyindecoderservice {
Static *;
}
Finally, recompile and test the code. You can call the Google input method successfully.
In summary, proguard plays a key role in the code compilation process, so it is necessary to understand it,Let's take a look at the following articles:
Http://www.cnitblog.com/zouzheng/archive/2011/01/12/72639.html