square / retrofit

A type-safe HTTP client for Android and the JVM
https://square.github.io/retrofit/
Apache License 2.0
43.14k stars 7.3k forks source link

java.lang.NullPointerException: Attempt to invoke virtual method 'retrofit2.Converter retrofit2.Converter$Factory.stringConverter #3293

Open ltma opened 4 years ago

ltma commented 4 years ago

java.lang.RuntimeException:Unable to start activity ComponentInfo{com.hundsun.stockwinner.hczq/com.hundsun.winner.application.hsactivity.splash.SplashActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'retrofit2.Converter retrofit2.Converter$Factory.stringConverter(java.lang.reflect.Type, java.lang.annotation.Annotation[], retrofit2.Retrofit)' on a null object reference

android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3303)  ...... java.lang.NullPointerException:Attempt to invoke virtual method 'retrofit2.Converter retrofit2.Converter$Factory.stringConverter(java.lang.reflect.Type, java.lang.annotation.Annotation[], retrofit2.Retrofit)' on a null object reference retrofit2.Retrofit.stringConverter(Unknown Source:30) retrofit2.ServiceMethod$Builder.parseParameterAnnotation(Unknown Source:326) retrofit2.ServiceMethod$Builder.parseParameter(Unknown Source:8) retrofit2.ServiceMethod$Builder.retrofit2.ServiceMethod build()(Unknown Source:188) retrofit2.Retrofit.loadServiceMethod(Unknown Source:29) retrofit2.Retrofit$1.invoke(Unknown Source:32) java.lang.reflect.Proxy.invoke(Proxy.java:913) $Proxy10.a(Unknown Source) com.hundsun.winner.application.hsactivity.splash.AdvertisementHandle.a(Unknown Source:30) com.hundsun.winner.application.hsactivity.splash.SplashActivity.void gotoHomeView()(Native Method) com.hundsun.winner.application.hsactivity.splash.SplashActivity.showAdvertisement(Unknown Source:189) com.hundsun.winner.application.hsactivity.splash.SplashActivity.void initAdInfo()(Unknown Source:0) com.hundsun.winner.application.hsactivity.splash.SplashActivity.access$000(Unknown Source:0) com.hundsun.winner.application.hsactivity.splash.SplashActivity$1.a(Unknown Source:18) com.rxhui_hczq.base.BaseHsUPushActivity.void onEasyPermissionGranted(int)(Native Method)

Related code

Underneath RxhuiHttp.custom().build()  by
public R build() {
        this.mOkHttpBuilder = this.assembleOkHttp();
        this.mRetrofitBuilder = this.assembleRetrofit();
        this.mRetrofit = this.mRetrofitBuilder.client(this.mOkHttpBuilder.build()).addConverterFactory(FastjsonConverterFactory.create()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build();
        this.apiService = (ApiService)this.mRetrofit.create(ApiService.class);
        return this;
}
CustomRequest customRequest = RxhuiHttp.custom().build();
MainPagerService mainPagerService = customRequest.createService(MainPagerService.class);
customRequest.execute(mainPagerService.getCarouselViewData(AppConstants.PRODUCT_ID, spec, "4"),
      new RxhuiCallBack<LoopBannerVO>() {
                    @Override
                    protected void onSuccess(LoopBannerVO loopBannerVO) {

                    }

                    @Override
                    public void onFailure(String msg, Object o) {
                    }
});
AndoridZgc commented 4 years ago

Hi,did you solve the problem?

yashraj-deserve commented 3 years ago

Hi, did you get any solution for this?

ahmdsk commented 1 year ago

i do same this, how fix it?