Android studio reports: java.lang.exceptionininitializererror error

1、 Problem description

Android studio reports a bunch of errors when importing a project:

Java.lang.exceptionininitializererror error is reported. The online parsing is:

When an exception occurs in the static initialization block, the JVM will throw a java.lang.exceptionininitializererror exception. If you know static variables in Java, you will know that they are initialized when the class is loaded. If an exception occurs during the initialization of this static variable, a java.lang.exceptionininitializererror exception will be thrown. This can be raised by any exception, such as java.lang.arrayindexoutofbound or java.lang.nullpointerexception. Java developers are usually confused by this error. They feel that they have not defined any static initialization block. Why do they throw an exception exceptionininitializererror; In fact, Java places the initialization of static variables in a default static initialization block by default, and then initializes them in the order they are declared in the source file.

2、 Solution

After searching for a long time, I didn't find any errors. Finally, I found the problem in the androidmanifest.xml manifest file:

He cited the maapp class here:

Maapp inherits the global application class, so an error will be reported if it is not referenced during initialization, but it is not referenced in my manifest file. Just add it:

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>