私は他のAndroidデバイスでうまく動作するAndroidアプリを持っていますが、データでAndroidバージョン4.0.4を実行しているsamsung s3では失敗します。Retrofit は 404 (ページが見つからないエラー) をスローしますが、ページは存在し、wifi で同じ要求を行うとうまく機能します。何が不正行為の可能性があるかについての考えを持っている人。ありがとう
スタックトレースの下を見つけてください
retrofit.RetrofitError: 404 Not Found
at retrofit.RestAdapter$RestHandler.invokeRequest (RestAdapter.java:388)
at retrofit.RestAdapter$RestHandler.access$100 (RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$2.obtainResponse (RestAdapter.java:278)
at retrofit.CallbackRunnable.run (CallbackRunnable.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:569)
at retrofit.Platform$Android$2$1.run (Platform.java:142)
at java.lang.Thread.run (Thread.java:856)
以下は、私が呼び出しを行うために使用しているコードです
val tailorsInterface = RestAdapter.Builder()
.setEndpoint(resources.getString(R.string.base_url))
.build().create(TailorsInterface::class.java)
tailorsInterface.addTailor(txtName.text.toString(), txtEmail.text.toString(),
Utils.parsePhone(txtPhone.text.toString(), "254"), txtAddress.text.toString(),
txtLon.text.toString(), txtLat.text.toString(), txtPassword.text.toString(),
Common.LOCATIONS!!.get(spTowns.selectedItemPosition).id, object : Callback<DefaultResponse> {
override fun success(defaultResponse: DefaultResponse, response: Response) {
dialog.hide()
if(defaultResponse.success == 1.toLong()){
val alertDialog: AlertDialog
val builder = AlertDialog.Builder(this@TailorsRegisterActivity)
.setTitle(resources.getString(R.string.app_name))
.setMessage("Tailor successfully registered, click OK to continue to login")
.setPositiveButton("OK") { dialog, which -> run{dialog.dismiss()
val loginIntent: Intent = Intent(this@TailorsRegisterActivity, TailorsLoginActivity::class.java)
startActivity(loginIntent)
} }
alertDialog = builder.create()
alertDialog.show()
}else{
val alertDialog: AlertDialog
val builder = AlertDialog.Builder(this@TailorsRegisterActivity)
.setTitle(resources.getString(R.string.app_name))
.setMessage("An Error occurred please try again later")
.setPositiveButton("OK") { dialog, which -> run{dialog.dismiss()
finish()} }
alertDialog = builder.create()
alertDialog.show()
}
}
@FormUrlEncoded
@POST("/tailors")
public fun addTailor(@Field("name") name: String, @Field("email") email: String,
@Field("phone") phone: String, @Field("address") address: String,
@Field("lon") lon: String, @Field("lat") lat: String,
@Field("password") password: String, @Field("town") town: Int,
cb: Callback<DefaultResponse>)
data class DefaultResponse (
var success: Long,
var message: String
)