Note that there are some explanatory texts on larger screens.

plurals
  1. PO(Android) ANTLRStringStream throwing exception
    primarykey
    data
    text
    <p>I've been trying to get ANTLR-3.5-complete.jar to work on an Android app, but I can't get it to work! Bart Kiers's answer <a href="https://stackoverflow.com/questions/9594966/android-antlr-make-not-working-properly">HERE</a> has helped me a lot, but I still can't get it to work.</p> <p>I'm trying to make a Button that, when clicked, will validate whether the text in the EditText view is correct according to my <strong>grammar.g</strong>, but it doesn't matter whether the text I input is correct or not, my app always crashes when I click the button while instantiating the ANTLRStringStream. Here's what I have:</p> <pre><code>public void onClickVerify(View v) throws TypeNotPresentException { String source = "foobar"; Log.e("TestDebug", "Instantiating views"); TextView out = (TextView) findViewById(R.id.textView1); EditText in = (EditText) findViewById(R.id.editText1); try { Log.e("TestDebug", "Getting source from EditText"); source = in.getText().toString(); Log.e("TestDebug", "source = " + source); Log.e("TestDebug", "Instantiating stream"); ANTLRStringStream stream = new ANTLRStringStream(source); Log.e("TestDebug", "Instantiating lexer"); grammarLexer lexer = new grammarLexer(stream); Log.e("TestDebug", "Instantiating parser"); grammarParser parser = new grammarParser( new BufferedTokenStream(lexer)); Log.e("TestDebug", "Applying rule to parser"); out.setText(source + " = " + !parser.failed()); } catch (IllegalStateException ise) { out.setText("Exception caught"); } } </code></pre> <p>And here's what I see in the logs:</p> <ul> <li>Instantiating views</li> <li>Getting source from EditText</li> <li>source = test33</li> <li>Instantiating stream</li> </ul> <p>And then the "Unfortunately, TestAntlrApp has stopped." window pops up.</p> <p>EDIT: Here's more of my logcat.</p> <pre><code>java.lang.IllegalStateException: Could not execute method of the activity at android.view.View$1.onClick(View.java:3591) at android.view.View.performClick(View.java:4084) at android.view.View$PerformClick.run(View.java:16966) 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:4745) 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:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at android.view.View$1.onClick(View.java:3586) ... 11 more Caused by: java.lang.NoClassDefFoundError: org.antlr.runtime.ANTLRStringStream at com.test.antlr.MainActivity.onClickVerify(MainActivity.java:89) </code></pre> <p>Something about not finding the class ANTLRStringStream class? However there seems to be no errors/warnings in the code and I can even see the class's hierarchy.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload