尽管需要改造 2.0,但价值缺失
Value missing though required retrofit 2.0
我正在使用 Retrofit 2.0 创建用于在服务器上上传文件的改造服务。
我指的是https://futurestud.io/blog/retrofit-2-how-to-upload-files-to-server
下面是我的 FileUploadService 代码:
interface TripHistoryFileUploadService {
@Multipart
@POST("trip/trip-history")
Call<ResponseBody> upload(@Part("json_file") RequestBody description,
@Part MultipartBody.Part file);
}
我正在使用以下改造版本:
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
但我收到错误 虽然需要但缺少值,如下所示:
谁能遇到同样的问题,或者谁能解决同样的问题?
beta Version is An early version of a program or application that
contains most of the major features, but is not yet complete.
您应该使用稳定版
compile 'com.squareup.retrofit2:retrofit:2.0.2' //A type-safe HTTP client
那么Clean -Rebuild-Sync
你的IDE。希望对你有帮助。
您缺少 零件名称 第二个参数
interface TripHistoryFileUploadService {
@Multipart
@POST("trip/trip-history")
Call<ResponseBody> upload(@Part("json_file") RequestBody description,
@Part("part_name_missing here") MultipartBody.Part file);
}
}
我遇到了类似的情况,结果证明这是微不足道的事情 - 我从第一个版本的改造而不是第二个版本中导入了零件。
所以至少你可以做的是检查你是否有
import retrofit.http.Part; -> requires value
而不是
import retrofit2.http.Part; -> doesn't required value
我正在使用 Retrofit 2.0 创建用于在服务器上上传文件的改造服务。
我指的是https://futurestud.io/blog/retrofit-2-how-to-upload-files-to-server
下面是我的 FileUploadService 代码:
interface TripHistoryFileUploadService {
@Multipart
@POST("trip/trip-history")
Call<ResponseBody> upload(@Part("json_file") RequestBody description,
@Part MultipartBody.Part file);
}
我正在使用以下改造版本:
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
但我收到错误 虽然需要但缺少值,如下所示:
谁能遇到同样的问题,或者谁能解决同样的问题?
beta Version is An early version of a program or application that contains most of the major features, but is not yet complete.
您应该使用稳定版
compile 'com.squareup.retrofit2:retrofit:2.0.2' //A type-safe HTTP client
那么Clean -Rebuild-Sync
你的IDE。希望对你有帮助。
您缺少 零件名称 第二个参数
interface TripHistoryFileUploadService {
@Multipart
@POST("trip/trip-history")
Call<ResponseBody> upload(@Part("json_file") RequestBody description,
@Part("part_name_missing here") MultipartBody.Part file);
}
}
我遇到了类似的情况,结果证明这是微不足道的事情 - 我从第一个版本的改造而不是第二个版本中导入了零件。 所以至少你可以做的是检查你是否有
import retrofit.http.Part; -> requires value
而不是
import retrofit2.http.Part; -> doesn't required value