13
Android migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We 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_name artifactoryPassword=type_yout_domain_password artifactoryURL=http://arti:8081/artifactory/libs-release-local org.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

Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

  • Upload
    lamngoc

  • View
    230

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

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

Page 2: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

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

 

Page 3: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

Set the minimum SDK base on original project.

Adding activities

 

Choose not to add activity.

Creating moduleOpen project structure

Page 4: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

 

Click on “+” (Add new module)

Page 5: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

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

Page 6: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

 

Configure new module

 

Adding activities

Page 7: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

 

Choose not to add activity.

Remove module

Page 8: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

 

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.

Page 9: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

 

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).

Page 10: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

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

Page 11: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

// 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

Page 12: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

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

Page 13: Android migration Elipse/SVN to Android Studio/GIT · PDF fileAndroid migration Elipse/SVN to Android Studio/GIT project Setting up Gradle We need to setup some local variables (like

   

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