WeiLianYang / AndroidToolkit

πŸ”₯πŸ”₯πŸ”₯ A toolkit for Android developers to debug easily.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AndroidToolkit δΈ­ζ–‡

Maven Central API License

  • This is a tool that can help Android development engineers and test engineers view network interface logs more conveniently.
  • You can view the status, address and time of the network interface request in the list.
  • In the detail page, because the json has been colored, the entire data looks more intuitive.
  • Of course, you can also share the data to the people you want to share through other apps



step 1 : update root project build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
}

step 2 : update module's build.gradle

dependencies {
    implementation 'io.github.weilianyang:toolkit:1.0.5'
}

step 3 : init the toolkit

  • I suggest you do initialization in the onCreate method of the Application as early as possible
class App : Application() {

    override fun onCreate() {
        super.onCreate()
        // set config data
        val config = ToolkitConfig.Builder().setDebugMode(BuildConfig.DEBUG).build()
        // init toolkit
        ToolkitPanel.init(this, config)
    }
}

step 4 : display the toolkit entrance

    // Request the permission of the floating window and display the toolkit entrance
    // The logic of applying for permissions and callbacks 
    // has been automatically processed inside the method
    ToolkitPanel.showFloating(this)

step 5 : capture network interface logs

  • If you are using Okhttp, then you only need to add ApiRecordInterceptor to automatically capture network interface logs.
fun getOkHttpClient(): OkHttpClient {
    val builder = OkHttpClient().newBuilder()
   
    builder.run {

        // Add the interceptor defined in the package
        addInterceptor(ApiRecordInterceptor())

        connectTimeout(TIMEOUT, TimeUnit.SECONDS)
        readTimeout(TIMEOUT, TimeUnit.SECONDS)
        writeTimeout(TIMEOUT, TimeUnit.SECONDS)
    }
    return builder.build()
}
  • If you don’t want to use the interceptor, also you can use the method provided in the library to manually save the data, and it will work normally, just like this
fun saveRecord() {
    val bean = ApiRecordBean(
        url = "https://developer.android.com/",
        method = "POST",
        headers = "{\"os\":\"android\", \"language\":\"en\"}",
        request = "{\"param1\": \"first param\",\"param2\": \"second param\"}",
        response = "{\"code\": code, \"success\": true, \"msg\": \"execute msg\"}",
        requestTime = System.currentTimeMillis(),
        duration = 100,
        httpCode = 200
    )
    DataManager.saveRecord(bean)
}

Function plan list

  • Show Crash log detail.
  • Display General information of view.
  • Display App related performance.
  • Other painful scenes in development.

Reporting Issues

  • When you find that the component is not working properly, please create an issue and I will reply in time.

License

Copyright WeiLianYang

Licensed 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.0

Unless required by applicable law or agreed to in writing, software distributed 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 and limitations under the License.

About

πŸ”₯πŸ”₯πŸ”₯ A toolkit for Android developers to debug easily.

License:Apache License 2.0


Languages

Language:Kotlin 96.9%Language:Java 3.1%