1
我正嘗試使用Weatherlib API創建天氣應用程序。我有下面的代碼。我試圖尋找城市模式,但不幸的是,okhttp引發了url == null的異常。未能在Weatherlib API中檢索搜索到的城市android
我創建了驗證,當至少輸入4個字母時開始搜索。一旦我輸入第四個字母,我得到這個例外...
有沒有人使用Weatherlib並遇到此問題?下面
10-09 15:35:24.681 11596-11596/ie.betterweather.betterweather I/System.out? testingbefore
10-09 15:35:24.688 11596-11596/ie.betterweather.betterweather W/System.err? java.lang.IllegalArgumentException: url == null
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at com.squareup.okhttp.Request$Builder.url(Request.java:148)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at com.survivingwithandroid.weather.lib.client.okhttp.WeatherDefaultClient._doSearchCity(WeatherDefaultClient.java:149)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at com.survivingwithandroid.weather.lib.client.okhttp.WeatherDefaultClient.searchCity(WeatherDefaultClient.java:92)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at ie.betterweather.betterweather.MainActivity$1.onTextChanged(MainActivity.java:81)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at android.widget.TextView.sendOnTextChanged(TextView.java:7722)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at android.widget.TextView.handleTextChanged(TextView.java:7782)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:9514)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:964)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:515)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:454)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:33)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:685)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:445)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:340)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
10-09 15:35:24.689 11596-11596/ie.betterweather.betterweather W/System.err? at android.os.Handler.dispatchMessage(Handler.java:102)
10-09 15:35:24.690 11596-11596/ie.betterweather.betterweather W/System.err? at android.os.Looper.loop(Looper.java:211)
10-09 15:35:24.690 11596-11596/ie.betterweather.betterweather W/System.err? at android.app.ActivityThread.main(ActivityThread.java:5373)
10-09 15:35:24.690 11596-11596/ie.betterweather.betterweather W/System.err? at java.lang.reflect.Method.invoke(Native Method)
10-09 15:35:24.690 11596-11596/ie.betterweather.betterweather W/System.err? at java.lang.reflect.Method.invoke(Method.java:372)
10-09 15:35:24.690 11596-11596/ie.betterweather.betterweather W/System.err? at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
10-09 15:35:24.690 11596-11596/ie.betterweather.betterweather W/System.err? at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)