Closed ArjunVermaGitHub closed 5 years ago
@ArjunVermaGitHub No worries :-) What do you mean with it doesn't work? Do you get an exception?
And did you configure the lang specific object handler like:
rs = new RiveScript();
rs.setHandler("javascript", new JavaScriptHandler());
We have various integration tests using macros. See e.g. https://github.com/aichaos/rivescript-java/blob/master/rivescript-core/src/integration-test/java/com/rivescript/JavaScriptObjectIT.java
Thank you so much. When I said it doesn't work, I meant it didnt give me the output I required. For example, in your reverse hello world program, instead of elloh dlrow, I got err:object not found. The program ran fine, just the output is unexpected. No, I did not configure it like you said to, but something weird is happening now that I did. When I try to use the setHandler function outside my onCreate() function for my app, the program cant find the function in the packages, but it does get recognized when I use the function inside it. Still, the application throws an error when I launch the activity.
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.script.ScriptEngineManager" on path: DexPathList[[zip file "/data/app/com.example.myapplication-2/base.apk", zip file "/data/app/com.example.myapplication-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.myapplication-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.myapplication-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.myapplication-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.myapplication-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.myapplication-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.myapplication-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.myapplication-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.myapplication-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.myapplication-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.myapplication-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.myapplication-2/lib/arm, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
is what seems relevant to me, please tell me if I should paste more of the stackTrace
Based on the exception (Didn't find class "javax.script.ScriptEngineManager"
) I think you are missing the javax.script
dependency. Probably it's not part of the Dalvik JVM but I'm not sure as I have no experience with Dalvik...
Maybe this helps: https://stackoverflow.com/questions/25371949/is-it-possible-to-use-javascript-code-in-android
It can't be fixed with an import statement. I cant seem to install a dependency either. Would it be faster to switch over to perl or some other type of macro? Or is it possible to use java functions in some way to get the same work done?
@ArjunVermaGitHub yes you could also use Java subroutines as , see https://github.com/aichaos/rivescript-java/blob/master/rivescript-core/src/integration-test/java/com/rivescript/JavaObjectIT.java for an example in an integration test.
But I wonder why you say it can't be fixed? It's not only about adding an import statement. You need to addition libraries (jars) to your project that contain the script engine implementation.
OK I installed the jar file, and now the import happens properly, but I got a new kind of exception: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Enumeration java.lang.ClassLoader.getResources(java.lang.String)' on a null object reference This is originating from the same line: bot.setHandler("javascript", new JavaScriptHandler()); Why is it a null object reference when I have already used the constructor?
I have no idea. Probably you have to look at the full stack trace to see from where it originates...
Well, I managed to do pretty well using Java macros. I've had a lot of fun with this and sincerely thank you for the help. I do feel there may have been something weird happening with the javascript for android business, but even if thats true, the workaround is really good. I have been developing a bot for the past few days and can envision the enormous applications this platform has to offer.
Thx for the feedback @ArjunVermaGitHub. I'm closing this issue for now. If you anything else feel free to raise another issue or re-open this one.
Hi again, and sorry for making this my personal forum but I don't know a better place to go than this. I have tried copying the perl macro from the website:
but it doesn't work. I have also tried javascript macros which have worked on the online compiler but they don't work here. I even used these imports: import com.rivescript.; import com.rivescript.lang.; import com.rivescript.macro.*; Am I missing something? Whenever I call the object macros I get error:object not found in place of my object in the output.