一、先写一个自己的jar包
我的jar包是testjar,建一个testjar的文件夹,里面的Android.mk
LOCAL_PATH:= $(call my-dir)
# MAP API module
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_MODULE := testjar
LOCAL_DEX_PREOPT := false
include $(BUILD_JAVA_LIBRARY)
在testjar建src/com/anwtest/anwbt/testjar.java
package com.anwtest.anwbt;
import android.util.Log;
public class testjar{
private static final String INFO_TAG = "testjar";
private static final boolean DBG = true;
private static testjar sTestjar;
public static synchronized testjar getDefaultAnwBtService(){
if(sTestjar == null){
Log.d(INFO_TAG,"sTestjar now new");
sTestjar = new testjar();
}else{
Log.d(INFO_TAG,"sTestjar has new, directly using");
}
return sTestjar;
}
public testjar()
{
debugLog("run testjar_1");
}
private void debugLog(String msg) {
if (DBG) {
Log.d(INFO_TAG, msg);
}
}
}
注意:LOCAL_DEX_PREOPT := false