gpt4 book ai didi

android - 改造给出 java.lang.VerifyError

转载 作者:太空狗 更新时间:2023-10-29 15:38:24 26 4
gpt4 key购买 nike

我正在尝试使用 Retrofit 从站点获取数据。我已经按照在线示例http://kdubblabs.com/java/retrofit-by-square/retrofit-simple-get/http://corner.squareup.com/2013/05/retrofit-one-dot-oh.html .我在下面粘贴我的代码 -

public class MainActivity extends ActionBarActivity {

public interface CatAPI{
@GET("/apj/category.php")
public String subCat();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}

/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {

public PlaceholderFragment() {
}

@SuppressWarnings("deprecation")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
Builder b=new RestAdapter.Builder();
Builder s=b.setServer("http://kurdshopping.net/");
RestAdapter adapter=s.build();
CatAPI api=adapter.create(CatAPI.class);
String response=api.subCat();
Log.i("Subcat", response);
return rootView;
}
}

}

请告诉我我做错了什么。 logcat 显示以下错误 -

05-06 17:23:41.037: E/AndroidRuntime(3365): FATAL EXCEPTION: main
05-06 17:23:41.037: E/AndroidRuntime(3365): Process: com.example.retrofitdemo, PID: 3365
05-06 17:23:41.037: E/AndroidRuntime(3365): java.lang.VerifyError: retrofit/converter/GsonConverter
05-06 17:23:41.037: E/AndroidRuntime(3365): at retrofit.Platform$Android.defaultConverter(Platform.java:117)
05-06 17:23:41.037: E/AndroidRuntime(3365): at retrofit.RestAdapter$Builder.ensureSaneDefaults(RestAdapter.java:714)
05-06 17:23:41.037: E/AndroidRuntime(3365): at retrofit.RestAdapter$Builder.build(RestAdapter.java:707)
05-06 17:23:41.037: E/AndroidRuntime(3365): at com.example.retrofitdemo.MainActivity$PlaceholderFragment.onCreateView(MainActivity.java:82)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.app.Activity.performStart(Activity.java:5241)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.app.ActivityThread.access$800(ActivityThread.java:135)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.os.Handler.dispatchMessage(Handler.java:102)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.os.Looper.loop(Looper.java:136)
05-06 17:23:41.037: E/AndroidRuntime(3365): at android.app.ActivityThread.main(ActivityThread.java:5017)
05-06 17:23:41.037: E/AndroidRuntime(3365): at java.lang.reflect.Method.invokeNative(Native Method)
05-06 17:23:41.037: E/AndroidRuntime(3365): at java.lang.reflect.Method.invoke(Method.java:515)
05-06 17:23:41.037: E/AndroidRuntime(3365): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-06 17:23:41.037: E/AndroidRuntime(3365): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-06 17:23:41.037: E/AndroidRuntime(3365): at dalvik.system.NativeStart.main(Native Method)

如果有人可以帮助我开始改造,那就太好了。预先感谢您的帮助。

最佳答案

看起来你不见了Gson , 或许?尝试将 Gson .jar 添加到您的 lib 文件夹。

关于android - 改造给出 java.lang.VerifyError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23510377/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com