如何使用leakcanary,如何添加leakcanary作为一个罐子建立与的.mk文件的apk [英] how to use leakcanary, how to add leakcanary as a jar to build a apk with .mk file

查看:891
本文介绍了如何使用leakcanary,如何添加leakcanary作为一个罐子建立与的.mk文件的apk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

LeakCanary是Android和Java的内存泄漏检测库。 LeakCanary

LeakCanary is a memory leak detection library for Android and Java. LeakCanary

我的项目是基于Android的make文件系统,它依赖于一些Android的内部接口和自定义方法。

My project is based on android make file system, which relies on some android internal interfaces and custom methods.

我如何可以添加LeakCanary作为一个lib到我的应用程序来检测内存泄漏。

How can I add the LeakCanary as a lib into my app to detect memory leak.

我的解决方法: 首先,我要建立LeakCanary作为一个jar文件,但如何。因为它是一个摇篮的目录结构,我从来没有使用摇篮了。

My solution: First, I have to build the LeakCanary as a jar file, but how to. as it's a gradle directory structure, and I have never used Gradle before.

任何提示是precious。

Any tip is precious.

推荐答案

LeakCanary不仅仅是一个JAR - 它不仅包含了Java code,但资源太(PNG的举例)。如果你正在使用ANT,那么你可以做的唯一一件事就是包括LeakCanary作为库项目。但我强烈建议切换到摇篮。由于Android开发团队不会支持任何导入库,不只是罐子中的任何用户友好的方式在不久的将来(因为摇篮的优先级)。和导入为库项目是一个痛苦的过程,它得到的更多的痛苦时,它有时会涉及到包括库的依赖也为库项目。我的手很久以前,只是因为客户端使用日食与蚂蚁为年龄大的项目做到了。通常情况下,你必须做到以下几点:

LeakCanary is not just a JAR - it contains not only the java code, but resources too (png's for example). If you are using ANT, then the only thing you can do is to include LeakCanary as a library project. But I strongly recommend switching to gradle. Because android development team is not going to support importing any library which is not just jar in any user-friendly way in the nearest future (because gradle is priority). And importing as library projects is a painful procedure, which get's more painful when it sometimes comes to including library's dependencies also as library projects. I've done it by hand long ago only because the client used eclipse with ant for big project for ages. Generally, you must do the following:

  1. 获取来源:来源$ C ​​$ C,资产,资源...
  2. 在调查LeakCanary的依赖。你可以看看POM对象模型<一href="http://search.maven.org/#artifactdetails%7Ccom.squareup.leakcanary%7Cleakcanary-android%7C1.3%7Caar"相对=nofollow>此处。
  3. 对于依赖关系,这已经不仅仅是Java的code,则需要再次它们作为库。对于其他人,只需下载它们作为罐子。
  4. 有关资产(字体,例如)有一个额外的步骤:你必须与你对他们的工作拷贝到项目或你会得到一个资源未发现异常
  5. 的最后一步是使明显的合并。添加下面一行到你的项目的project.properties:

  1. Obtain sources: source code, assets, resources...
  2. Investigate LeakCanary's dependencies. You may look "POM Object Model" here.
  3. For dependencies, which have more than just java code, you'll need to include them as library again. For others, just download them as jar.
  4. For assets (fonts, for example) there are an extra step: you must copy them to the project you are working on or you'll get a resource not found exception.
  5. The final step is to enable manifest merger. Add the following line to project.properties of your project:

manifestmerger.enabled = TRUE

manifestmerger.enabled=true

这是为了所有的库项目合并AndroidManifest.xml中进入决赛的apk。

It is done to merge all the AndroidManifest.xml from library project into final apk.

这篇关于如何使用leakcanary,如何添加leakcanary作为一个罐子建立与的.mk文件的apk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