getting exception "Error while connecting UiAutomation" on starting instrumentation using Runtime.getRuntime().exec - android-testing

started the shell command from mainActivity.java,
Runtime.getRuntime().exec("am instrument -w com.example.android.testing.uiautomator.BasicSample.test/androidx.test.runner.AndroidJUnitRunner");
and trying to get a UiDevice object in AndroidJUnit4 class as below,
#RunWith(AndroidJUnit4.class)
#SdkSuppress(minSdkVersion = 18)
public class ChangeTextBehaviorTest {
#Before
public void startMainActivityFromHomeScreen() throws UiObjectNotFoundException,
InterruptedException {
// Initialize UiDevice instance
Instrumentation instr = InstrumentationRegistry.getInstrumentation();
mDevice = UiDevice.getInstance(instr);
}
On running the instrumantation from adb, it works fine but through shell command from mainActivity it fails with below reason,
Line 14779: 02-20 12:27:45.655 7344 7411 I TestRunner: started: testChangeText_newActivity(com.example.android.testing.uiautomator.BasicSample.ChangeTextBehaviorTest)
Line 14784: 02-20 12:27:45.667 7344 7411 E TestRunner: failed: testChangeText_newActivity(com.example.android.testing.uiautomator.BasicSample.ChangeTextBehaviorTest)
Line 14785: 02-20 12:27:45.667 7344 7411 E TestRunner: ----- begin exception -----
Line 14786: 02-20 12:27:45.669 7344 7411 E TestRunner: java.lang.RuntimeException: Error while connecting UiAutomation#f398452[id=-1, flags=0]
Line 14787: 02-20 12:27:45.669 7344 7411 E TestRunner: at android.app.UiAutomation.connect(UiAutomation.java:252)
Line 14788: 02-20 12:27:45.669 7344 7411 E TestRunner: at android.app.Instrumentation.getUiAutomation(Instrumentation.java:2182)
Line 14789: 02-20 12:27:45.669 7344 7411 E TestRunner: at androidx.test.uiautomator.UiDevice.getUiAutomation(UiDevice.java:1129)
Line 14790: 02-20 12:27:45.669 7344 7411 E TestRunner: at androidx.test.uiautomator.QueryController.<init>(QueryController.java:95)
Line 14791: 02-20 12:27:45.669 7344 7411 E TestRunner: at androidx.test.uiautomator.UiDevice.<init>(UiDevice.java:109)
Line 14792: 02-20 12:27:45.669 7344 7411 E TestRunner: at androidx.test.uiautomator.UiDevice.getInstance(UiDevice.java:261)
Line 14793: 02-20 12:27:45.669 7344 7411 E TestRunner: at com.example.android.testing.uiautomator.BasicSample.ChangeTextBehaviorTest.startMainActivityFromHomeScreen(ChangeTextBehaviorTest.java:73)
Line 14794: 02-20 12:27:45.669 7344 7411 E TestRunner: at java.lang.reflect.Method.invoke(Native Method)
Line 14795: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
Line 14796: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
Line 14797: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
Line 14798: 02-20 12:27:45.669 7344 7411 E TestRunner: at androidx.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:76)
Line 14799: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
Line 14800: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
Line 14801: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
Line 14802: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
Line 14803: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
Line 14804: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
Line 14805: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
Line 14806: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
Line 14807: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
Line 14808: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
Line 14809: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
Line 14810: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
Line 14811: 02-20 12:27:45.669 7344 7411 E TestRunner: at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:162)
Line 14812: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.Suite.runChild(Suite.java:128)
Line 14813: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.Suite.runChild(Suite.java:27)
Line 14814: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
Line 14815: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
Line 14816: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
Line 14817: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
Line 14818: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
Line 14819: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
Line 14820: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
Line 14821: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
Line 14822: 02-20 12:27:45.669 7344 7411 E TestRunner: at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
Line 14823: 02-20 12:27:45.669 7344 7411 E TestRunner: at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
Line 14824: 02-20 12:27:45.669 7344 7411 E TestRunner: at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:439)
Line 14825: 02-20 12:27:45.669 7344 7411 E TestRunner: at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2211)
Line 14826: 02-20 12:27:45.669 7344 7411 E TestRunner: Caused by: android.os.DeadObjectException
Line 14827: 02-20 12:27:45.669 7344 7411 E TestRunner: at android.os.BinderProxy.transactNative(Native Method)
Line 14828: 02-20 12:27:45.669 7344 7411 E TestRunner: at android.os.BinderProxy.transact(BinderProxy.java:550)
Line 14829: 02-20 12:27:45.669 7344 7411 E TestRunner: at android.app.IUiAutomationConnection$Stub$Proxy.connect(IUiAutomationConnection.java:422)
Line 14830: 02-20 12:27:45.669 7344 7411 E TestRunner: at android.app.UiAutomation.connect(UiAutomation.java:249)
Thannk you in Advance, little help if anyone already saw this will help to get through.

