Android Studio Considerations for adding Third-party libraries _android

Source: Internet
Author: User

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.HttpRequestBaseThe 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.

Related Article

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.