2017년 5월 16일 화요일

Runtime error after installing APK, works fine in dev mode


I am using App Inventor 2 on Win7 with Chrome 31.
My app is a game involving two UFO's, a bomb, a bullet and two sprites representing explosions.
When I developed the game, I used the AI Companion 2 to see the result. All went well, and I created a package to test it out on some other devices. The first one of course was the same phone (Samsung Google Nexus, Android 4.3) I developed it on.
To my surprise it throws a runtime error the moment it is started. I can see the app doing the right stuff in the background, but the Runtime error/End application dialog is flashing in the foreground.
I tried to find something in the logs through "Android System Info" app, but could not find anything.
Please advise.
--
can you send the source so we can have a look?

--
Thanks for the interest and quick reply.
I don't mind sharing the code, of course. It is quite big though... especially if I have to share a screendump of the blocks. Will this work: http://ai2.appinventor.mit.edu/#61960017? Or should I share it in another way?
After my post, I found the post on the nested join, I had that too, but fixing it using the mutator didn't help.
--
Go to 'My Porjects' page, click on the project you want to export,
then go to 'Project --> export' and it will download as an aia file.
You can attach that to your report.

--
Sorry, when I say 'click' I mean on the checkbox beside the project,
not on the project itself.

--
You need to check your timers; one of them (don't know which one) is
throwing exceptions all the time and making the app crash; it even crashed my phone. 

--
The only timer that's enabled from the start of the app is the one for the bomb.
I reduced it to this and still it crashes.
How did you find out one of the timers was responsible?

Inline image 1

--
you can attach your devive through USB and use 'adb logcat': http://developer.android.com/tools/help/logcat.html
You need to have the Android SDK installed though.

--
I attached the USB cable, and got a log showing the stacktrace of the runtime error. No matter how I simplify the app (I removed the timer given above, then the edge reached) I still get an error like this:
W/System.err( 9255): java.lang.NullPointerException
W/System.err( 9255):    at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:163)
W/System.err( 9255):    at appinventor.ai_jhvanderven.UFO_timer_problem.Screen1.ufo$TouchUp(Screen1.yail:72)

The last line depends on what I remove... It has been the bomTimer and the badufo, and now it is the ufo...
The rest of the trace is the same:
W/System.err( 9255):    at appinventor.ai_jhvanderven.UFO_timer_problem.Screen1$frame.apply2(Screen1.yail:10239)
W/System.err( 9255):    at gnu.expr.ModuleBody.applyN(ModuleBody.java:230)
W/System.err( 9255):    at appinventor.ai_jhvanderven.UFO_timer_problem.Screen1$frame.applyN(Screen1.yail)
W/System.err( 9255):    at gnu.expr.ModuleMethod.applyN(ModuleMethod.java:222)
W/System.err( 9255):    at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
W/System.err( 9255):    at gnu.kawa.functions.Apply.applyN(Apply.java:70)
W/System.err( 9255):    at gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
W/System.err( 9255):    at appinventor.ai_jhvanderven.UFO_timer_problem.Screen1.dispatchEvent(Screen1.yail:10120)
W/System.err( 9255):    at com.google.appinventor.components.runtime.EventDispatcher.delegateDispatchEvent(EventDispatcher.java:219)
W/System.err( 9255):    at com.google.appinventor.components.runtime.EventDispatcher.dispatchEvent(EventDispatcher.java:197)
W/System.err( 9255):    at com.google.appinventor.components.runtime.Sprite$1.run(Sprite.java:366)
W/System.err( 9255):    at android.os.Handler.handleCallback(Handler.java:730)
W/System.err( 9255):    at android.os.Handler.dispatchMessage(Handler.java:92)
W/System.err( 9255):    at android.os.Looper.loop(Looper.java:137)
W/System.err( 9255):    at android.app.ActivityThread.main(ActivityThread.java:5103)
W/System.err( 9255):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 9255):    at java.lang.reflect.Method.invoke(Method.java:525)
W/System.err( 9255):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
W/System.err( 9255):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
W/System.err( 9255):    at dalvik.system.NativeStart.main(Native Method)
Any thoughts?
--
keep removing timers until you find the offender. Make sure you have copies of your app though.
--
I disabled all event blocks. The app then starts without errors. And without functionality :-(

I then enabled a few that will not be called because they are activated by the other blocks. That also ran error free.

Then I enabled the first interaction: dragging the ufo around, that also worked.

Next I enabled the TouchUp event on the ufo: the error occurred once the touch up event fires for the first time:
W/System.err(32103): java.lang.NullPointerException
W/System.err(32103):    at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:163)
W/System.err(32103):    at appinventor.ai_jhvanderven.UFO_timer_problem.Screen1.ufo$TouchUp(Screen1.yail:71)
W/System.err(32103):    at appinventor.ai_jhvanderven.UFO_timer_problem.Screen1$frame.apply2(Screen1.yail:10239)