Related

Erlang: Fail to make a gen_server:call()

Given the following code:
-module(appender_server).
-behaviour(gen_server).
-export([start_link/1, stop/0]).
-export([append_synched/2]).
-export([init/1, handle_call/3, handle_cast/2]).
start_link(FilePath) ->
gen_server:start_link({local, ?MODULE}, ?MODULE, FilePath, []).
init(FilePath) ->
{ok, TheFile} = file:open(FilePath, [append]), % File is created if it does not exist.
io_lib:print(TheFile).
append_synched(FilePath, Text) ->
gen_server:call(?MODULE, {append_synched, FilePath, Text}).
handle_call({append_synched, FilePath, Text}, _From, LoopData) ->
io:fwrite("Hello!~n", []),
io:fwrite("LoopData:~p~n", LoopData),
io:fwrite("~p~n", FilePath),
io:fwrite("~p~n", Text).
handle_cast(append_asynched, Str) ->
{ok, theFile} = file:write_file(theFile, Str).
stop() ->
gen_server:cast(?MODULE, stop).
I then use the erlang shell to call the following and the get the errors:
1> cd("c:/Users/TalTe/WebAppsProjects/fileappender/src/").
c:/Users/TalTe/WebAppsProjects/fileappender/src
ok
2> c(appender_server).
{ok,appender_server}
3> appender_server:start_link("c:/temp/file.txt").
{error,{bad_return_value,"<0.88.0>"}}
4> =CRASH REPORT==== 2-Dec-2020::23:30:19.687000 ===
crasher:
initial call: appender_server:init/1
pid: <0.87.0>
registered_name: appender_server
exception exit: {bad_return_value,"<0.88.0>"}
in function gen_server:init_it/6 (gen_server.erl, line 409)
ancestors: [<0.79.0>]
message_queue_len: 0
messages: []
links: [<0.79.0>]
dictionary: []
trap_exit: false
status: running
heap_size: 376
stack_size: 28
reductions: 257
neighbours:
neighbour:
pid: <0.79.0>
registered_name: []
initial_call: {erlang,apply,2}
current_function: {io,execute_request,2}
ancestors: []
message_queue_len: 0
links: [<0.78.0>,<0.87.0>]
trap_exit: false
status: waiting
heap_size: 1598
stack_size: 26
reductions: 5365
current_stacktrace: [{io,execute_request,2,[{file,"io.erl"},{line,571}]},
{shell,exprs,7,[{file,"shell.erl"},{line,693}]},
{shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]},
{shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]
** exception error: {bad_return_value,"<0.88.0>"}
4> appender_server:append_synched("c:/temp:/file.txt", "Hello").
** exception exit: {noproc,{gen_server,call,
[appender_server,
{append_synched,"c:/temp:/file.txt","Hello"}]}}
in function gen_server:call/2 (gen_server.erl, line 238)
5>
Please help me understand what am I doing wrong here?
BTW, the file was created despite the error on step 3.
The init callback should return {ok, SomeState}. In your case the return value of init is the return value of io_lib:print()

Installing pyspark in Dockerfile

