Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to...
Transcript of Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to...
Android migration Elipse/SVN to Android Studio/GITproject
Setting up GradleWe need to setup some local variables (like Asseco artifactory username and password) used in gradle scripts.
Open the file C:\Users\<USER>\.gradle\gradle.properties and add this lines:
artifactoryUserName=type_your_domain_user_nameartifactoryPassword=type_yout_domain_passwordartifactoryURL=http://arti:8081/artifactory/libs-release-localorg.gradle.daemon=true
If the file doesn't exists, you need to create it.
Setting up project in Android Studio
Open android studio and select „Start a new Android Studio project“
C:\Users\<USER>\.gradle\gradle.properties
Configure new project
Enter “Application name“. This will be subfolder name in folder “Project location“. “Real“ application leave for module name. “Application name”could be the same as name the project name on GIT. (eg. for mZABA-PS, “Application name” could be “ZABAmBankingSME”)
Set “Package name” to “production” package name. This should be “base” package name. Different environment should have package suffix onbase package (eg. base package = “hr.asseco.android.pbz”, test environment package = “hr.asseco.android.pbz.test”).
“Company Domain“ set to “ “.android.asseco.hr
Configure minimum SDK version
Set the minimum SDK base on original project.
Adding activities
Choose not to add activity.
Creating moduleOpen project structure
Click on “+” (Add new module)
We want to add application module with “real” application name. This module name will be the part of APK filename. So we need to add newmodule.
Chose application module
Configure new module
Adding activities
Choose not to add activity.
Remove module
We need to remove default module “app”. Select module “app” on the module list and select “-“ to remove it. Confirm it, and close “ProjectStructure” dialog.
Now, we must remove “app” module from the disk drive.
Open “Project” bar (on the left side) and choose “Project” preview from drop down.
Find and select “app” folder and press “Delete”, and confirm the dialog.
Project structure after deleting “app” directory/module.
Now we have the foundation to run ANT scripts (move.xml).
1. 2.
1. 2.
Configuring the ANT scriptFirst copy the ANT script ( ) to the eclipse project folder. Then open the script in Notepad++.move.xml
We need to configure only two parameters:
dest.dir – should be the dir of “application” module (not project dir).package.new – should be production/base package
<project default="convert"> <!-- SRC DIR --> <property name="source.dir" value="." /> <!-- DEST DIR --> <property name="dest.dir" value="C:/Projects/AndroidStudio/PBZmBanking/mPBZ" /> <!-- PROD PACKAGE --> <property name="package.new" value="hr.asseco.android.pbz" />
Runing the scriptTo run conversion script open command prompt, and type:
ant -f move.xml
After the script is finished, the source files will be copied to UTF-8 encoding. Configuration files from “configuration” folder will be distributed inflavors. Each configuration build will have one gradle flavor. There are two exceptions:
“test” – configuration which will be replaced with “atest” flavor,“ide” – this is flavor for developing in Android Studio
Configure Asseco repoOpen the gradle file (build.gradle). It should look like this:project
// Top-level build file where you can add configuration options common to allsub-projects/modules.
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}
allprojects { repositories { jcenter() }}
We need to modify the repositories section like this:
Original build.gradle
1. 2.
// Top-level build file where you can add configuration options common to allsub-projects/modules.
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}
allprojects { repositories { maven { credentials { username artifactoryUserName password artifactoryPassword } url artifactoryURL } jcenter() }}
Configure dependencies
Now is time to configure dependencies. There are two way:
Editing application module gradle fileEditing application module dependencies from “Project Structure”
Setting up Build variantsAt the end we need to configure variants. First, you need to run “Sync project with gradle”, clicking on the icon .
Open the “Build variants” panel on the lower-left:
Modified build.gradle
For mPBZ module from drop down choose variant “ideDebug”.
Related articles appear here based on the labels you select. Click toedit the macro and add or change labels.
Konvencija za imenovanje git projekata
GIT setup