Recently I discovered a problem. Sometimes I repeatedly add jar and remove jar to an Android project, and find that the compilation can pass, but when it is applied to the object of an external jar, a java.lang.NoClassDefFoundError exception will be thrown during operation. Cause the program to crash.
Check the project properties and find that the Android Dependencies item in the java build path is less than the normal project:
By comparing with the project before the loss, we found that the difference lies in the .classpath file in the project root directory, <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/ >The exported here became false, so I changed it back to true, then closed and opened the project again, and found that it was ok.
In addition, if the jar package you imported is not placed in the /libs directory of the project directory, this problem will also occur. Please place the jar package in the /libs directory. Otherwise, although the compilation can pass, the jar will not be packaged when packaging. Go in, so it causes the exception above. Eclipse will automatically package the files in the /libs directory when compiling.
This problem has not appeared before. I don't know if it is related to the Eclipse version and ADT version.