第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Android studio - 帶有Retrofit2的外匯匯率API,無法運(yùn)行應(yīng)用程序

Android studio - 帶有Retrofit2的外匯匯率API,無法運(yùn)行應(yīng)用程序

慕桂英3389331 2022-11-02 15:07:10
所以我試圖在應(yīng)用程序上顯示一些貨幣兌換,但我什至無法運(yùn)行它,我遇到了這個(gè)錯(cuò)誤:2019-05-01 14:34:57.260 6798-6798/com.example.myapplication E/AndroidRuntime: FATAL EXCEPTION: mainProcess: com.example.myapplication, PID: 6798java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.IllegalArgumentException: Unable to create converter for java.util.List<com.example.myapplication.Currency>    for method CurrencyExchangeService.getCurrency    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)    at android.os.Handler.dispatchMessage(Handler.java:106)    at android.os.Looper.loop(Looper.java:193)    at android.app.ActivityThread.main(ActivityThread.java:6669)    at java.lang.reflect.Method.invoke(Native Method)    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: java.lang.IllegalArgumentException: Unable to create converter for java.util.List<com.example.myapplication.Currency>    for method CurrencyExchangeService.getCurrency    at retrofit2.Utils.methodError(Utils.java:52)    at retrofit2.HttpServiceMethod.createResponseConverter(HttpServiceMethod.java:70)    at retrofit2.HttpServiceMethod.parseAnnotations(HttpServiceMethod.java:46)        ... 11 moreLogcat 導(dǎo)航到這行代碼        Call<List<Currency>> call = currencyInterface.getCurrency();我假設(shè)這是在接口中調(diào)用方法,我在 @Get 方法中錯(cuò)誤地命名了 String 。
查看完整描述

1 回答

?
寶慕林4294392

TA貢獻(xiàn)2021條經(jīng)驗(yàn) 獲得超8個(gè)贊

如網(wǎng)站上所述,您可能會(huì)收到這種類型的 JSON 響應(yīng)


{

  "base": "EUR",

  "date": "2018-04-08",

  "rates": {

    "CAD": 1.565,

    "CHF": 1.1798,

    "GBP": 0.87295,

    "SEK": 10.2983,

    "EUR": 1.092,

    "USD": 1.2234,

    ...

  }

}

所以要解析這種類型的 JSON,你的 POJO 類應(yīng)該是這樣的


public class MyPojo

{

    private String date;


    private Rates rates;


    private String base;


    public String getDate ()

    {

        return date;

    }


    public void setDate (String date)

    {

        this.date = date;

    }


    public Rates getRates ()

    {

        return rates;

    }


    public void setRates (Rates rates)

    {

        this.rates = rates;

    }


    public String getBase ()

    {

        return base;

    }


    public void setBase (String base)

    {

        this.base = base;

    }


    @Override

    public String toString()

    {

        return "ClassPojo [date = "+date+", rates = "+rates+", base = "+base+"]";

    }


public class Rates

{

    private String CHF;


    private String EUR;


    private String GBP;


    private String CAD;


    private String USD;


    private String SEK;


    public String getCHF ()

    {

        return CHF;

    }


    public void setCHF (String CHF)

    {

        this.CHF = CHF;

    }


    public String getEUR ()

    {

        return EUR;

    }


    public void setEUR (String EUR)

    {

        this.EUR = EUR;

    }


    public String getGBP ()

    {

        return GBP;

    }


    public void setGBP (String GBP)

    {

        this.GBP = GBP;

    }


    public String getCAD ()

    {

        return CAD;

    }


    public void setCAD (String CAD)

    {

        this.CAD = CAD;

    }


    public String getUSD ()

    {

        return USD;

    }


    public void setUSD (String USD)

    {

        this.USD = USD;

    }


    public String getSEK ()

    {

        return SEK;

    }


    public void setSEK (String SEK)

    {

        this.SEK = SEK;

    }


    @Override

    public String toString()

    {

        return "ClassPojo [CHF = "+CHF+", EUR = "+EUR+", GBP = "+GBP+", CAD = "+CAD+", USD = "+USD+", SEK = "+SEK+"]";

    }

}

}

讓我知道它是否有效


查看完整回答
反對(duì) 回復(fù) 2022-11-02
  • 1 回答
  • 0 關(guān)注
  • 280 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)