Then I looked at the TouchUp block, and I could not find anything wrong with it. Just to make a change I removed the calls to global variables (one getter, one setter). The event fired without an error. The sound plays, the rocket starts to move from the correct spot.

Then I put the calls back in, but changed not variable to variable = false. Luckily the error reoccurred...

Now I don't know what to try next. Here's the function:
Inline image 1
So without the get and the set, it works, but with it an runtime error is raised.

Please advise.

--
Can you think of a small project in which you can use a simple sprite with a touch up action and use a similar structure?
It might be a problem in AI, but we would need an example that isolates the error and makes it repeatable so we can have a look.
If you have the same problem in a different (and smaller) project, it could indicate a problem in AI and not in your code. Does that make sense?
--
I think I found it.
My project contains an unused clock called 'begin'. If I remove that, the errors go away.
If you want to confirm, here is a smaller version of the game that shows the error one time, if you touchup the ufo.



--
Good to hear it's sorted!


--
I have a problem as well I don't know what the problem comes from but it is then i initialize the option menu.
this is one of my school projects and there is 3 red errors and 3 yellow errors that i don't know why they are there.
please answer quickly. A_A

--
Here is the problem.  You have to set initialize global sound to     a text       ....the other errors are similar.
When you get a red triangle error indicator, look for the blocks in your code that show a red triangle.  Left click the triangle and you will get a message that may help you.
Also, rather than send an aia file, it is usually better to post an image of the blocks causing the problem.
Looks like a nice game.     Have fun with it and let us know when you fix your blocks.    Have fun.
--
I have the same problem,and I don't know what the wrong with my program,why it always show runtime error?Maybe the setting of my clock has some problems?
Hope for answering

--
@ Yolan      You could temporarily disable the Clock1.Timer block.   Right mouse click anywhere on the Clock1.Timer, then select Disable Block. The entire block will turn gray; Now run the program and see if you get the error message.   If you still get the error when the clock is disabled, then the issue is probably within your Timer block.

When you finish the test,  right click on the Clock1.Timer block again.  This time select  Enable Block from the pop up.and it takes you  back where you started.

You may want to save an aia file before you do that.

If there is an error in the Timer, where is it?   I suspect the first block may be part of  the problem.  As coded, the first time the clock fires, time left is decreased by 1.  Where do you initially set the timeleft2.text block?    Is it hard coded, set in the Designer or where.   If the value is unset when the clock fires, the value will be   -1 and subsequently any negative number perhaps.  That might be what you want to do .. you get is a set of negative values that never stops resetting timeleft2.text .

What might be the problem is related to how you set the IF statement.  Where do you set the  global time to equal zero ?... to turn off the clock/  and how do you use the time.  At the moment, " i " is   either 1 to 9    .  If the value is 3 the else is executed.  Is that what you want?    or do you really mean  <= 3 in the first IF and >3 in the else if block? Would the way you set the equality cause the error?   I do not know, you have to run your app and test it and change the values.

--

댓글 없음:

댓글 쓰기