我一直在做这个教程。
但我似乎无法让应用程序运行。在尝试修复错误数小时后,我在我的 MainActivity.Java 中将其精确定位到了这一行SCService scService = SoundCloud.getService();
(只是指出我在 Java 错误方面有点缺乏经验)。
所以我决定创建一个小程序来测试 API 调用是否正在检索以及任何东西(我正在尝试从我的 soundcloud 帐户中获取曲目)
import retrofit.Call;
import retrofit.Retrofit;
import retrofit.http.GET;
public class MyTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Retrofit retrofit = new Retrofit.Builder().baseUrl("https://api.soundcloud.com/").build();
SCService service = retrofit.create(SCService.class);
System.out.println("Welcome boi");
System.out.println(service.me().toString());
}
public interface SCService {
@GET("tracks?client_id=" + Config.CLIENT_ID)
Callme();
}
}
我收到了这个错误:
Exception in thread "main" java.lang.NoClassDefFoundError: okio/Source
at retrofit.Retrofit$Builder.baseUrl(Retrofit.java:301)
at com.casula.testingapp.MyTest.main(MyTest.java:12)
Caused by: java.lang.ClassNotFoundException: okio.Source
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
请帮助我认为这与我的 Retrofit.jar 库有关。我正在使用 Retrofit2.0.0-3beta 和 Eclipse IDE - 如何解决此问题以便能够从我的帐户中检索曲目?