Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJavier Pacheco
3,963 PointsApp crashes because of OkHttp error
When I launch the app on my phone it opens and immediately crashes. Console says:
06-03 09:48:59.807 29573-29594/com.example.javierpacheco.stormy E/AndroidRuntime﹕ FATAL EXCEPTION: OkHttp Dispatcher Process: com.example.javierpacheco.stormy, PID: 29573 java.lang.IllegalArgumentException: Unknown pattern character 'n' at java.text.SimpleDateFormat.validatePatternCharacter(SimpleDateFormat.java:314) at java.text.SimpleDateFormat.validatePattern(SimpleDateFormat.java:296) at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:356) at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:249) at com.example.javierpacheco.stormy.CurrentWeather.getFormattedTime(CurrentWeather.java:87) at com.example.javierpacheco.stormy.MainActivity.getCurrentDetails(MainActivity.java:98) at com.example.javierpacheco.stormy.MainActivity.access$100(MainActivity.java:25) at com.example.javierpacheco.stormy.MainActivity$1.onResponse(MainActivity.java:61) at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:168) at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818)
Javier Pacheco
3,963 PointsJavier Pacheco
3,963 PointsI just solved it. Seems like I put SimpleDateFormat("h:mn a"); while creating a new SimpleDateFormat object and apparently the "n" from the minutes must be removed; so it has to look like SimpleDateFormat("h:m a");