سؤال

I am using android-json-rpc library. I added the android-json-rpc-0.3.4.jar library to my build path. Just following some basic tutorial.

Here is my code:

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;
  }
}

Error:

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

While going around this error, I found out that some guy has a blogpost about the same issue on a Mac Lion (same as mine) but worked fine on Ubuntu. http://www.1771.in/android-jsonrpc-not-working-on-mac.html

Could anyone help me with a workaround for this issue?

Thanks, Dexter

هل كانت مفيدة؟

المحلول

There are 2 options I have in mind. 1. Have "libs" folder in root of the project, copy lib there, no need to add to the build path. This is a new requirement from android team. 2. Add import of used class.

Just got it compiled and working.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top