版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/chaoyu168/article/details/77842358
下载网址:https://github.com/wyouflf/xUtils3
第一步:新建一个自己的工程;
第二步:点File->New->Import Module,选择自己下载好的xutils3,目录为:D:\adtext\xUtils3-master\sample
第三步:修改库xutils的build.gradle,屏蔽无用代码,将versionName的值改为版本号,修改;
apply plugin: 'com.android.library'
//apply plugin: 'com.github.dcendents.android-maven'
//apply plugin: 'com.jfrog.bintray'
//
//def siteUrl = 'https://github.com/wyouflf/xUtils3'
//def gitUrl = 'https://github.com/wyouflf/xUtils3.git'
//group = "org.xutils"
//version = "3.5.0"
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
versionCode 20170405
versionName "3.5.0"
}
buildTypes {
debug {
minifyEnabled false
debuggable true
}
release {
minifyEnabled false
debuggable true
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
java.srcDirs = ['src/main/java']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
}
//install {
// repositories.mavenInstaller {
// // This generates POM.xml with proper parameters
// pom {
// project {
// packaging 'aar'
// name 'xUtils'
// description 'android orm, bitmap, http, view inject... '
// // #CONFIG# // project title
// url siteUrl
// // Set your license
// licenses {
// license {
// name 'The Apache Software License, Version 2.0'
// url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
// }
// }
// developers {
// developer {
// id 'wyouflf'
// // #CONFIG# // your user id (you can write your nickname)
// name 'lei.jiao'
// // #CONFIG# // your user name
// email 'wyouflf@qq.com'
// // #CONFIG# // your email
// }
// }
// scm {
// connection gitUrl
// developerConnection gitUrl
// url siteUrl
// }
// }
// }
// }
//}
//task sourcesJar(type: Jar) {
// from android.sourceSets.main.java.srcDirs
// classifier = 'sources'
//}
//task javadoc(type: Javadoc) {
// options.encoding = "UTF-8"
// source = android.sourceSets.main.java.srcDirs
// classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
//}
//task javadocJar(type: Jar, dependsOn: javadoc) {
// classifier = 'javadoc'
// from javadoc.destinationDir
//}
//artifacts {
// archives javadocJar
// archives sourcesJar
//}
//Properties properties = new Properties()
//properties.load(project.rootProject.file('local.properties').newDataInputStream())
//bintray {
// user = properties.getProperty("bintray.user")
// key = properties.getProperty("bintray.apikey")
// configurations = ['archives']
// pkg {
// repo = "maven"
// name = "xUtils"
// // #CONFIG# project name in jcenter
// websiteUrl = siteUrl
// vcsUrl = gitUrl
// licenses = ["Apache-2.0"]
// publish = true
// }
//}
第四步:修改xutils_sample的
build.gradle,修改红色字体的版本号,要与自己app的build.gradle版本号一致;
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "org.xutils.sample"
minSdkVersion 14
targetSdkVersion 22 // 不使用api23的动态权限策略
versionCode 1
versionName "1.0"
}
signingConfigs {
debugConfig {
storeFile file("debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes {
release {
debuggable false
minifyEnabled true
signingConfig signingConfigs.debugConfig
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile project(':xutils')
}
第五步:将xutils库作为工程添加到自己app的build.gradle中,在File->Project Structure中选择APP,然后library中添加
初始化时导入:
import org.xutils.x;