12 practical Android skills: How to import a third-party class library to Android Studio
When a netizen's XMPP code is transferred from ADT to AS, it finds that it uses a third-party class library, the source code is placed under lib, and the project is directly imported in, third-party class libraries are not automatically imported in. It seems that you need to do it yourself.
The directory structure of the project is as follows:
XMPP$ lsapp build.gradle gradlew import-summary.txt XMPP.imlbuild gradle gradlew.bat local.properties settings.gradle
Copy the third-party source code qqEmoji-lib to this directory and modify settings. gradle to add this lib:
include ':app',':qqEmoji-lib'
Modify build. gradle in the app and add it to dependencies:
dependencies { compile project(':qqEmoji-lib') ...
Create the build. gradle file under qqEmoji-lib. For details, refer to the following:
apply plugin: 'android-library'android { compileSdkVersion 19 buildToolsVersion "21.1.2" defaultConfig { minSdkVersion 8 targetSdkVersion 18 } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] } }}dependencies { compile 'com.android.support:appcompat-v7:19.1.0' //compile 'com.android.support:support-v4:19.1.0'}
For configuration content of gradle, see the second link.
The project structure is as follows:
At this time, the compilation is successful. The import is successful!
Refer:
Http://www.cnblogs.com/neozhu/p/3458759.html
Http://www.open-open.com/lib/view/open1415793464648.html