Android ADB WIFI定位NDK错误调试方法

1.打开Android studio 工具栏找到Tools->Android->ADB WIFI
2.在ADB WIFI中有两项ADB USB TO WIFI 和ADB Restart
注:如果没有上述项,需要在Android setting->Plugins里面先下载ADB
3.一般如果电脑上开着360手机助手或者类似于豌豆荚的软件,需要关闭,不然会将默认的端口5555占据,之后将手机和PC连接在同一个网段即可操作。
4.启动ADB adb start-server
5.杀死ADB adb kill-server
6.使设备监听TCP/IP一个连接,端口号为5555
adb tcpip 5555
7.连接你的设备
adb connect ip
8.确认设备是否连接到主机电脑
adb devices
之后就可已经对NDK崩溃错误进行定位logcat日志输出
adb logcat | ndk-stack -sym ./obj/local/armabi-v7a
获取崩溃JNI堆栈信息

如果失去adb连接:
1. 确保你的主机和移动设备一直处于同一个Wi-Fi网络里。
2. 重试上述步骤。
3. 如果都不起作用,那么重置你的adb

定位上层Java内存泄漏的方式
/********************************/
debugCompile ‘com.squareup.leakcanary:leakcanary-android:1.5’
releaseCompile ‘com.squareup.leakcanary:leakcanary-android-no-op:1.5’
testCompile ‘com.squareup.leakcanary:leakcanary-android-no-op:1.5’

上面三个依赖库要添加到工程(项目的–>build.gradle中的dependencies)的
/****************************/

在在mainActivity同级目录下新建class文件继承 Application
public class MyApp extends Application {
@Override public void onCreate() {
super.onCreate();
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return;
}
LeakCanary.install(this);
// Normal app init code…
}
}

在AndroidMainfest.xml文件中需要注册application

猜你喜欢

转载自blog.csdn.net/Stone_OverLooking/article/details/78928270