http2 doesn't seem to be working with OkHttp3 and retrofit2

http2 doesn't seem to be working with OkHttp3 and retrofit2

By : Ankit
Date : October 22 2020, 08:10 PM
wish help you to fix your issue I got it to working after rebuilding nginx. The code at the client side is fine.
The default nginx shipped with ubuntu 14.04 doesn't support http2 out of the box for google clients. It uses NPN and not ALPN. In order to support APLN we need to rebuild openssl and nginx.
code :
$ wget -c https://www.openssl.org/source/openssl-1.0.2h.tar.gz
$ tar xf openssl-1.0.2h.tar.gz -C /usr/local/
$ cd /usr/local/openssl-1.0.2h
$ ./config
$ make depend
$ make
$ make test
$ make install
$ mv /usr/bin/openssl /usr/bin/openssl_1.0.1e
$ ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
$ openssl version
OpenSSL 1.0.2h  3 May 2016
$ sudo apt-get install libpcre3-dev libssl-dev libxml2-dev libxslt-dev libgd-dev libgeoip-dev
$ wget http://nginx.org/download/nginx-1.14.2.tar.gz
$ tar -xvzf nginx-1.14.2.tar.gz 
$ cd nginx-1.14.2/
$ ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads --with-openssl=/usr/local/openssl-1.0.2h/
$ sudo make
$ sudo make install
$ nginx -V
nginx version: nginx/1.14.2
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.4)
built with OpenSSL 1.0.2h  3 May 2016
TLS SNI support enabled

Share : facebook icon twitter icon
Imageuploding on okhttp3 or Retrofit2, how can i get this uri?

Imageuploding on okhttp3 or Retrofit2, how can i get this uri?

