1,首先之是增加Android.mk文件
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)
编译会找不到引用的包中对应的类和方法。
2,然后在声明包,在.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,这时编译有可能还会报错。(...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
这好像的混淆编译造成的错误,然后在应用的根文件夹下建立proguard.cfg这个文件,在里面输入:
-dontwarn demo.**
-keep class demo.** { *;}
查看编译报的错误,有几个包出错。就在里面加几个这种声明。这里是有demo.下的java报错,仅仅加这个即可。然后在Android.mk中加入此文件的标识。
LOCAL_PROGUARD_FLAG_FILES := proguard.cfg
然后在编译。应该就能够通过。