How do I add a library to use an Android studio?
android actionbarsherlock android-library android-studio
It's a method of adding a gradle file If you look at build.gradle in the app directory
dependencies {
compile 'com.jakewharton:butterknife:6.0.0'
}
It looks like this. I'm going to add it here For example, if you look at a project called HelloWorld in the project directory,
HelloWorld/
app/
- - build.gradle // local gradle config (for app only)
...
- - build.gradle // global gradle config (for whole project)
- - settings.gradle
- - gradle.properties
...
It should be organized like this, so please create a libs folder here, and I'll add the PagerSlidingTabStrip library. library Go download here.
HelloWorld/
app/
- - build.gradle // local gradle config (for app only)
...
libs/
PagerSlidingTabStrip/
- - build.gradle // local gradle config (for library only)
- - build.gradle // global gradle config (for whole project)
- - settings.gradle
- - gradle.properties
...
If you add it, it should look like this. And then go into settings.gradle.
include ':app', ':PagerSlidingTabStrip'
project(':PagerSlidingTabStrip').projectDir = new File('libs/PagerSlidingTabStrip')
If you do this and get a "Default Configuration" error, don't do that.
include ':app'
include ':libs:PagerSlidingTabStrip'
Try changing it like this. If you don't have a "Default Configuration" error, go to the app/build.gradle you saw at first.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(":PagerSlidingTabStrip")
}
If you have a "Default Configuration" error,
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(":libs:PagerSlidingTabStrip")
}
Do it like this. If you don't have build.gradle in the library folder, make it yourself
apply plugin: 'com.android.library'
dependencies {
compile 'com.android.support:support-v4:21.0.3'
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
You can do it. Next, I'll go to gradle.properties
ANDROID_BUILD_MIN_SDK_VERSION=14
ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_TOOLS_VERSION=21.1.3
ANDROID_BUILD_SDK_VERSION=21
Please add it and go to the build.gradle file.
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
}
Please. And
© 2024 OneMinuteCode. All rights reserved.