- Notifications
You must be signed in to change notification settings - Fork29
A library for remote logging, database debugging, shared preferences and network requests
License
zerobranch/android-remote-debugger
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Android Remote Debugger is a library for remote debugging Android applications. It allows you to view logs, databases, shared preferences and network requests directly in the browser.
- Logging
- View the logs of your application
- Filter logs by priority and tags
- Search logs
- Download logs
- Crash errors are also logged
- Database
- View all databases
- Edit database entries
- Delete database entries
- Search data
- Run custom sql query to get, add, update or delete data
- SharedPreferences
- View all data
- Edit, add and delete data
- Search data
- Network
- View all network requests and responses in a convenient format
- Filter data by response code and errors
- Download logs
- Search data
Add it in your root build.gradle at the end of repositories:
allprojects { repositories {... maven { url'https://jitpack.io' } }}
Add the following dependency to your module's build.gradle:
dependencies { debugImplementation'com.github.zerobranch.android-remote-debugger:debugger:1.1.2' releaseImplementation'com.github.zerobranch.android-remote-debugger:noop:1.1.2'}
Note: The final line above will use a no-op version, which does nothing.It should only be used in production build.This makes it impossible to run the server on a production build.
Android Remote Debugger has 4 sections:
- Logging
- Database
- Shared Preferences
- Network
For theLogging
,Database
andShared Preferences
sections to work, several steps are necessary:
Call:
AndroidRemoteDebugger.init(applicationContext)
in the application code.After launching your application, you will receive a notification in the notification panel, in which a link of the type:http://xxx.xxx.x.xxx:8080 will be indicated. Just follow this link in your browser. Also, an entry will be added to logcat:
D/AndroidRemoteDebugger: Android Remote Debugger is started. Go to: http://xxx.xxx.x.xxx:8080
To view the logs in the
Logging
section, you must call the static methodsAndroidRemoteDebugger.Log
anywhere in your application, for example,AndroidRemoteDebugger.Log.d("tag", "message")
orAndroidRemoteDebugger.Log.log(priority, tag, msg, throwable)
with all parameters specified.To view network logs in the
Network
section, it is necessary to use theOkHttp3 library and add theNetLoggingInterceptor
interceptor. Recommended to add it after all others interceptors to get actual network traffic data.
OkHttpClientclient =newOkHttpClient.Builder() .addInterceptor(newNetLoggingInterceptor()) .build();
Attention
- Your Android device and computer must be connected to the same network (Wi-Fi or LAN).
- You can also use debugging via usb or Android Default Emulator. To do this, run the command:
adb forward tcp:8080 tcp:8080
and go to the address:http://localhost:8080 orhttp://0.0.0.0:8080 in your browser. - If you use Android Default Emulator, then you may also need to turn on the mobile Internet and turn off WI-FI.
To configure the library, useAndroidRemoteDebugger.Builder
AndroidRemoteDebugger.init(newAndroidRemoteDebugger.Builder(applicationContext) .enabled(boolean) .disableInternalLogging() .enableDuplicateLogging() .disableJsonPrettyPrint() .disableNotifications() .excludeUncaughtException() .port(int) .build());
All parameters forAndroidRemoteDebugger.Builder
are optional. For standard library operation, just callAndroidRemoteDebugger.init(applicationContext)
.
.enabled(boolean) -libraryenablecontrol.disableInternalLogging() -disableinternallogsofAndroidRemoteDebugger.disableJsonPrettyPrint() -disableprettyprintjsonin `Logging`and`Network`sections.disableNotifications() -disableAndroidRemoteDebuggerstatusnotifications.excludeUncaughtException() -excludelogprinting whenapplicationcrashes.port(int) -useadifferentportthan8080.enableDuplicateLogging() -alllogsfrom `Logging`sectionwillalsobeprintedinlogcat.enableDuplicateLogging(newLogger() { -callbacktogetalllogsfrom `Logging`section@Overridepublicvoidlog(intpriority,Stringtag,Stringmsg,Throwableth) { }})
TheNetLoggingInterceptor
interceptor has two constructors: empty and with a callback to get all logs fromNetwork
section
newNetLoggingInterceptor(newNetLoggingInterceptor.HttpLogger() {@Overridepublicvoidlog(HttpLogModelhttpLogModel) { }})
- Choosing a logging level
- Filter the logs by tag
- Enable/disable autoscroll when receiving new logs
- Go to the top of the list
- Go to the end of the list
- Enable/disable colors for logs
- Delete all logs
- A link to the debugger page can also be obtained as follows:http://ip-address-of-your-android-device:port (you can see the ip-address-of-your-android-device in the settings of your device).
- If you use debugging via usb or Android Default Emulator and you want to use a different port, for example, 8081, then you need to run the following command:
adb forward tcp:8081 tcp:8081
. - To use this library on one Android device for two applications simultaneously, you need to use different ports.
If you use R8, you don't have to do anything. The specific rules are included automatically.
If you don't use R8 you have to apply the following rules:
-keep class zerobranch.androidremotedebugger.source.models.** { *; }-keep class zerobranch.androidremotedebugger.source.local.LogLevel
You might also need rules fromOkHttp3 andGson, which are dependencies of this library.
Copyright 2020 Arman SargsyanLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
About
A library for remote logging, database debugging, shared preferences and network requests
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.