java.lang.ExceptionInInitializerError in Android

前端 未结 5 908

I\'m trying to create an Android Application that can verify a face But when I try to run my app on my emulator (using Eclipse), I have this result in my logcat:



        
相关标签:
5条回答
  • 2021-01-18 04:12

    If I'm reading this right it can't find a library for Java Native Access Platform

    in Eclipse in your project properties check the libraries for JNA Platform

    java.lang.ClassNotFoundException: com.sun.jna.Platform

    It's been a few years since I have used eclipse.

    0 讨论(0)
  • 2021-01-18 04:20

    Here are answers, so you know how to solve it now. But this is for others. Java have a great exception message handling where you are able to find almost everything what you need to fix it. This is only my opinion and advice: Everytime look at CAUSED BY: part.

    When you have exception, look at last caused by message. For example here is it: Caused by: java.lang.NoClassDefFoundError: com.sun.jna.Platform. Java have a lot of error classes. This one is error from Object->Throwable->Error->LinkageError. Error => Problem during runtime, No class Def Found Error is typical problem for classloader. All what you can need to explaining error is in java docs.


    Btw from your quetions in comments, here is solution to add external library.

    HOW TO ADD LIBRARY TO PROJECT IN ECLIPSE: Download jar which is decsribed by others here (jna.jar) and add it to lib folder and then you have to add it to build path (then classloader will be able to find it and it will solve your problem). If you are using Eclipse, you can import them directly via Eclipse to your lib folder (right click on project folder, select buildpath, libraries tab and add jar) or just copy jar directly to lib folder, then rightclick and Build Path -> Add to Buildpath.

    0 讨论(0)
  • 2021-01-18 04:20

    You might need to add more dependencies which can be here https://github.com/java-native-access/jna/tree/master/lib if I have the correct library.

    To do so, you right click on your project in eclipse and then go to Properties(should be bottom option).

    There are some options on the left, choose "Java Build Path". Here is where you can add "Add Jars" or "Add External Jars". If you choose Add External Jar you can install from anywhere, if you choose Add Jars you can install within the folder project. I would add a jar folder inside project folder and put all jar dependencies there otherwise if you move jars to another folder you need to do this again.

    Add all the jars from the link and sub-links that are there. See if that fixes the issue. Eclipse will tell you if you are missing dependencies for your classes but it won't tell you if dependencies are missing dependencies until you run your code.

    0 讨论(0)
  • 2021-01-18 04:22

    As already pointed out by others you have a missing dependency to a project called Java Native Access (JNA). If you look carefully at your StackTrace you see at the end this Exception: java.lang.NoClassDefFoundError: com.sun.jna.Platform. A short Google search ended in the repository above.

    I would try to download all related jars which have the Android prefix. You might also need just android-arm.jar however this would break it on devices with another processor, so add them all.

    0 讨论(0)
  • 2021-01-18 04:34

    Hi my problems has solved . I have to add jna-4.2.2.jar into my projects . I have got errors about native libraries in jna.jar . So in this case , in Eclipse , I have to go to Preferences > Android > Build > uncheck "Force error when external jars contain native libraries". Then my problem is solved .

    0 讨论(0)
提交回复
热议问题