In android, compiled projects use the third-party jar import method release version !, Androidjar

Source: Internet
Author: User

In android, compiled projects use the third-party jar import method release version !, Androidjar

1. Third-Party jar packages are often used when compiling your own projects in the android system environment. These jar packages can be added and compiled in eclipse, because eclipse has helped you configure them. However, when the project is copied to the system environment for compilation, the jar package will not work. The following are my own problems. By searching for online materials, I encountered various problems and finally solved them. I will share it with you through my blog.


Condition: for example: the application first developed in eclipse, use support-v4 package and third-party pinyin4j-2.5.0.jar.
It is ported to the system project and the compilation fails. Take the system music application as an example.
1. First, add 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 corresponding classes and methods in the referenced package cannot be found during compilation.
2. Then, in the declaration package, add in. mk
LOCAL_PATH: = $ (call my-dir)
Include $ (CLEAR_VARS)
LOCAL_MODULE_TAGS: = optional
# Declare the package name
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)
# Specify the package location
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES: = pinyin4j-2.5.0: lib/pinyin4j-2.5.0.jar
Include $ (BUILD_MULTI_PREBUILT)
3. An error may occur during compilation. (... 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. Warn wevent
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 seems to be an error caused by mixed compilation. Then, create the proguard. cfg file in the root directory of the application and enter:
-Dontwarn demo .**
-Keep class demo .**{*;}

Check the compilation errors. If there are several errors in the package, add several such statements in it. Here is the java error in demo., just add this. Then, add the identifier of the file to Android. mk.
LOCAL_PROGUARD_FLAG_FILES: = proguard. cfg

After compilation, you should be able to pass.
Success...


2, and then use another jar package, a new problem occurs: The following is the emergence of 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

×××××

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


The above method is useless. However, adding a sentence to the proguard. cfg file can ignore warring.

-Ignorewarnings



The solution is to find it on the Internet and summarize it. Thank you for your sharing on the Internet.

Related Article

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.