In Android, compiled projects use the Ultimate version of the import method to third-party jars!

Source: Internet
Author: User

1, third-party jar packages are often used when compiling their own projects in an Android system environment. These jar packages add compilation to Eclipse, all the way through, because Eclipse has helped you configure it. However, when the project is copied to the system environment, the jar package will not work. The following is the problem of their own, through the search of online information, encountered various problems, finally finally resolved. Summarize through the blog, to share with you.


conditions: For example, an application developed in eclipse with SUPPORT-V4 packages and third-party Pinyin4j-2.5.0.jar.
migrated to the System project, the compilation does not pass. Take the System music application as an example.
1, the first is to join the Android.mk file
local_path:= $ (call My-dir)
include $ (clear_vars)
local_module_tags: = optional
local_src_files: = $ (call All-java-files-under, SRC) \
Src/com/android/music/imediaplaybackservice.aidl
local_package_name: = Music
local_proguard_flag_files: = Proguard.flags
include $ (build_package)
The compilation will not find the corresponding classes and methods in the referenced package.
2, and then in the declaration package, add in. mk
local_path:= $ (call My-dir)
include $ (clear_vars)
local_module_tags: = optional
#声明包名
local_static_java_libraries: = android-support-v4 pinyin4j-2.5.0
local_src_files: = $ (call All-java-files-under, SRC) \
Src/com/android/music/aidl/imediaservice.aidl
local_package_name: = Music
include $ (build_package)
include $ (clear_vars)
#指明包的位置
local_prebuilt_static_java_libraries: = Pinyin4j-2.5.0:lib/pinyin4j-2.5.0.jar
include $ (build_multi_prebuilt)
3, the compilation may also be error. (.... can ' t find superclass or interface ... )
Warning:demo. Pinyin4jappletdemo$1:can ' t find superclass or interface Java.awt.event.WindowAdapter
Warning:demo. Pinyin4jappletdemo$3:can ' t find superclass or interface Java.awt.event.ActionListener
Warning:demo. Pinyin4jappletdemo$2:can ' t find superclass or interface Java.awt.event.ActionListener
Warning:demo. Pinyin4jappletdemo:can ' t find superclass or interface Javax.swing.JApplet
Warning:demo. Pinyin4jappletdemo$1:can ' t find referenced class Java.awt.event.WindowAdapter
Warning:demo. Pinyin4jappletdemo$1:can ' t find referenced method ' void Stop () ' in class demo. Pinyin4jappletdemo
Warning:demo. Pinyin4jappletdemo$1:can ' t find referenced method ' void Destroy () ' in class demo. Pinyin4jappletdemo
Warning:demo. Pinyin4jappletdemo$1:can ' t find referenced class Java.awt.event.WindowAdapter
Warning:demo. Pinyin4jappletdemo$1:can ' t find referenced class Java.awt.event.WindowEvent
Warning:demo. Pinyin4jappletdemo$3:can ' t find referenced class Javax.swing.JComboBox
Warning:demo. Pinyin4jappletdemo$3:can ' t find referenced class Javax.swing.JComboBox
This is like confusing compilation errors, and then creating the Proguard.cfg file in the root of the app, typing in:
-dontwarn demo.**
-keep class demo.** {*;}  

Check the compiler error, there are several packages error, just add a few of these statements. Here is the demo. Below the Java error, just add this on the line. The identity of this file is then added to the android.mk.
local_proguard_flag_files: = Proguard.cfg

then in the compilation, it should be possible to pass.
Done ...


2, and then another jar package, a new problem occurred: The following are the warring:

Warning:org.opencv.android.CameraBridgeViewBase:can ' t find referenced class org.opencv.r$styleable
Warning:org.opencv.android.CameraBridgeViewBase:can ' t find referenced class org.opencv.r$styleable
Warning:org.opencv.android.CameraBridgeViewBase:can ' t find referenced class ORG.OPENCV.R

xxxxx

Warning:there were 3 unresolved references to classes or interfaces.
Need to specify additional library jars (using '-libraryjars '),
Or perhaps the '-dontskipnonpubliclibraryclasses ' option.


Using the method above will not work. But add one sentence to the proguard.cfg file to ignore warring.

-ignorewarnings



The solution is to find on the Internet, to summarize their own. Thank you for sharing on the Internet.

In Android, compiled projects use the Ultimate version of the import method to third-party jars!

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.