Just came to a company, found that Android development is still using eclipse, coding no specifications, channel packaging is manual, SVN version of the Trunk branch management confusion, in short, all kinds of low ...
For me with obsessive-compulsive disorder, the truth is not tolerated. But helpless, new one, there is no voice right.
After several months of training and witness, the actual combat finally can be vigorous and resolute to the most elite things show (plainly like the pursuit of Virgo perfect).
The above describes the Android development specifications, of course, this is reproduced others, covering the scope is relatively wide.
There are also eclipse packaging multi-channel package, this is reproduced others, the explanation is very detailed, of course, this is related to my local Eclipse version and environment, so gradle version and grammar are inconsistent, but the key is to read the wrong information, specific problems specific analysis, Do not understand through the Baidu can always solve. Once again eclipse packaged multi-channel package (library engineering version), this is on the basis of the previous article, all are their own crawl pits, mainly gradle configuration.
SVN version of the backbone branch management has a dedicated personnel responsible for the main idea is: to ensure that the baseline code is not changed (trunk), each version of the Code (branch), the version of the iteration completed, into the trunk (this is the case), in fact, I think it should be the baseline code also to distinguish between version preservation, This can be traced to the historical version code (which is really critical), that is, the baseline does not merge (this is what the home Company does).
Android Studio (AS) comes out with a lot of bugs, but it's a hate-friendly IDE compared to eclipse. Now I am using the as version is 2.3.2, because the Gradle version is also 2.3.2, then the Eclipse project turns into an as project, the pit is much more.
1. I started to generate the Gradle file in the way that eclipse was exported, and then import it through as. This method has a lot of errors, mainly when the Eclipse export Gradle version is generated according to the eclipse version, and as the environment will conflict, the error is unavoidable, and the project's file structure and eclipse almost, looks very uncomfortable, Compare as is a display mode switch with Project, packages, Android, and so on. So this way, reject.
2. I am rather stupid, open as, create an as project, package name, project name and Eclipse Project package name, project name consistent;
3. Copy the files associated with the Eclipse project and replace the files under the as project, typically with the copy of SRC, res, libs, androidmanifest, etc.;
4. This time the project must have an error. The library project is replaced by compile in the Build.gradle (app directory), if not found, then put the library project jar into the Libs, RES required all copies to the corresponding location. Note: The required resources cannot be duplicated (jar, XML, etc.).
5. Now is the time to configure the file:
1) settings.gradle content includes ': App ' (meaning to include the module, if there are other module, plus go);
2) LOCAL.PROPERTIES:SDK.DIR=E\:\\SDK (Declaration of the SDK Path);
3) Gradle.properties: (The default is org.gradle.jvmargs=-xmx2048m, the following is my reference to write online, to speed up the compilation of packaging speed)
org.gradle.daemon=true
org.gradle.jvmargs=-xmx2048m-xx:maxpermsize=512m-xx:+heapdumponoutofmemoryerror-dfile.encoding=utf-8
org.gradle.parallel=true
org.gradle.configureondemand=true
4) Build.gradle: Default generation, no modification required.
5) App/libs, put a copy of the jar package, note: Do not copy the. So file, the following is said. so file storage;
6) App/src/build.gradle: Key document, the first sentence of apply plugin: ' Com.android.application ', contains the relevant configuration SDK version, resource file, signature information, obfuscation information, build package modification
Channel information, compilation dependencies, etc. I will post the entire document at the end of the article;
7) App/src under the Androidtest and Test folder under the Java file Delete, if you need to do unit testing, you must keep (unit test does not expand);
8) The App/main folder contains the Assets folder (Eclipse copy over), the Java folder (core Java code), the Res folder (Eclipse copy), Androidmanifest and Jnilibs (created by yourself,
store. so files);
9) Proguard-rules.pro: Code to confuse the file, note: If there is a third-party jar package declaration, it must be deleted, because the gradle added dependencies have been declared.
In this case, choose Build,clean Project, this times wrong, the problem should be in the app/src/build.gradle, if it is another problem, check again from the beginning. And for the problems that arise in app/src/build.gradle, we should
Combine log, message output to do the modification, because different version of the Gradle syntax changes, because according to the error message can solve all the error, believe me, because the whole process of the first project I spent 2 days, the second project, I only spent half an hour.
App/src/build.gradle File Full Contents
Apply plugin: ' Com.android.application '
Android {
//Compile SDK
compilesdkversion
buildtoolsversion "25.0.2"
Defaultconfig {
multidexenabled True//Allow multiple Dex files
ApplicationID "com.xxx"//package name as ID
minsdkversion 14//Minimum version SDK
targetsdkversion 23//Maximum version SDK
Versioncode 1//Version code
versionname "1.0.0"//Version number
}
//Perform lint check, there are any errors or warning prompts, will terminate the build, we can turn it off.
lintoptions {
Abortonerror false//When there is an error, still continue to execute
disable "resourcetype"//Ignore resource type warning on code
}
compileoptions {
sourcecompatibility javaversion.version_1_7
targetcompatibility javaversion.version_1_7
}
Signingconfigs {
Debug {
}
Release {
//Fill in your KeyStore path and password (configure signature)
storefile file ("E:\\xxx.keystore")
Storepassword "12345678"
Keyalias "Android"
Keypassword "12345678"
}
}
Buildtypes {
Debug {
minifyenabled false
//zipalign Optimization
zipalignenabled True
//Remove useless resource files
shrinkresources false
}
Release {
minifyenabled True
//zipalign Optimization
zipalignenabled True
//Remove useless resource files
shrinkresources false
//The previous part represents the system default of the Android program to confuse the file, which already contains the basic confusion statement, after a file is its own definition confusing file
proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '
//Signature
signingconfig signingconfigs.release
Applicationvariants.all {Variant -
Variant.outputs.each {Output -
def outputFile = Output.outputfile
if (outputFile! = null && outputFile.name.endsWith ('. apk ')) {
//Output APK name
//def fileName = "app_v${defaultconfig.versionname}_${releasetime ()}.apk"
def fileName = "android_v${defaultconfig.versionname}_${variant.productflavors[0].name}.apk"
output.outputfile = new File (outputfile.parent, FileName)
}
}
}
}
}
productflavors {//channel information configuration
server {
manifestplaceholders = [umeng_channel_id: "1"]
}
baidu{
Manifestplaceholders = [umeng_channel_id: "2"]
}
}
}
Engineering dependency
dependencies {
Compile Filetree (include: [' *.jar '], dir: ' Libs ')
Compile ' com.android.support:appcompat-v7:25.3.0 '
Compile ' com.android.support:design:25.3.0 '
Compile ' com.youth.banner:banner:1.4.9 '
}
Eclipse Project go to Android