简体   繁体   中英

Activity is crashing due to NumberFormatException when trying to use OpenGL

I'm learning some basic OpenGL programming but I can't run the application because it crashes every time I run it with the following error:

01-21 16:22:04.245: E/AndroidRuntime(30137): java.lang.RuntimeException: Unable to start activity component: java.lang.NumberFormatException: Invalid int: "4.0.4"

The Samsung Galaxy SII that I'm runnning it on has android 4.0.4 installed on it and I'm wondering if that's the problem because most of the OpenGL tests I'm trying to run seem to be crashing with a similar error.

Any ideas what's happening?

Wrap your code in

try {
    /// Your code
} catch(NumberFormatException nfe) {
   Log.e("MyApp", nfe.getMessage(), nfe);
}

This will allow you to isolate where the exception is coming from.

4.0.4 is indeed a non-parsable number. You can substring it and compare the numbers that way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM