参考:http://www.cnblogs.com/softidea/p/5631341.html
将Eclipse中的pom.xml中的配置内容转换到build.gradle文件中。
方法:
下载gradle 2.0并安装,配置环境变量(类似JDK环境变量的配置)
然后在maven根目录下运行
gradle init --type pom
打开生成的build.gradle文件,查看里面的dependencies内容,已经转换成Android Studio可用的依赖配置。可以直接复制需要的部分到Android Studio中的build.gradle文件中。
以下是转换后整理修改好的build.gradle代码:(sync之后就会自动下载依赖的jar包)
apply plugin: 'java'
apply plugin: 'eclipse'
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
test {
useTestNG()
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile group: 'commons-configuration', name: 'commons-configuration', version:'1.9'
compile(group: 'io.appium', name: 'java-client', version:'3.4.1') {
exclude(module: 'selenium-java')
}
compile group: 'com.google.code.gson', name: 'gson', version:'2.2.4'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version:'2.53.0'
compile group: 'org.apache.poi', name: 'poi-ooxml', version:'3.10-FINAL'
compile group: 'org.seleniumhq.selenium', name: 'selenium-remote-driver', version:'2.53.0'
compile group: 'com.thoughtworks.qdox', name: 'qdox', version:'1.12.1'
testCompile group: 'org.testng', name: 'testng', version:'6.9.6'
testCompile group: 'com.googlecode.json-simple', name: 'json-simple', version:'1.1'
testCompile group: 'commons-lang', name: 'commons-lang', version:'2.6'
testCompile group: 'com.saucelabs', name: 'sauce_junit', version:'2.1.21'
compile(group: 'net.sourceforge.jexcelapi', name: 'jxl', version:'2.6.12') {
/* This dependency was originally in the Maven provided scope, but the project was not of type war.
This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency.
Please review and delete this closure when resolved. */
}
compile(group: 'log4j', name: 'log4j', version:'1.2.16') {
/* This dependency was originally in the Maven provided scope, but the project was not of type war.
This behavior is not yet supported by Gradle, so this dependency has been converted to a compile dependency.
Please review and delete this closure when resolved. */
}
}
解决方法:
修改File--setting中的默认编码为UTF-8,Apply后重启Android Studio,并且在gradle配置文件中添加如下内容。亲测有效:
参考:https://www.douban.com/note/507175402/