By : Sergiu Prodan
Date : March 29 2020, 07:55 AM
around this issue I want to make service for imageuploading using retrofit2 or Okhttp3, , modify the onActiivtyResult then handle the Exception in OnClick
code :
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(resultCode == Activity.RESULT_OK) {
        if(requestCode == 1000){
            Uri returnUri = data.getData();
            Bitmap bitmapImage = null;
            try {
                bitmapImage = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), returnUri);
            } catch (IOException e) {

    returnUri = data.getData(); //This is what i want to control

Uri returnUri;
HTTP/2 with OkHttp3 and Retrofit2

HTTP/2 with OkHttp3 and Retrofit2

By : kman
Date : March 29 2020, 07:55 AM
Any of those help alpn-boot is only used for a standard (Desktop/Server) JVM. It will not work with an Android device.
Also the change to bootclasspath is a runtime option in that case, not a compiler argument.
code :
$ oksocial --debug -i https://api.twitter.com/robots.txt 2>&1  | grep protocol
11:30:28.849    protocol: h2

$ oksocial --debug -i https://debug.api.heyyka.com/api/v1/dev/err 2>&1 | grep protocol
11:30:45.381    protocol: http/1.1
$ nghttp -v https://debug.api.heyyka.com/api/v1/dev/err
[  0.189] Connected
[  0.362][NPN] server offers:
          * h2
          * http/1.1
The negotiated protocol: h2
HTTPS not working with OkHttp3 and Retrofit2

HTTPS not working with OkHttp3 and Retrofit2

By : jason
Date : March 29 2020, 07:55 AM
Hope that helps Try to use this code HTTPS working with OkHttp3 and Retrofit2
create API interface
code :
public interface API {

Observable<Result<User>> getUser(@Path("user") String user);
public class ApiManager {

Context context;
public static final String BASE_URL = "https://api.github.com/";

private OkHttpClient okHttpClient;
private Authenticator authenticator = new Authenticator() {
    public Request authenticate(Route route, Response response) {
        return null;

private ApiManager() {

public void setAuthenticator(Authenticator authenticator) {
    this.authenticator = authenticator;

public static class Builder {
    String email, password;
    ApiManager apiManager = new ApiManager();

    public Builder setAuthenticator(Authenticator authenticator) {
        return this;

    public ApiManager build(String param_email, String param_password) {
        this.email = param_email;
        this.password = param_password;
        return apiManager.newInstance(email, password);


public class RequestTokenInterceptor implements Interceptor {
    String email, password;
    String credentials, basic;
    public RequestTokenInterceptor(String email, String password) {
        this.email = email;
        this.password = password;
        credentials = email + ":" + password;
        basic = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);

    public Response intercept(Interceptor.Chain chain) throws IOException {
        Request original = chain.request();
        Request.Builder builder = original.newBuilder()
                .addHeader("Authorization", basic)
                .method(original.method(), original.body());
        return chain.proceed(builder.build());

private ApiManager newInstance(String email, String password) {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
        public void log(String message) {
            Log.i("http", message);

    okHttpClient = new OkHttpClient.Builder()
            .addInterceptor(new RequestTokenInterceptor(email, password))

    return this;

public <T> T createRest(Class<T> t) {
    Retrofit retrofit = new Retrofit.Builder()


    return retrofit.create(t);

 compile 'com.squareup.okhttp3:okhttp:3.4.1'
 compile 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
 compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
 compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
 compile 'com.squareup.retrofit2:retrofit:2.0.2'
 compile 'com.squareup.retrofit2:converter-gson:2.0.2'
 compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
public class MainActivity extends AppCompatActivity {

private ProgressDialog feedbackDialog;

protected void onCreate(Bundle savedInstanceState) {

    feedbackDialog = new ProgressDialog(this);

public void getUser() {

    API accountAPI4 = createRestApi4();
    if (accountAPI4 != null) {
                .subscribe(new Action1<Result<User>>() {
                               public void call(Result<User> user) {
                                   Log.e("GIT_HUB","Github Name :"+user.response().body().getName()+"\nWebsite :"+user.response().body().getBlog());
                           }, new Action1<Throwable>() {
                               public void call(Throwable throwable) {
                                   // do something with the error
                                   if (throwable != null) {
    } else {

public static API createRestApi4() {
    ApiManager apiManager = new ApiManager.Builder().build(email, password);
    return apiManager.createRest(API.class);

public void showFeedback(String message) {


public void dismissFeedback() {
    <uses-permission android:name="android.permission.INTERNET"/>
Retrofit2 NoSuchMethodError with external AAR that uses OkHttp3 3.3.1

Retrofit2 NoSuchMethodError with external AAR that uses OkHttp3 3.3.1

By : Daniel Diaz
Date : March 29 2020, 07:55 AM
wish of those help Instead of checking the backward compatibility with OkHttp 3 3.1, you can exclude it from your ExternalSDK_Android dependency.
code :
// External SDK causing problems
compile(project(':ExternalSDK_Android')) {
    exclude group: 'com.squareup.okhttp3', module: 'okhttp'
compile('com.squareup.okhttp3:okhttp:+') {
    force = true
    transitive = true
Cache requests using retrofit2 and okhttp3

Cache requests using retrofit2 and okhttp3

By : Quick Question
Date : March 29 2020, 07:55 AM
hop of those help? I am using retrofit2 to cash responses using cache interceptor
code :
public Response intercept(Chain chain)
public Response intercept(Chain chain) {
    Request request = chain.request()
Related Posts Related Posts :
  • How to employ keyed-hash message authentication code (HMAC) with Android Keystore
  • Prevent inviting existing users or previously invited
  • How to overwrite windowSoftInputMode using edit-config tag in cordova
  • Difference between Loader and AsyncTask
  • In Firebase Android, retrieve the value of a child node and save it in a boolean variable
  • when i scroll the custom list in my android app then the favorite icon which is part of the custom adapter changes on it
  • adding room dependency gives manifest merge error
  • Visibility of RelativeLayout change on scrolling Gridview
  • Strange LiveData behavior vs ObservableField
  • Which layout is used for clash of clans home screen? We can scroll it horizontal as well as vertical. Please illuminate
  • RxJava: Know when observable is finished and return Boolean Observable to the caller
  • how to use savedInstanceState to save camera information when the orientation change occure
  • Style React-Native via Styles.xml
  • Keyboard won't show after calling InputMethodManager.showSoftInput
  • Compiling ffmpeg for Android on OSX
  • Button does not get clicked on the first attempt
  • AR Core performance, learning curve and comparison with other frameworks
  • Codename one : Attaching images to email message fails
  • Error: Unsupported type 'viewItem' in Android build
  • setLayoutParams on ConstraintLayout does not change size
  • How to profile the fetch time of the android gradle libraries
  • Kotlin setOnclickListener
  • Naming convention for methods returning RxJava's Completable
  • Conv3D not working
  • FFmpeg audio video merge command
  • Do you have to use gradle-experimental for JNI?
  • How to get key hashes for facebook for facebook app?
  • ZXing not calling onActivityResult, When scanning QR Code
  • Integration of Android Native module with existing Xamarin Native Project
  • Restore RecyclerView state after rotating
  • ViewModelProviders java.lang.RuntimeException trying to instantiate class which inherit AndroidViewModel
  • SKD19 vs SDK24 - Usage of API documented as @since 1.8+
  • filter option in list view fragment activity
  • Picture from camera not showing up in second activity
  • How to change imageview according to screen size
  • How to copy Android Studio project to remote Git (NOT GitHub) server
  • How to get React-Native to announce specific accessibility message via AccessibiliyManager?
  • Change colors of com.tech.freak.wizardpager.ui.StepPagerStrip
  • Android fullscreen activity shows ActionBar
  • Turn on the screen when timer calls onFinish()
  • Would like a bit of clarification with SQLite database's onUpgrade method
  • Use ObjectBox with Libgdx
  • How to make combine Gregorian and Hijri calendar in Android?
  • Try to read text file from sdcard in other language
  • "App not installed" message when installed apk
  • How to execute a designated test suite class in Firebase Test Lab
  • play music with background service
  • background not visible on LG G3
  • should every View have an id?
  • Realm object server sync on low connection.
  • Correct way to add more views to adapter
  • Getting error in android support library
  • Instant app zip uploading error
  • "No emulator installed" error in Android Studio even though Intel HAXM is up and running
  • AsyncTask without leaks
  • SQLiteException : No such table found whereas a table was created
  • Using @Component.Builder with constructor params
  • No injector was found for fragment dagger 2.11
  • Android Volley Https SSL self signed and Google Maps API
  • Why does the onClickListener not work anymore in this example?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org