[SOLVED] A crash for Android: "java.util.MissingFormatArgumentException: Format specifier: s"

I have been getting crash report from Android users a few times this week:

java.util.MissingFormatArgumentException: Format specifier: s at java.util.Formatter.getArgument(Formatter.java:1111) at java.util.Formatter.doFormat(Formatter.java:1076) at java.util.Formatter.format(Formatter.java:1042) at java.util.Formatter.format(Formatter.java:1011) at java.lang.String.format(String.java:1988) at java.lang.String.format(String.java:1962) at network.NetworkRequest.error(NetworkRequest.java:64) at network.NetworkRequest$AsyncNetworkRequestRunnable.run(NetworkRequest.java:1775) at java.lang.Thread.run(Thread.java:849)

It seems a very basic crash in network request. How to find out where it is? I have over 40k iOS downloads, but I have never got any complaint about app crash though.

Do you have an android device to test on?  Can you add some print statements to try and narrow down where it’s happening?

I do have an Android to test on. But I don’t see any crash at all.

The crash log I showed above is from Google Play Crash Report website.

I don’t know how to reproduce this bug. That’s why I asked if it’s possible to derive where it might happen from the Crash Report. 

It must happen in a very rare condition.

I am still getting this same crash reports from Google Play Developer Console. 8 times this week.

Is it ever possible a bug in Corona SDK?

Or it must be somewhere in my code?

Please help Corona developers if you have some insight to share from the stack trace. Thanks a lot.

It’s happening in network function.  Are you calling network.request() anywhere? 

Yes, many places.

But I cannot reproduce this crash. I also tried to stop network interface to simulate network errors but no crash either. So I hope if you can give more insights from the call stack trace.

The rest of the stack is coming from inside of a network request.  It’s trying to format a string and is missing a parameter.  So likely you are calling network.request() and passing a nil in somewhere.  It could be for the URL, the request type (POST, GET, etc) or it come be in a parameter table somewhere.  Unfortunately there really isn’t much more can be determined.  It is a string that is nil.

Rob

I tried this

(1) network.request( nil, nil, nil, nil, nil)

It does not crash, but reporting the first parameter is nil

(2) network.request( valid_url, nil, nil, nil, nil)

It does not crash either

I think it’s not just about passing nil to network.request()… see the third line from the bottom in the stack trace:

network.NetworkRequest.error(NetworkRequest.java:64)

The crash happens somewhere else in error handling and is it possibly Corona’s code?

I really hope Corona can help on this issue, I keep getting Android reports about this crash.

Can any Android engineer check the related code in handling network error, a simply typo like this

System.out.printf(“The error: $%s\n” + errorString)

 

can generate a similar error. 

Even if I passes a nil parameter, I think Corona should be more fault-tolerant. It shouldn’t let it crash in such a “tolerable” case.

Do you have an android device to test on?  Can you add some print statements to try and narrow down where it’s happening?

I do have an Android to test on. But I don’t see any crash at all.

The crash log I showed above is from Google Play Crash Report website.

I don’t know how to reproduce this bug. That’s why I asked if it’s possible to derive where it might happen from the Crash Report. 

It must happen in a very rare condition.

We have the same issue!

In my case this problem only occurs on Galaxy Nexus.

Other android devices run without problem.

And this issue occurs at calling the following API

network.request(url, “POST”, callback, param)

All 4 parameters were not nil.

I’m using CoronaAPI Version 2013.1202.

Phone OS :  Android 4.2.1

The following is the error message when my game crashes.

12-06 17:21:30.864: E/AndroidRuntime(2946): FATAL EXCEPTION: Thread-227

12-06 17:21:30.864: E/AndroidRuntime(2946): java.util.MissingFormatArgumentException: Format specifier: 201.8:

12-06 17:21:30.864: E/AndroidRuntime(2946):     at java.util.Formatter.getArgument(Formatter.java:1109)

12-06 17:21:30.864: E/AndroidRuntime(2946):     at java.util.Formatter.doFormat(Formatter.java:1074)

12-06 17:21:30.864: E/AndroidRuntime(2946):     at java.util.Formatter.format(Formatter.java:1040)

12-06 17:21:30.864: E/AndroidRuntime(2946):     at java.util.Formatter.format(Formatter.java:1009)

12-06 17:21:30.864: E/AndroidRuntime(2946):     at java.lang.String.format(String.java:1988)

12-06 17:21:30.864: E/AndroidRuntime(2946):     at java.lang.String.format(String.java:1962)

12-06 17:21:30.864: E/AndroidRuntime(2946):     at network.NetworkRequest.error(NetworkRequest.java:64)

12-06 17:21:30.864: E/AndroidRuntime(2946):     at network.NetworkRequest$AsyncNetworkRequestRunnable.run(NetworkRequest.java:1775)

12-06 17:21:30.864: E/AndroidRuntime(2946):     at java.lang.Thread.run(Thread.java:856)

@iamarej

Are you able to reproduce it? What kind of operations would cause your game crash? 

@jeo528

Yes! Every time I run my game on Galaxy Nexus (Android 4.2.1).

But Other Android devices and iPhone have no problem running my game.

When my game start, it is trying to connect to my game server with " network.request" API  to send some json text!

And every time this issue occurs only on Galaxy Nexus (Android 4.2.1).

@Corona

Take a look at the similarity of the crash call stacks reported by me & iamarej, I think it’s a Corona crash and should be fixed as soon as possible.

Although it does not happen often (as long as the user has a good network connection), it does happen now and then when there is an unstable network environment. It seems a network error not easy to be simulated but it does happen.

Corona engineer who is responsible for Java network handling should review the code to see if there is a missing parameter when formatting a string in network error handling.

I am still getting this same crash reports from Google Play Developer Console. 8 times this week.

Is it ever possible a bug in Corona SDK?

Or it must be somewhere in my code?

Please help Corona developers if you have some insight to share from the stack trace. Thanks a lot.

It’s happening in network function.  Are you calling network.request() anywhere? 

Yes, many places.

But I cannot reproduce this crash. I also tried to stop network interface to simulate network errors but no crash either. So I hope if you can give more insights from the call stack trace.

The rest of the stack is coming from inside of a network request.  It’s trying to format a string and is missing a parameter.  So likely you are calling network.request() and passing a nil in somewhere.  It could be for the URL, the request type (POST, GET, etc) or it come be in a parameter table somewhere.  Unfortunately there really isn’t much more can be determined.  It is a string that is nil.

Rob

I tried this

(1) network.request( nil, nil, nil, nil, nil)

It does not crash, but reporting the first parameter is nil

(2) network.request( valid_url, nil, nil, nil, nil)

It does not crash either

I think it’s not just about passing nil to network.request()… see the third line from the bottom in the stack trace:

network.NetworkRequest.error(NetworkRequest.java:64)

The crash happens somewhere else in error handling and is it possibly Corona’s code?