java - 读取 ini 时出现 VerifyError

标签 java android verifyerror ini4j

我正在使用 ini4j,因为我更喜欢 windoze 的 inis。 这部分确保文件存在:

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();
        }

        }      
    }

这就是我试图阅读它的方式:(此代码位于 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);

我收到以下错误:

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)

我在整个互联网上搜索了修复程序,尝试重新导入 jar、修复构建路径、清理项目以及我能找到的一切。没有任何帮助。

如果有什么我忘了说的,请告诉我,我可以补充。 如果需要,我可以添加项目设置的屏幕截图。

谢谢!

编辑:这是一个包含完整日志的屏幕: http://img823.imageshack.us/img823/7144/54gx.png

最佳答案

我在一个 Android 项目中遇到了同样的问题,我发现自己删除 int.class 并将 String 转换为 Integer 似乎可行。

改变

int refresh_interval = ini.get("Throttle", "refresh_interval", int.class);

int refresh_interval = Integer.parseInt(ini.get("Throttle", "refresh_interval"));

它应该可以工作。

关于java - 读取 ini 时出现 VerifyError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20792637/

相关文章:

java - android 未知的空指针错误

java - Android - 可绘制路径

Java android BaseAdapter - 如何在适配器的特定位置的 TextView 中设置文本?

java - 检测 Flappy Bird 克隆中特定区域的触摸

android - 将纯文本发送到 Android 中的 USB 打印机

android - 用于计算位置的 Gps 和网络状态在建筑物内不准确

java - 对于在 onCreate() 中创建的类,卡在 Java.lang.VerifyError

android - 2 服务通讯

带有 ASM : VerifyError on code injection at INVOKESPECIAL instructions 的 Java 字节码检测

导入的 jar 上的 java.lang.VerifyError