Android 在改装中调用api时未找到响应消息和响应代码-404

Android 在改装中调用api时未找到响应消息和响应代码-404,android,web-services,retrofit,retrofit2,webservices-client,Android,Web Services,Retrofit,Retrofit2,Webservices Client,从数据库获取数据的Webservice如下所示: Smart.php define('HOST','localhost'); define('USER','root'); define('PASS','root'); define('DB','Stud'); $con = mysqli_connect(HOST,USER,PASS,DB); $sql = "select * from Student";

从数据库获取数据的Webservice如下所示:

Smart.php

define('HOST','localhost'); define('USER','root'); define('PASS','root'); define('DB','Stud'); $con = mysqli_connect(HOST,USER,PASS,DB); $sql = "select * from Student"; $result=array(); $res = mysqli_query($con,$sql); enter code here while($row = mysqli_fetch_array($res)){ array_push($result, array('id'=>$row[0], 'name'=>$row[1], 'address'=>$row[2] )); } echo json_encode(array("result"=>$result)); mysqli_close($con); ?> ApiServices.java接口

public interface ApiServices {

    @GET("Smart.php")
    Call<Example> List();

}

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.saloni.retrofit_sample.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15dp"
        android:id="@+id/text" />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/btn"
    android:text="click"
    />
</LinearLayout>
公共接口服务{
@GET(“Smart.php”)
调用列表();
}
activity_main.xml
当我运行这个程序时,点击按钮,我得到toast null,logcat输出如下:

E/API未成功:2。Response@d45de1e找不到 okhttp3.responsebook$1@9a0e6ff404

这意味着响应消息“未找到”,响应代码为“404”

按照建议编辑程序并删除“/”后,在logcat中出现以下错误:

E/Failed:t.printStackTrace()java.lang.UnsupportedOperationException:无法实例化接口!接口名称:javax.xml.transform.resultanble可调用接口javax.xml.transform.Result的无参数构造函数。为此类型向Gson注册InstanceCreator可能会解决此问题

公共接口服务{
@获取(“/Smart.php”)
调用列表();
}
而不是

public interface ApiServices {

@GET("Smart.php")
Call<List<Result>> List();

}
公共接口服务{
@GET(“Smart.php”)
调用列表();
}
公共接口服务{
@获取(“/Smart.php”)
调用列表();
}
而不是

public interface ApiServices {

@GET("Smart.php")
Call<List<Result>> List();

}
公共接口服务{
@GET(“Smart.php”)
调用列表();
}

我成功地解决了这个错误,没有出现任何进一步的错误。我的Result.java类与javax.xml.transform.Result类冲突。因此,我重命名了Result.java类

我成功地解决了这个错误,没有出现任何进一步的错误。我的Result.java类与javax.xml.transform.Result类冲突。因此,在应用您的建议并编辑代码后,我重命名了我的Result.java类

,它给出了另一个在帖子中编辑的错误。请继续指导我这不是代码问题检查您的json响应我认为您在应用建议并编辑代码后得到的是列表而不是示例对象,它给出了另一个在帖子中编辑过的错误。请继续指导我。这不是代码问题。请检查您的json响应。我想您得到的是列表而不是示例对象
public interface ApiServices {

    @GET("Smart.php")
    Call<Example> List();

}

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.saloni.retrofit_sample.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15dp"
        android:id="@+id/text" />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/btn"
    android:text="click"
    />
</LinearLayout>
public interface ApiServices {

@GET("/Smart.php")
Call<List<Result>> List();

}
public interface ApiServices {

@GET("Smart.php")
Call<List<Result>> List();

}