Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在设置了baseUrl之后,在程序运行的过程中偶尔会出现Base URL required 导致App崩溃 #87

Open
Huwei1993 opened this issue Jul 24, 2018 · 2 comments

Comments

@Huwei1993
Copy link

Huwei1993 commented Jul 24, 2018

是retorfit 当中报出来的,不是novate
报错信息:
FATAL EXCEPTION: mqt Process: com.ocj.oms.mobile, PID: 17343
java.lang.IllegalStateException: Base URL required.
at retrofit2.Retrofit$Builder.build(Retrofit.java:563)
at com.novate.Novate$Builder.build(Novate.java:2921)
at com...service.novate.NovateGenerator.createNovate(NovateGenerator.java:67)
at com.
.base.App.initRNNovate(App.java:430)
at com.******.ui.rn.RouterModule.getAPIKey(RouterModule.java:1283)
at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:345)
at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:141)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:163)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
at java.lang.Thread.run(Thread.java:760)

调用地方:
public Novate createNovate() {
if (TextUtils.isEmpty(ApiHost.API_HOST)){
ApiHost.API_HOST = BuildConfig.ApiUrl;
}
// 该log用于检测 Base Url 为 空的情况下App崩溃问题
Log.e("ApiHost.API_HOST","createNovate ApiHost.API_HOST:" + ApiHost.API_HOST);
return createBuilder()
.baseUrl(ApiHost.API_HOST)
.connectTimeout(30)
.writeTimeout(30)
.build();
}

/**
* 创建构建novate的builder
* @return Novate.Builder
*/
private Novate.Builder createBuilder() {
LogWraper.setDebug(BuildConfig.DEBUG);
if (TextUtils.isEmpty(ApiHost.API_HOST)){
ApiHost.API_HOST = BuildConfig.ApiUrl;
}
return new Novate.Builder(App.getInstance())
.addHeader(getHeaders()) //添加公共请求头
.addParameters(getParameters())//公共参数
.connectTimeout(30) //连接时间 可以忽略
.writeTimeout(30)
// .addCookie(true) //是否同步cooike 默认不同步
.addCache(false) //是否缓存 默认缓存 ,true时,当频繁访问API时会使用缓存数据返回,在调试开发的时候尽量关闭缓存,防止后台数据与前台数据交互不畅
// .addCache(cache, cacheTime) //自定义缓存 设置缓存时间
.baseUrl(ApiHost.API_HOST) //base URL
.addLog(BuildConfig.DEBUG) //是否开启log
// .cookieManager(new NovateCookieManager()) // 自定义cooike,可以忽略
.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) // 自定义Interceptor
.addNetworkInterceptor(new StethoInterceptor()) // 自定义NetworkInterceptor
// .addSSLSocketFactory(NovateHttpsFactroy.getSSLSocketFactory(instance, certificates))
.skipSSLSocketFactory(true);
// .addSSLSocketFactory(NovateHttpsFactroy.)
// .proxy(proxy) //代理
// .client(client) //clent 默认不需要
}

@Tamicer
Copy link
Owner

Tamicer commented Aug 2, 2018

baseUrl不合法吧?

@Huwei1993
Copy link
Author

只有在快速多次请求的时候会报错,一般情况下是不会出现异常

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants