Androidruntime: Java. Lang. noclassdeffounderror

Source: Internet
Author: User

Find several solutions to similar problems:

1. The error is that the class is not found, but the class does exist in the Code. The compilation is correct. This exception is reported during execution.

My colleague's machine is okay. I have a problem.

Think about the difference, that is, the. classpath file is inconsistent.

Later, go to project-properties-Java build path-order and export and try to adjust the order,

The problem was solved by putting the project name/GEN above the project name/src.

2. First declare that the project I run before the upgrade is ready to run.
I imported the project into eclipse and found that the error java. Lang. noclassdeffounderror could not be run, and androidmanifest. xml also registered the class.
Later I found that
After a long time
Android private libraries must be selected here. Note that you only need to select other ones that cannot be moved.
Okay. In this case, my problem can be solved.


3.

This problem occurs when Baidu locates the SDK: Java. Lang. noclassdeffounderror: COM. Baidu. Location. locationclient

Error process:

The project was originally developed under R12. Later, in order to catch up with the wind, I replaced R12 with r21.1. Then check out the code developed under R12 from SVN (this code runs under R12 completely without errors ). Once the code is run, java. Lang. noclassdeffounderror is reported.



The first message is that the listener of my inherited bdlocationlistener cannot be found, and the private class mybdlistener implements bdlocationlistener. I think it is a problem when packaging code, so I do not use inheritance directly in locationclient. registerlocationlistener (New bdlocationlistener () {}), and directly implement an internal class. In this case, the listener error is not found in the package. However, the following error occurs: Java. Lang. noclassdeffounderror:
Com. Baidu. Location. locationclient. After a brief analysis, I felt that this was not my own code problem. It was a third-party jar package problem. The first thought was: was it confused when it was obfuscated, then I cannot find this class? Therefore, add the following configuration in proguard. cfg:-keep class
Com. Baidu. Then run again and the same error is reported. After the obfuscation error is ruled out, I have never encountered such a problem. Now, Baidu has encountered this problem. The R16 he used, changing lib to libs is okay, but in my project, jar is clearly under the libs file! In addition, the Code can run normally in earlier versions, but it won't work in later versions. It is definitely not a code issue, but it must be an environment issue. Experience tells me this way. Since I think it is an environment problem, it must be a problem between the high and low versions, so I thought of the bin directory. After opening it, I found several hidden red ×. I did not think about it. I just deleted it. If you delete the file in eclipse, the file is deleted, but the file is not deleted. To completely delete eclipse, close eclipse, find the bin through the resource manager, delete it, and re-open eclipse. It should be correct after eclipse refresh and load and compile. But I still reported an error, so I cleaned the project, and then the red × disappeared. If it's gone, it means it's okay. Therefore, the project was re-run, and the error was lost. The main interface was successfully entered.


The solution is similar to the solution where the class in the third-party jar cannot be found:

1. If you are in R16 and your jar or lib file, you should first set lib Rename to libs, And then try the clear project.

2. If the program fails, you can try to remove the third-party obfuscation. Sometimes, the third-party classes cannot be found because the third-party code is obfuscated. Add the configuration in the proguard. cfg file, for example,-keep class com. Baidu .**{*;}

3. If you are switching from a lower version to a higher version, some incredible problems may occur, such as code running normally in a lower version, you can find out the reason from different versions. For example, delete the bin and ask him to generate it automatically. Then there is no problem.

4. If you find a class that is the same as the problem I encountered last time but cannot find a method in the class, consider whether it is a conflict issue, change the package name of your class. (This problem usually occurs in the jar generated by open-source code, which is not common ).


4. Now, this is my problem. I reported this error when importing sdkdemo for all:

My solution is to check the two jar packages !! I don't know when to add an android private libraries

With this, you do not need to add to build when adding a jar package ..


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.