直接在eclipse项目中建立一个文件,文件名为build.gradle。其实还可以用eclipse再项目上面右击,export->Android->Generate Gradle build files,既可以生成文件
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.10.+' } } repositories { mavenCentral() } apply plugin: 'android' android { compileSdkVersion 18 buildToolsVersion "19.0.1" defaultConfig { minSdkVersion 8 targetSdkVersion 19 versionCode 83 versionName "2.1.5 beta" } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] jniLibs.srcDirs = ['libs'] //用于copy so 文件 } } packagingOptions { exclude 'META-INF/notice.txt' exclude 'META-INF/license.txt' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/ASL2.0' } lintOptions { abortOnError false } signingConfigs { key { storeFile file("MYB.keystore"); storePassword "你大爷永远是你大爷" keyAlias "etmobile" keyPassword "你大妈有可能就成别人的大妈了" } } buildTypes { release { runProguard true signingConfig signingConfigs.key proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) }