The second secret of Android Development: importing existing projects and precautions

When I saw an example written by jsoup on the Internet, I downloaded it for research, but found that it would not be imported, so I Baidu and found the method: that is, click "file" - > "import" - > "general" - > "existing projects into workspace" in turn to find the project directory to be loaded.

Then, although the project was imported, it was found that the imported Java namespace could not be recognized, java.io and android.widget could not be recognized, so Google searched and found that it was not set properly. Here, you just need to right-click the project, select "properties", switch to "Java build path", switch to the "libraries" tab, then click "add liberty", add a "JRE system liberty", and then follow the above steps to select "Android classpath container", but you find that the following error occurs after adding it “unable to get system library for the project ”。

This problem occurs because the Android version is not selected. Switch to the Android node and select an Android version under project build target fieldset. Then test, everything is normal.

However, a new problem is that the project compilation is normal. Once it runs, an error will be reported. Normally, the procedure is normal and there is no error. The error text is: NoClassDefFoundError

I searched for this problem and found a solution:

Go to "Properties" of the project.
Select "Java Build Path"
Select "Order and Export" Tab
You should see the selected project's "src" and "gen" paths and dependencies here.
The order how they listed were first "src" and then "gen" path
I switch them, so that "gen" folder is build before the "src"
Click the project, then select "Clean", choose the project to clean it.
then It worked for me.

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
分享
二维码
< <上一篇
下一篇>>