WeatherLib - Volley.jar错误导致应用程序崩溃

时间:2014-09-22 18:42:48

标签: java android debugging jar android-volley

我正在尝试使用 - https://github.com/survivingwithandroid/WeatherLib/tree/master/demo

实施天气应用

但是我在清理,重建,重新启动等后出现以下错误 -

09-22 14:35:26.519    8083-8083/com.the.app.the E/dalvikvm﹕ Could not find class 'com.android.volley.toolbox.StringRequest', referenced from method com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault._doSearch
09-22 14:35:26.519    8083-8083/com.the.app.the E/dalvikvm﹕ Could not find class 'com.android.volley.toolbox.StringRequest', referenced from method com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault.getCurrentCondition
09-22 14:35:26.519    8083-8083/com.the.app.the E/dalvikvm﹕ Could not find class 'com.android.volley.toolbox.ImageRequest', referenced from method com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault.getDefaultProviderImage
09-22 14:35:26.519    8083-8083/com.the.app.the E/dalvikvm﹕ Could not find class 'com.android.volley.toolbox.StringRequest', referenced from method com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault.getForecastWeather
09-22 14:35:26.519    8083-8083/com.the.app.the E/dalvikvm﹕ Could not find class 'com.android.volley.toolbox.StringRequest', referenced from method com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault.getHistoricalWeather
09-22 14:35:26.519    8083-8083/com.the.app.the E/dalvikvm﹕ Could not find class 'com.android.volley.toolbox.StringRequest', referenced from method com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault.getHourForecastWeather
09-22 14:35:26.519    8083-8083/com.the.app.the E/dalvikvm﹕ Could not find class 'com.android.volley.toolbox.ImageRequest', referenced from method com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault.getImage
09-22 14:35:26.519    8083-8083/com.the.app.the E/dalvikvm﹕ Could not find class 'com.android.volley.toolbox.StringRequest', referenced from method com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault.getProviderWeatherFeature
09-22 14:35:26.519    8083-8083/com.the.app.the E/dalvikvm﹕ Could not find class 'com.android.volley.toolbox.ImageRequest', referenced from method com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault.getWeatherImage
09-22 14:35:26.529    8083-8083/com.the.app.the E/dalvikvm﹕ Could not find class 'com.android.volley.toolbox.StringRequest', referenced from method com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault.searchCityByLocation
09-22 14:35:26.629    8083-8083/com.the.app.the E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: com.android.volley.toolbox.Volley
            at com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault.init(WeatherClientDefault.java:95)
            at com.survivingwithandroid.weather.lib.WeatherClient$ClientBuilder.build(WeatherClient.java:482)
            at com.the.app.the.Weather.WeatherContext.getClient(WeatherContext.java:38)
            at com.the.app.the.Weather.fragment.WeatherFragment.onActivityCreated(WeatherFragment.java:47)
            at com.the.app.the.Weather.fragment.CurrentWeatherFragment.onActivityCreated(CurrentWeatherFragment.java:75)
            at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:848)
            at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
            at android.app.BackStackRecord.run(BackStackRecord.java:635)
            at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397)
            at android.app.Activity.performStart(Activity.java:5211)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2108)
            at android.app.ActivityThread.access$600(ActivityThread.java:138)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4941)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
            at dalvik.system.NativeStart.main(Native Method)

我仍然是app dev的新手,所以我不确定错误在哪里。我知道它与volley.jar有关,我已经将我的jar添加到lib并将它们添加为库。当单击库中的文件它告诉我找不到源时,我尝试附加源但它什么也没做。

感谢任何帮助。感谢

更新 好吧,好像我错过了一个图书馆,感谢@Francesco指出了这一点。但是在添加库之后,当前的天气选项卡似乎显示正常但是当点击预测选项卡时,我知道会收到此错误---

09-23 11:39:52.354  18832-18832/com.thewave.app.thewave E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: com.survivingwithandroid.weather.lib.R$string
            at com.survivingwithandroid.weather.lib.WeatherCode.<clinit>(WeatherCode.java:36)
            at com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapCodeProvider.getWeatherCode(OpenweathermapCodeProvider.java:98)
            at com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getForecastWeather(OpenweathermapProvider.java:251)
            at com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault$9.onResponse(WeatherClientDefault.java:454)
            at com.survivingwithandroid.weather.lib.client.volley.WeatherClientDefault$9.onResponse(WeatherClientDefault.java:449)
            at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
            at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
            at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
            at android.os.Handler.handleCallback(Handler.java:615)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4941)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:561)
            at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:0)

我是你正在使用的lib背后的开发者。 我猜你没有正确引用该库。 如果您使用的是Android工作室,我建议您在graddle文件中添加依赖项

dependencies {                  
compile 'com.survivingwithandroid:weatherlib:1.5.2'
compile 'com.survivingwithandroid:weatherlib_volleyclient:1.5.2'
compile 'com.mcxiaoke.volley:library:1.0.6@aar' (or whatever you like)

}

否则,如果你使用eclipse,你可以克隆volley项目并将其添加为项目依赖项。 如果您想了解更多信息,请点击此处: Weatherlib