【发布时间】:2021-07-13 03:17:12
【问题描述】:
我正在使用 Retrofit2 进行 API 解析。
在使用retrofit1.9.0 时,post 和 get 方法都可以正常工作。但是使用retrofit 2.1.0,在get方法中,出现错误:
java.lang.IllegalArgumentException: baseUrl 必须以 / 结尾
我检查了我的代码,没有问题,它适用于 post 方法。
Retrofit retrofit= new Retrofit.Builder()
.baseUrl("sample.com/ecomtest/index.php?route=api/")
.addConverterFactory(GsonConverterFactory.create())
.build();
【问题讨论】:
-
请添加相关代码。
-
请记得分享一些相关代码,帮助人们快速为您解决问题。
-
Retrofit retrofit= new Retrofit.Builder() .baseUrl("sample.com/ecomtest/index.php?route=api/") .addConverterFactory(GsonConverterFactory.create()) .build();
-
在此代码中出现异常并且应用程序崩溃
-
使用
"sample.com/ecomtest/"作为基础网址