I had a Dockerfile as follows
FROM python:3.7
RUN apt-get update
RUN apt-get install default-jdk -y
COPY requirements.txt ./
RUN pip install -r requirements.txt
which I was using in a CI pipeline on GitLab, and it was working fine.
Recently, however, it has stopped working. I haven't updated my requirements.txt file, so might this be because default-jdk has changed?
How should I update my Dockerfile so it now correctly installs pyspark?
EDIT
example of error:
/usr/local/lib/python3.7/site-packages/pyspark/rdd.py:824: in collect
port = self.ctx._jvm.PythonRDD.collectAndServe(self._jrdd.rdd())
/usr/local/lib/python3.7/site-packages/py4j/java_gateway.py:1160: in __call__
answer, self.gateway_client, self.target_id, self.name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
answer = 'xro1291'
gateway_client = <py4j.java_gateway.GatewayClient object at 0x7f6490c2a350>
target_id = 'z:org.apache.spark.api.python.PythonRDD', name = 'collectAndServe'
def get_return_value(answer, gateway_client, target_id=None, name=None):
"""Converts an answer received from the Java gateway into a Python object.
For example, string representation of integers are converted to Python
integer, string representation of objects are converted to JavaObject
instances, etc.
:param answer: the string returned by the Java gateway
:param gateway_client: the gateway client used to communicate with the Java
Gateway. Only necessary if the answer is a reference (e.g., object,
list, map)
:param target_id: the name of the object from which the answer comes from
(e.g., *object1* in `object1.hello()`). Optional.
:param name: the name of the member from which the answer comes from
(e.g., *hello* in `object1.hello()`). Optional.
"""
if is_error(answer)[0]:
if len(answer) > 1:
type = answer[1]
value = OUTPUT_CONVERTER[type](answer[2:], gateway_client)
if answer[1] == REFERENCE_TYPE:
raise Py4JJavaError(
"An error occurred while calling {0}{1}{2}.\n".
> format(target_id, ".", name), value)
E py4j.protocol.Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.collectAndServe.
E : java.lang.IllegalArgumentException
E at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
E at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
E at org.apache.xbean.asm5.ClassReader.<init>(Unknown Source)
E at org.apache.spark.util.ClosureCleaner$.getClassReader(ClosureCleaner.scala:46)
E at org.apache.spark.util.FieldAccessFinder$$anon$3$$anonfun$visitMethodInsn$2.apply(ClosureCleaner.scala:449)
E at org.apache.spark.util.FieldAccessFinder$$anon$3$$anonfun$visitMethodInsn$2.apply(ClosureCleaner.scala:432)
E at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:733)
E at scala.collection.mutable.HashMap$$anon$1$$anonfun$foreach$2.apply(HashMap.scala:103)
E at scala.collection.mutable.HashMap$$anon$1$$anonfun$foreach$2.apply(HashMap.scala:103)
E at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:230)
E at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
E at scala.collection.mutable.HashMap$$anon$1.foreach(HashMap.scala:103)
E at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:732)
E at org.apache.spark.util.FieldAccessFinder$$anon$3.visitMethodInsn(ClosureCleaner.scala:432)
E at org.apache.xbean.asm5.ClassReader.a(Unknown Source)
E at org.apache.xbean.asm5.ClassReader.b(Unknown Source)
E at org.apache.xbean.asm5.ClassReader.accept(Unknown Source)
E at org.apache.xbean.asm5.ClassReader.accept(Unknown Source)
E at org.apache.spark.util.ClosureCleaner$$anonfun$org$apache$spark$util$ClosureCleaner$$clean$14.apply(ClosureCleaner.scala:262)
E at org.apache.spark.util.ClosureCleaner$$anonfun$org$apache$spark$util$ClosureCleaner$$clean$14.apply(ClosureCleaner.scala:261)
E at scala.collection.immutable.List.foreach(List.scala:381)
E at org.apache.spark.util.ClosureCleaner$.org$apache$spark$util$ClosureCleaner$$clean(ClosureCleaner.scala:261)
E at org.apache.spark.util.ClosureCleaner$.clean(ClosureCleaner.scala:159)
E at org.apache.spark.SparkContext.clean(SparkContext.scala:2292)
E at org.apache.spark.SparkContext.runJob(SparkContext.scala:2066)
E at org.apache.spark.SparkContext.runJob(SparkContext.scala:2092)
E at org.apache.spark.rdd.RDD$$anonfun$collect$1.apply(RDD.scala:939)
E at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
E at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
E at org.apache.spark.rdd.RDD.withScope(RDD.scala:363)
E at org.apache.spark.rdd.RDD.collect(RDD.scala:938)
E at org.apache.spark.api.python.PythonRDD$.collectAndServe(PythonRDD.scala:153)
E at org.apache.spark.api.python.PythonRDD.collectAndServe(PythonRDD.scala)
E at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
E at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
E at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
E at java.base/java.lang.reflect.Method.invoke(Method.java:566)
E at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
E at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
E at py4j.Gateway.invoke(Gateway.java:282)
E at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
E at py4j.commands.CallCommand.execute(CallCommand.java:79)
E at py4j.GatewayConnection.run(GatewayConnection.java:214)
E at java.base/java.lang.Thread.run(Thread.java:834)
/usr/local/lib/python3.7/site-packages/py4j/protocol.py:320: Py4JJavaError
Changing the base image to python:3.7-stretch worked for me

