1

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?

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.

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>

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">

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?

reardenlife
  • 317
  • 4
  • 15

2 Answers2

0

Your app needs to have debuggable true defined in the build variant for you to see Log messages.

See this documentation.

Once you have debugging enabled in your application, you can use Logcat to view your app's logs via its package name. I've never used CatLog but I'd assume it's just parsing Logcat to display the logs.

D Ta
  • 864
  • 6
  • 17
  • Nice. Would you please point out where exactly should I put debuggable flag? In the AndroidManifest.xml before the compilation by apktool? – reardenlife Jan 23 '19 at 19:24
  • No, it'd go in the module level `build.gradle` file. Check the first documentation I linked. – D Ta Jan 23 '19 at 19:27
  • Yeah, I checked it out. And I read the info about gradle. The problem is that there is no gradle files in the project I decompiled by apktool. Only AndroidManifest.xml, some resources and bunch of smali-files. – reardenlife Jan 23 '19 at 19:33
  • I'm going on a limb and assume you're using Gradle (there are other build tools). In your scenario, you'd need to make your own build.gradle file. It sounds like you don't have access to the source code since you had to decompile the apk. This would be difficult to do since you'd need to know what dependencies and configurations the application uses. – D Ta Jan 23 '19 at 19:42
  • I am not sure what exactly apktool uses for the compilation, but I don't think it is gradle. It just have to convert *.smali files back into bytecode. But the point is that the debuggable flag doesn't seem to help me (see Edit 3). – reardenlife Jan 23 '19 at 19:56
  • Yeah I don't have an access to the source code. But I have an access to *.smali files that apktool is providing. Now I just have to figure out how to view the logs on my android device to see where the problem is. Then I will modify the appropriate smali-file on my server with vim and re build it with apktool. – reardenlife Jan 23 '19 at 20:00
  • Keep in mind that the build.gradle file tells the build tool how to construct the apk. The apk wouldn't know about the build.gradle file. So it makes sense that when you decompile the apk, the build.gradle file doesn't exist. – D Ta Jan 23 '19 at 20:10
  • Here is the tutorial on how to make a release app debuggable: https://gist.github.com/nstarke/615ca3603fdded8aee47fab6f4917826 They patching AndroidManifest.xml – reardenlife Jan 23 '19 at 20:23
  • So I would assume that I've done everything correctly with that debuggable flag. Yet I cannot read any Logs on my Android device. Apparently that debuggable option is for USB debugging. Well, apparently the debugging on Android is a pain in the but it was much better on Windows OS with their DebugOutput and DebugView... – reardenlife Jan 23 '19 at 20:25
0

Try adding:

{
    debuggable true
} 

in your build.gradle file.

Necoras
  • 6,743
  • 3
  • 24
  • 45
Patka07
  • 1
  • 1