Giter VIP home page Giter VIP logo

stetho-no-op's Introduction

Stetho no-op library

Having two different Application subclasses just for stetho (debug and release) is annoying, so to keep everything plain and simple, to use stetho just add this for debug and production release:

repositories {
    maven { url 'http://dl.bintray.com/igenius-code/maven' }
}
def stethoVersion = "1.4.2"

debugCompile "com.facebook.stetho:stetho:${stethoVersion}"
debugCompile "com.facebook.stetho:stetho-okhttp3:${stethoVersion}"
releaseCompile "net.igenius:stetho-no-op:1.1"
public class App extends Application {

    private static OkHttpClient httpClient;

    @Override
    public void onCreate() {
        super.onCreate();
        
        if (BuildConfig.DEBUG) {
            Stetho.initialize(
                newInitializerBuilder(this)
                    .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
                    .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
                    .build());
        }
    }
    
    /**
     * Gets the instance of the application's HTTP client.
     * @return OkHttp client instance, ready to make requests
     */
    public static OkHttpClient getHttpClient(final Context context) {
        if (httpClient == null) {
            OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder()
                    .followRedirects(true)
                    .followSslRedirects(true)
                    .retryOnConnectionFailure(true)
                    .cache(null)
                    .connectTimeout(5, TimeUnit.SECONDS)
                    .writeTimeout(10, TimeUnit.SECONDS)
                    .readTimeout(10, TimeUnit.SECONDS);

            if (BuildConfig.DEBUG) {
                clientBuilder.addNetworkInterceptor(new StethoInterceptor());
            }

            httpClient = clientBuilder.build();
        }

        return httpClient;
    }

}

License

Copyright (C) 2017 iGenius Srl

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.

stetho-no-op's People

Contributors

gotev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stetho-no-op's Issues

Crashes on Android 4.4

Hi,

I found my app receently built with stetho-no-op crashes on Android 4.4. I am afraid that is because steho-no-op module has a dependency on OkHttp 3.+. As you might already know OkHttp 3.13 drops the support for Android 4.4 and below. So I want to stick to OkHttp 3.12 or below but steho-no-op forces us to use the latest OkHttp, 3.13.1.
https://github.com/square/okhttp/blob/master/CHANGELOG.md#version-3130

My question is what is the rationale behind 3.+ is specified in build.gradle? I am not sure if stetho-no-op always requires the latest OkHttp version. If no, do you agree on fixing the version to 3.12.1?

compile 'com.squareup.okhttp3:okhttp:3.+'

As a workaround, I removed stetho-no-op and it resolved the crashes.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.