JNI error thrown during Google input method call

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.