天天看点

源码编译环境集成LeakCanary                        源码编译环境集成LeakCanary

                        源码编译环境集成LeakCanary

        具体的android.mk编写如下,在最后会附上已经编译OK的jar和aar包。

# Copyright (C) 2009 The Android Open Source Project

#

# Licensed under the Apache License, Version 2.0 (the "License");

# you may not use this file except in compliance with the License.

# You may obtain a copy of the License at

#

#      http://www.apache.org/licenses/LICENSE-2.0

#

# Unless required by applicable law or agreed to in writing, software

# distributed under the License is distributed on an "AS IS" BASIS,

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

# See the License for the specific language governing permissions and

# limitations under the License.

#


LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_JAVA_LIBRARIES := services
LOCAL_SRC_FILES := $(call all-java-files-under, src)

	
	
LOCAL_STATIC_JAVA_LIBRARIES += litepal \
							    haha   \
                                leakcanary-watcher 
#这里主要是引入V4的jar包
LOCAL_STATIC_ANDROID_LIBRARIES += \
    android-support-v4 \
    android-support-annotations \
    android-support-v7-recyclerview \
    android-support-v7-preference \
    android-support-v7-appcompat \
    android-support-v14-preference \
    android-support-v17-preference-leanback \
    android-support-v17-leanback \

#依赖aar
LOCAL_STATIC_JAVA_AAR_LIBRARIES += leakcanary-analyzer
LOCAL_STATIC_JAVA_AAR_LIBRARIES += leakcanary-android

#添加包名
LOCAL_AAPT_FLAGS := \
              --auto-add-overlay \
              --extra-packages com.squareup.leakcanary \
              --extra-packages gnu.trove

#LOCAL_PROGUARD_FLAG_FILES := proguard.cfg

LOCAL_PACKAGE_NAME := XXX_APK

LOCAL_CERTIFICATE := platform


LOCAL_PROGUARD_ENABLED := disabled
#LOCAL_DEX_PREOPT := false

include $(BUILD_PACKAGE)



include $(CLEAR_VARS)
#指明包的位置,引入第三方jar包
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := litepal:libs/litepal-1.1.1-src.jar  \										
										haha:libs/haha-2.0.4.jar \
    									leakcanary-watcher:libs/leakcanary-watcher-1.6.2.jar \
    									leakcanary-android:libs/leakcanary-android-1.6.2.aar \
    									leakcanary-analyzer:libs/leakcanary-analyzer-1.6.2.aar 
include $(BUILD_MULTI_PREBUILT)


# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))

##linm

           

     其中参考的博客如下,我对做了一些整理并亲自验证OK: 源码编译环境集成LeakCanary 

继续阅读