AlphaVladim AlphaVladim - 2 months ago 8
Android Question

VerifyError when reading ini

I am using ini4j as i prefer windoze's inis.
This part makes sure the file exists:

File INI_FILE = new File(getActivity().getFilesDir().getAbsolutePath()+File.separator+"config.ini");
final String INI = getActivity().getFilesDir().getAbsolutePath()+File.separator+"config.ini";

if(!GetProp.Supports(INI_FILE)){

File INI_F = new File(getActivity().getFilesDir().getAbsolutePath()+File.separator+"config.ini");
if (!INI_F.exists()) {
try {
INI_F.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
Wini ini = null;
try {
ini = new Wini(new File(INI));
} catch (InvalidFileFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

ini.put("Throttle", "refresh_interval", 1000);
ini.put("Throttle", "active", false);
ini.put("Throttle", "temp_limit", 80);

try {
ini.store();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}


This is how i am trying to read it: (THIS CODE IS UNDER A onClick() )

Wini ini = null;
try {
ini = new Wini(new File(INI));
} catch (InvalidFileFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

int refresh_interval = ini.get("Throttle", "refresh_interval", int.class); // ERROR HERE
boolean active = ini.get("Throttle", "active", boolean.class);
int max_temp = ini.get("Throttle", "temp_limit", int.class);


I am getting the following error:

E/AndroidRuntime(12340): FATAL EXCEPTION: main
E/AndroidRuntime(12340): java.lang.VerifyError: org/ini4j/spi/BeanTool
E/AndroidRuntime(12340): at org.ini4j.BasicOptionMap.get(BasicOptionMap.java:161)
E/AndroidRuntime(12340): at org.ini4j.BasicProfile.get(BasicProfile.java:129)
E/AndroidRuntime(12340): at com.costinutz32.hox_control.fragments.CPU$6.onClick(CPU.java:622)
E/AndroidRuntime(12340): at android.view.View.performClick(View.java)
E/AndroidRuntime(12340): at android.view.View$PerformClick.run(View.java)
E/AndroidRuntime(12340): at android.os.Handler.handleCallback(Handler.java)
E/AndroidRuntime(12340): at android.os.Handler.dispatchMessage(Handler.java)
E/AndroidRuntime(12340): at android.os.Looper.loop(Looper.java)
E/AndroidRuntime(12340): at android.app.ActivityThread.main(ActivityThread.java)
E/AndroidRuntime(12340): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(12340): at java.lang.reflect.Method.invoke(Method.java)
E/AndroidRuntime(12340): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
E/AndroidRuntime(12340): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
E/AndroidRuntime(12340): at dalvik.system.NativeStart.main(Native Method)


I have searched all across the internet for a fix, tried reimporting jars, fixing buildpaths, cleaning projects and everything i could find. Nothing helped.

If there is something i forgot to mention, let me know so i can add it.
If needed, i can add screenshots of my project's settings.

Thank you!

Edit: Here is a screen with complete logs:
http://img823.imageshack.us/img823/7144/54gx.png

Answer

The library you're trying to use seems to rely heavily on java.beans reflection. However, on Android only parts of java.beans package are available.

The VerifyErrors are due to missing classes, fields and methods at class loading time.

Either port the library to Android yourself, or ditch it in favor of mechanisms and libraries that are readily available on Android.