Retrofit not working on specific versions of android

前端 未结 3 1333
盖世英雄少女心
盖世英雄少女心 2020-12-09 06:00

I have a problem with Retrofit on my emulator running Android 4.3 and my device is on Android 4.4.2 while the same code runs normally on another emulator with Android 7.1.1<

3条回答
  •  执念已碎
    2020-12-09 06:30

    Android prior to 21 has some missing SSL and Retrofit wont work. Using google services you can update the device protocols after that the HTTP request will work

        //compile 'com.google.android.gms:play-services-base:11.0.0'
         //remember to add the library in your dependencies
    
            //compile 'com.google.android.gms:play-services-base:$currentVersion'
    
            ProviderInstaller.installIfNeededAsync(this, new ProviderInstallListener() {
    
                @Override
    
                public void onProviderInstalled() {
    
                    //Do your http request here
    
                }
    
    
                @Override
    
                public void onProviderInstallFailed(int errorCode, Intent recoveryIntent) {
    
                    //sad face :C is sad
    
                }
    
            });
    
    

提交回复
热议问题