【问题标题】:Android error: NoClassDefFound error while using android-json-rpcAndroid 错误:使用 android-json-rpc 时出现 NoClassDefFound 错误
【发布时间】:2012-08-03 20:50:15
【问题描述】:

我正在使用 android-json-rpc 库。我将 android-json-rpc-0.3.4.jar 库添加到我的构建路径中。只需遵循一些基本教程即可。

这是我的代码:

public class MainActivity extends Activity {

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    TextView tv = (TextView) findViewById(R.id.text_view);
    tv.setText(testMethod());
  }

  private String testMethod() {
    // Crashes here on this line
    JSONRPCClient client = JSONRPCClient.create("10.1.2.3/json", JSONRPCParams.Versions.VERSION_2);
    String string = "";
    try {
        string = client.callString("cf.test");
    } catch (JSONRPCException e) {
        Log.i("JSON-RPC Client", e.toString());
    }
    return string;
  }
}

错误:

 *AndroidRuntime(1528): java.lang.NoClassDefFoundError: org.alexd.jsonrpc.JSONRPCParams$Versions*

在解决这个错误时,我发现有些人在 Mac Lion(和我的一样)上有一篇关于相同问题的博文,但在 Ubuntu 上运行良好。 http://www.1771.in/android-jsonrpc-not-working-on-mac.html

谁能帮我解决这个问题?

谢谢, 德克斯特

【问题讨论】:

    标签: android macos json-rpc


    【解决方案1】:

    我想到了两个选项。 1.项目根目录下有“libs”文件夹,将lib复制到那里,无需添加到构建路径。这是android团队的新要求。 2.添加使用类的导入。

    刚刚编译并运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多