Objective
A lot of people started learning about Android and would choose Google's official Android studio as a development tool, and because he was not quite the same as the previous eclipse, there were more problems. This is mainly the problem of importing and the problems posed by Android Studio's version of the Android SDK.
First of all, the introduction of Third-party libraries into the Android studio method, take Xutils as an example, the way to import a jar package, simpler, again do not introduce. We are mainly talking about the way library files are introduced.
The first step we have to do is to introduce the package, placed in our engineering directory, the following figure
And then we can see the third party library in our engineering directory.
But this is not enough, we also need in the Engineering app directory (engineering root directory has a, engineering app directory also has a, here we configure the app directory under the Build.gradle) under the configuration of some things
Here we are to get our engineering team this third library to rely on
Also, add the Xutils settings to the setting file in the engineering root directory
Then we need to set up the Build.gradle file under the third Party library
The main setting is the three places labeled above to make sure that he is consistent with the environment you are using.
The General Third-party Library settings are over here.
However, the Xutils framework was removed from the Android6.0 version of the Appache HTTP client after the previous Android 6.0. If your app's target version is Android2.3 (API level 9) or higher, use the HttpURLConnection class to replace it, so there's a problem
Error: (20, 32) Wrong: Package Org.apache.http.protocol does not exist
At this point, our solution is to add the use of the Legacy library under the Build.gradle directory of the Xutils framework.
As follows
Adding this step to other data on the web is often a functional solution, but in the course of my actual operation I found that there were other errors.
Error:(39, 32) 错误: 无法访问HttpRequestBase
org.apache.http.client.methods.HttpRequestBase
The class file that cannot be found
The Final Solution is
Add the use of this library to the Build.gradle in the Engineering app directory
At this point, the program can finally compile successfully.
The above is the entire content of this article, I hope that the study or work to bring some help, if you have questions you can message exchange.