error "line 1 column 27: invalid expression, unexpected input" in z3

(simplify (str.++ (str.at "abc" 1) (str.at "abc" 0)))
(simplify (str.indexof "abcabc" "a"))
(simplify (str.indexof "abcabc" "a" 1))
(simplify (str.substr "xxabcyy" 2 3))
link
When I run the above code in z3-smt lib with file name as extension .smt or .smt2 using command: z3 -smt2 eg1.smt or z3 -smt2 eg1.smt2
I get the error :
(error "line 1 column 27: invalid expression, unexpected input")
(error "line 2 column 23: invalid expression, unexpected input")
(error "line 3 column 23: invalid expression, unexpected input")
(error "line 4 column 22: invalid expression, unexpected input")
Please help.

exception in xamarin.forms in System.Net.Http

I have this exception that i printed in my log that cause the app to crash in android, motorola device xt1058.
The problem is that I don't have the device and I got the log from the client who sent me the log file.
I have no idea where the logs comes from.
I have all the app wrapped in try catch but still the app crashed
09:37:10 - Error in TaskSchedulerOnUnobservedTaskException:
A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.
09:37:11 - Error in TaskSchedulerOnUnobservedTaskException: System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.Net.WebException: Error: NameResolutionFailure
at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00064] in <552eeeb8705c4abb9eeb5ebce43b6865>:0
at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x00014] in <52ca43e23d764403a7855ae066156266>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <52ca43e23d764403a7855ae066156266>:0
at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () [0x0041e] in <21d260c0947046f0aae7990757a51ba3>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <52ca43e23d764403a7855ae066156266>:0
at System.Net.Http.HttpClient+c__async0.MoveNext () [0x000f3] in <21d260c0947046f0aae7990757a51ba3>:0
--- End of inner exception stack trace ---
---> (Inner Exception #0) System.Net.WebException: Error: NameResolutionFailure
at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00064] in <552eeeb8705c4abb9eeb5ebce43b6865>:0
at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x00014] in <52ca43e23d764403a7855ae066156266>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <52ca43e23d764403a7855ae066156266>:0
at System.Net.Http.HttpClientHandler+<SendAsync>c__async0.MoveNext () [0x0041e] in <21d260c0947046f0aae7990757a51ba3>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <52ca43e23d764403a7855ae066156266>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <52ca43e23d764403a7855ae066156266>:0
at System.Net.Http.HttpClient+c__async0.MoveNext () [0x000f3] in <21d260c0947046f0aae7990757a51ba3>:0 <---
the problem is with one of the http call which leads you to this error, so cross check your API on Postman extension if it returns what you expect. check your website is running, check network status and please have a habit of surrounding these calls with try and catch.
Once you surround all your http calls with try catch put your debugger in the catch statement understand the exception and verify the same URL.

ParseKit simple example does not work and parserFromGrammer shows lots of exceptions with PEGRecognitionExceptions in console

