eclipse => android studio
@[android][gradle]
Train of thought
1. Add gradle to the root directory of the project. 2
1 Initialize the gradle directory
- $CD PROJECT_ROOT $gradle init $git st?? .gradle/ ?? build.gradle ?? gradle/ ?? gradlew ?? gradlew.bat ?? settings.gradle
Properties file contains only one line and specifies the SDK path sdk.dir=...Copy the code
$ cat > local.properties
sdk.dir=/home/sctdroid/android_sdk/
^C
$ cat local.properties
sdk.dir=/home/sctdroid/android_sdk/
- the build configuration. GradleCopy the code
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { Dependencies repositories {jcenter ()} {the classpath ‘com. Android. View the build: gradle: 1.2.3’}}
allprojects {
repositories {
jcenter()
}
}
#### 2 Add a Module- Create new Module folder - Add build.gradle for moduleCopy the code
$ mkdir calculator
$ cd calculator
$ touch build.gradle
- Write configuration information in build.gradle ** minimum version required for successful compilation **Copy the code
// PROJECT_ROOT/build.gradle
Apply plugin: ‘com.android.application’ // Imports predefined Android tasks
Android {compileSdkVersion 21 buildToolsVersion “23.0.2”
defaultConfig {
applicationId "com.sctdroid.calculator"/ / package name}sourceSets {// ** key ** respecify the location of the object file. If not specified, Gradle uses the default directory structure to compile. Main {manifest.srcfile'.. /AndroidManifest.xml'
java.srcDirs = ['.. /src']
resources.srcDirs = java.srcDirs
aidl.srcDirs = java.srcDirs
renderscript.srcDirs = java.srcDirs
res.srcDirs = ['.. /res']
assets.srcDirs = ['.. /assets']
jniLibs.srcDirs = ['.. /jniLibs']
}
androidTest.setRoot('tests')
}
lintOptions {
abortOnError false
}Copy the code
}
** Take calculators **Copy the code
// PROJECT_ROOT/calculator/build.gradle
Apply plugin: ‘com.android.application’ // Imports predefined Android tasks
Android {compileSdkVersion 21 buildToolsVersion “23.0.2”
defaultConfig {
applicationId "com.sctdroid.calculator"MinSdkVersion 14 targetSdkVersion 17} signingConfigs {// add signature file custom {storeFile file file(".. /app.keystore")
storePassword "storepassword"
keyAlias "app"
keyPassword "keypassword"} buildTypes {release {minifyEnabled} buildTypes {release {minifyEnabledfalse
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'}}sourceSets {// ** key ** respecify the location of the object file. If not specified, Gradle uses the default directory structure to compile. Main {manifest.srcfile'.. /AndroidManifest.xml'
java.srcDirs = ['.. /src']
resources.srcDirs = java.srcDirs
aidl.srcDirs = java.srcDirs
renderscript.srcDirs = java.srcDirs
res.srcDirs = ['.. /res']
assets.srcDirs = ['.. /assets']
jniLibs.srcDirs = ['.. /jniLibs']
}
androidTest.setRoot('tests')
}
lintOptions {
abortOnError false
}Copy the code
}
dependencies { compile files(‘.. /libs/libGoogleAnalyticsV2.jar’) }
- modify the setting. GradleCopy the code
Add the include ‘: the calculator’
#### 3. Don't forget **. Gitignore **Copy the code
.gitignore
.gradle
build
/local.properties
### Possible problems
- lintCopy the code
-
What went wrong:
Execution failed for task ‘:calculator:lint’.Lint found errors in the project; aborting build.
Fix the issues identified by lint, or add the following to your build script to proceed with errors:
…
android {lintOptions { abortOnError false }Copy the code
}…
` ` `