Android Remote Debugger - remote debugging Android applications

Debugging is an important step in software development. Search and bug fixes allow you to develop quality products.


In this article I want to talk about debugging exactly Android applications. Android Studio provides us with various profiling tools, such as:


  • logcat is a tool for viewing application logs, including crash exceptions. It can be used both in Android Studio and in the terminal, via adb;
  • Android profiler is a powerful tool that allows you to view all network requests, CPU, memory and battery usage.

There are also many third-party solutions that allow you to view network traffic, databases, shared preferences, etc.
All of these tools have advantages and disadvantages. Their minuses include the following:


  • many dependencies of various tools;
  • complexity of use - as a rule, all tools are focused on developers and inconvenient for other team members, for example, testers, analysts or back-end developers. Typically, the latter have to pull the android developers to view any logs;
  • Mandatory connection of the phone to the computer, for example, via a usb cable.

, . .


Android Remote Debugger


, , Android . :


  • Logging — , ;
  • Database — ;
  • Network — ;
  • SharedPreferences – SharedPreferences.


:


  • ;
  • ;
  • , http://xxx.xxx.x.xxx:8080. , (Wi-Fi LAN) Android ;
  • . .

:


Logging


logging.png

Database


database.png

Network


network.png


AndroidRemoteDebugger.init(applicationContext) . AndroidRemoteDebugger.Builder:


AndroidRemoteDebugger.init(
    new AndroidRemoteDebugger.Builder(applicationContext)        
        .enabled(boolean)    //  
        .disableInternalLogging()    //    Android Remote Debugger
        .disableJsonPrettyPrint()    //   json   `Logging`  `Network`
        .disableNotifications()    //      Android Remote Debugger
        .excludeUncaughtException()    //      
        .port(int)    //   ,   8080
        .enableDuplicateLogging()    //     `Logging`     logcat
        .enableDuplicateLogging(new Logger() {  // callback       `Logging`
            @Override
            public void log(int priority, String tag, String msg, Throwable th) {
            }
        })
        .build()
);

. - NanoHTTPD. . , , , 8080. . AndroidRemoteDebugger.Builder.


Logging


. , . , . .


AndroidRemoteDebugger.Log. . . , Logging . .


: AndroidRemoteDebugger.Log.d("tag", "message").


Timber ( Jake Wharton), :


class AndroidRemoteDebuggerTree extends Timber.Tree {
    @Override
    protected void log(int priority, @Nullable String tag, @NotNull String message, @Nullable Throwable t) {
        AndroidRemoteDebugger.Log.log(priority, tag, message, t);
    }
}

...

public class App extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Timber.plant(new Timber.DebugTree(), new AndroidRemoteDebuggerTree());
    }
}

Network


Network . . . Logging. HTTP . , . Logging, .


OkHttp3 NetLoggingInterceptor. , .


:


OkHttpClient client = new OkHttpClient.Builder()
    // other interceptors
    .addInterceptor(new NetLoggingInterceptor())
    .build();

Database


. . . 15 . , , . sql-.


SharedPreferences


SharedPreferences. , , . SharedPreferences . , .


Android Remote Debugger


build.gradle :


allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

build.gradle :


dependencies {
    implementation 'com.github.zerobranch:android-remote-debugger:1.0.0'
}


Android Remote Debugger:


  • ;
  • Includes several debugging tools at once;
  • focused not only on developers;
  • does not require connecting an Android device to a computer for operation;
  • easy to use.

Github


Detailed instructions for working and connecting the library can be found on GitHub


All Articles