I just came across ParseKit, and I incorporated in my IOS project using the instructions from http://parsekit.com/iphone.html. I got it from Google Code, and the checked out version is 1543.
Everything compiled and built fine.
Then I tried to use the (final working) simple example from one of the posts - Can't get simple ParseKit example working
NSString *test = #"FOO : BAR";
NSString *grammar = #"#start = foo ':' bar; foo = 'FOO'; bar = 'BAR';";
PKParser *parser = nil;
NSError *err = nil;
parser = [[PKParserFactory factory] parserFromGrammar:grammar assembler:self error:&err];
NSLog(#"parser: error1: %#", err);
[parser parse:test error:&err];
NSLog(#"parser: error2: %#", err);
- (void)didMatchFoo:(PKAssembly *)a
{
NSLog(#"FOO");
}
- (void)didMatchBar:(PKAssembly *)a
{
NSLog(#"BAR");
}
when the execution gets to the line
parser = [[PKParserFactory factory] parserFromGrammar:grammar assembler:self error:&err];
I see a lot of error messages in the console. The didMatchFoo and didMatchBar do not fire.
Here are the messages from the console:
objc[53244]: EXCEPTIONS: throwing 0xb47f040 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd2e0] for exception 0xb47f020
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd2e0] for exception 0xb47f020
objc[53244]: EXCEPTIONS: handling exception 0xb47f020 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0xb47f5e0 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd170] for exception 0xb47f5c0
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd170] for exception 0xb47f5c0
objc[53244]: EXCEPTIONS: handling exception 0xb47f5c0 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0xa589360 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd230] for exception 0xa589340
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd230] for exception 0xa589340
objc[53244]: EXCEPTIONS: handling exception 0xa589340 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0xa589470 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd290] for exception 0xa589450
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd290] for exception 0xa589450
objc[53244]: EXCEPTIONS: handling exception 0xa589450 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0xa58bd80 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd380] for exception 0xa58bd60
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd380] for exception 0xa58bd60
objc[53244]: EXCEPTIONS: handling exception 0xa58bd60 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0x8b848e0 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd210] for exception 0x8b848c0
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd210] for exception 0x8b848c0
objc[53244]: EXCEPTIONS: handling exception 0x8b848c0 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0x8ba5610 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd2d0] for exception 0x8ba55f0
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd2d0] for exception 0x8ba55f0
objc[53244]: EXCEPTIONS: handling exception 0x8ba55f0 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0xb57a160 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd330] for exception 0xb57a140
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd330] for exception 0xb57a140
objc[53244]: EXCEPTIONS: handling exception 0xb57a140 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0xb57a730 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd2e0] for exception 0xb57a710
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd2e0] for exception 0xb57a710
objc[53244]: EXCEPTIONS: handling exception 0xb57a710 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0xb57ac90 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd170] for exception 0xb57ac70
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd170] for exception 0xb57ac70
objc[53244]: EXCEPTIONS: handling exception 0xb57ac70 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0xb57af30 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd230] for exception 0xb57af10
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd230] for exception 0xb57af10
objc[53244]: EXCEPTIONS: handling exception 0xb57af10 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0x8ba5c40 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd290] for exception 0x8ba5c20
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd290] for exception 0x8ba5c20
objc[53244]: EXCEPTIONS: handling exception 0x8ba5c20 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0x8ba5f40 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd380] for exception 0x8ba5f20
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd380] for exception 0x8ba5f20
objc[53244]: EXCEPTIONS: handling exception 0x8ba5f20 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0x8e80b40 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd210] for exception 0x8e80b20
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd210] for exception 0x8e80b20
objc[53244]: EXCEPTIONS: handling exception 0x8e80b20 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0x8e4ac80 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd2d0] for exception 0x8e4ac60
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd2d0] for exception 0x8e4ac60
objc[53244]: EXCEPTIONS: handling exception 0x8e4ac60 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0x8ba6200 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd330] for exception 0x8ba61e0
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd330] for exception 0x8ba61e0
objc[53244]: EXCEPTIONS: handling exception 0x8ba61e0 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
objc[53244]: EXCEPTIONS: throwing 0x8ba62c0 (object 0xa17b7b0, a PEGRecognitionException)
objc[53244]: EXCEPTIONS: searching through frame [ip=0xf23ac sp=0xbfffd420] for exception 0x8ba62a0
objc[53244]: EXCEPTIONS: catch(PEGRecognitionException)
objc[53244]: EXCEPTIONS: unwinding through frame [ip=0xf23ac sp=0xbfffd420] for exception 0x8ba62a0
objc[53244]: EXCEPTIONS: handling exception 0x8ba62a0 at 0xf2406
objc[53244]: EXCEPTIONS: finishing handler
[parser parse:test error:&err];
Does not invoke callbacks, and does not return any error either.
Any pointers or help would be greatly appreciated!
PS - I uncommented some NSLOG statements in ParseKit to see what the exceptions above were:
For a grammar of
NSString *grammar = #"#start = expr; expr = abc col def; abc = 'ABC'; col = ':'; def = 'DEF';";
I got
Expected : #
Line : 1
Near : ; expr = abc
Found : =
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def
Found : col
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def
Found : def
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def
Found : def
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc
Found : ;
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc
Found : ;
No viable alternative found in rule 'primaryExpr'.
Line : 1
Near : ; expr = abc col def ; abc
Found : ;
Expected : |
Line : 1
Near : ; expr = abc col def ; abc
Found : ;
Expected : #
Line : 1
Near : ; expr = abc col def ; abc
Found : =
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc
Found : col
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc
Found : def
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc
Found : def
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc
Found : ;
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc
Found : ;
No viable alternative found in rule 'primaryExpr'.
Line : 1
Near : ; expr = abc col def ; abc
Found : ;
Expected : |
Line : 1
Near : ; expr = abc col def ; abc
Found : ;
Expected : #
Line : 1
Near : ; expr = abc col def ; abc = 'ABC'
Found : =
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col
Found : ;
No viable alternative found in rule 'primaryExpr'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col
Found : ;
Expected : |
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col
Found : ;
Expected : #
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col
Found : =
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col
Found : ;
No viable alternative found in rule 'primaryExpr'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col
Found : ;
Expected : |
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col
Found : ;
Expected : #
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':'
Found : =
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def
Found : ;
No viable alternative found in rule 'primaryExpr'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def
Found : ;
Expected : |
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def
Found : ;
Expected : #
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def
Found : =
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def
Found : ;
No viable alternative found in rule 'primaryExpr'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def
Found : ;
Expected : |
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def
Found : ;
Expected : #
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def = 'DEF'
Found : =
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def = 'DEF' ;
Found : ;
No viable alternative found in rule 'primaryExpr'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def = 'DEF' ;
Found : ;
Expected : |
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def = 'DEF' ;
Found : ;
Expected : #
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def = 'DEF' ;
Found : =
No viable alternative found in rule 'predicate'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def = 'DEF' ;
Found : ;
No viable alternative found in rule 'primaryExpr'.
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def = 'DEF' ;
Found : ;
Expected : |
Line : 1
Near : ; expr = abc col def ; abc = 'ABC' ; col = ':' ; def = 'DEF' ;
Found : ;
No viable alternative found in rule 'statement'.
Line : 2147483647
Near : «EOF»
Found : «EOF»
I got it to work ... sort of!
Where things differ from the documentation ...
I linked with libParseKitMobile.a ... it was obvious since it was the only target for iOS.
I used ParserGenApp to first generate the .h and .m for my grammar
I included these generated files in my project. My project was not built with ARC, and ParseKit does, so I added -fobjc-arc to the compile flag of the generated .m
Then usage in my code was as follows:
NSString *test = #"ABC : DEF";
MyParser *parser = [[MyParser alloc] init];
NSError *err = nil;
PKAssembly *result = [parser parseString:test
assembler:self
error:&err];
if (!result) {
if (err) NSLog(#"%#", err);
} else {
NSLog(#"%#", [result description]);
}
The callback needs to be of the form:
- (void)parser:(PKParser *)p didMatchAbc:(PKAssembly *)a;
(the ParseKit documentation mentions -(void)didMatchAbc:(PKAssembly *a); but that won't work as the required signature is different)
Downloading and trying the full MiniMath project from Github helped me figure some of it out - https://github.com/itod/ParseKitMiniMathExample
MiniMath example was also available for download as a zip, but that does not seem to have the embedded ParseKit files and I had some problems with that.
Hope this helps others looking to use ParseKit in their iOS projects!
Todd Ditchendorf, thanks a lot for your work on ParseKit! Unfortunately, it is a little fragmented - Github version, Google Code version, and the documentation in the website is sparse, and interesting, has links to both Github and Google code, adding to the confusion.
parser = [[PKParserFactory factory] parserFromGrammar:grammar assembler:self error:&err];
does not seem to work. However, generating the parser code first and then using it seems to work.
It will be great if ParseKit can be cleaned up and brought up-to-date! It is a very useful tool, and all the more so because I don't see any other alternative being mentioned. If you would like help in cleaning up ParseKit and its documentation, I would be glad to help!
Cheers,
Sridhar

Resources