问题描述
我有一个运行非常不稳定的Android应用程序,我想修复它.因此,我使用apktool反编译了apk,并发现该应用程序调用了一堆Log.d,并在其中写入了有用的信息.然后,我为Android安装了一个日志查看器,发现它没有显示任何内容.我读了CatLog的评论(例如),用户告诉它在最新的Android版本上不起作用.好吧,现在我想知道该怎么办-如果我的手机没有扎根,现在可以在Android上查看日志跟踪了吗?
I've got an Android app that works highly unstable and I want to fix it. So I decompiled the apk with apktool and figured that the app call a bunch of Log.d where it writes the useful information. Then I installed a log viewer for Android and figured that it doesn't show anything. I read into the reviews of CatLog (for example) and the user told that it doesn't work on the newest Android version. Well, now I wonder what to do - now can I view the log trace on Android provided my phone isn't rooted?
编辑:我想知道是否有某种方法可以修改由apktool反编译的* .smali文件中的Log.d或Log.e的每次调用,这样我就可以对文本进行写说了直接与操作系统的日志机制不交互的文件.有没有人做类似的事情?我也知道使用远程调试会好得多,但是我现在根本无法访问计算机-只能通过SSH访问智能手机和Linux服务器.
Edit: I wonder if there is some way to modify each call of Log.d or Log.e inside *.smali files decompiled by apktool so I will be able to write say to the text file directly w/o interacting with log mechanisms of OS. Have anyone done similar thing?I also understand that it would be much-much better to use remote debugging, but I simply don't have an access to computer right now - only to smartphone and the Linux server by SSH.
编辑2 :这是应用程序的清单.我试图弄清楚是否可以在其中添加可调试标记.
Edit 2: Here is a manifest of an app. I am trying to figure out if it is possible to ad debuggable flag in it.
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:targetSdkVersion="16" package="com.anda.otgdiskpro" platformBuildVersionCode="23" platformBuildVersionName="6.0-2704002">
<uses-feature android:name="android.hardware.usb.accessory"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application android:icon="@drawable/icon" android:label="@string/app_name" android:largeHeap="true">
<activity android:configChanges="orientation" android:label="@string/app_name" android:launchMode="singleInstance" android:name="com.anda.otgdiskpro.USBActivityPro">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:label="Settings" android:name="com.anda.otgdisk.PrefPage"/>
<activity android:configChanges="orientation" android:label="@string/title_activity_music" android:launchMode="singleInstance" android:name="com.anda.otgdisk.MusicActivity"/>
</application>
</manifest>
编辑3 :啊哈!显然,我必须将"android:debuggable ="true"放入AndroidManifest.xml的应用程序标签中...好的.我修改了AndroidManifest.xml:
Edit 3:Aha! Apparently I have to put "android:debuggable="true"" I to the application tag of AndroidManifest.xml...Okay. I modified the AndroidManifest.xml:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:largeHeap="true" android:debuggable="true">
将其编译为apk,对其进行签名并安装在智能手机上.此外,我安装了logcat的极限.在LogCat Extreme中运行两个应用程序,并且没有日志.似乎Android不允许我查看其他应用程序的日志.对吧?
Compiled it to apk, signed it and installed on the smartphone. Also I installed LogCat Extreme. Run both apps and ... no logs in the LogCat Extreme. It seems that Android is not allowing me to view the logs of other apps. Right?
推荐答案
尝试添加:
{
debuggable true
}
在build.gradle文件中.
in your build.gradle file.
这篇关于如何在Android上查看调试消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!