Tuesday, February 23, 2016

info Android Continous Integration

Continuous Integration 
Goal is that every time you commit your code, your code automatically goes thru some Junit testing (iOS/Android) and also builds the apps (ipa/apk). CI helps improves the quality of the app. Ideally is nice to have one system when you can kick a build and also run your unit and integration tests. CI is key to have a great app :)

Good read: Tools used by other companies:
Android Jenkins aws 
Read to learn about CI Jenkins vs. Circle CI vs Travis

 


------------------------------------------------------------------------------------------------------------
My Opinion:
Most enterprise companies use Jenkins. For small companies I would suggest CircleCI($) or Travis($$$).

------------------------------------------------------------------------------------------------------------
Jenkins:

What is Jenkins? 

Jenkins Plugin info (BUILD_NUMBER..)
Jenkins is an open source continuous integration tool which aims to automate certain tasks that developers find themselves repeating. It runs as a local server on a host machine
Tutorial by codepath
Setup:
1. Create Jenkins account.
2. Configure Jenkins:
Install Plugins: Manage Jenkins -> Manage Plugins -> Available
  • Gradle Plugin (build system)
  • Git Plugin (use git to link to your projects repos)
  • Android Emulator
  • AWS device farm (test apps with real devices using AWS Device farm)
  • HockeyApp (distribute apps)
  • Android lint plugin - Lint is a great tool created by Google to analyze the code for Android. It comes with the SDK of Android and it is useful to have good quality code.
3. Configure Git repo, ssh key.
4. Create new job to generate APK.

Enterprise Notes:
1. Create Jenkins account.
2. Install Android SDK in jenkins machine(node) 
3. Install Plugins.
4. Configure Git Enterprise repo(master).
5. Test run to generate apk.

Tips 
Jacoco Reporting

------------------------------------------------------------------------------------------------------------
Circleci uses the build file: circle.yml, you need to create and add this file to your project root.
Circleci builds apk and runs Espresso UI test(click button change text).
GitHub Project
Circleci Dashboard
Reference
Circleci iOS



------------------------------------------------------------------------------------------------------------
Travis uses the build file: travis.yml , you need to create and add this file to your project root.  Can be setup to run both unit and integration tests. Working example follow below step: CodePath Tutorial
GitHub Project
Good read
Travis Enterprise
Travis iOS 
Travis upload apk to Testflight


 



------------------------------------------------------------------------------------------------------------
Online Examples:

Android example:
https://www.bignerdranch.com/blog/continuous-delivery-for-android/

iOS example:
Build and deploy to HockeyApp
Travis iOS very example




------------------------------------------------------------------------------------------------------------
Other Resources:

CI slides-
http://www.slideshare.net/sergiizhuk/slides-v6-41909668
http://www.slideshare.net/tomoakiimai2/tips-for-better-ci-on-android?related=1

CI paper - 
https://saucelabs.com/resources/white-papers/why_ci_should_be_part_of_your_mobile_dev_process-a_sauce_labs_report.pdf/@@download/file

Gradlew-
https://guides.codepath.com/android/Getting-Started-with-Gradle
http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Tasks

Monday, February 1, 2016

info Android Material

Good read about Material Design

Components:
snackbar

Drawables tutorial

info Android Testing (and iOS)

Mobile Testing background

 ------------------------------------------------------------------------------------------------------------


Android
Robolectric for unit testing,
Espresso for UI testing,



iOS
Xcode XCTest

 ------------------------------------------------------------------------------------------------------------

Robolectric:
Very Good Tutorial
http://robolectric.blogspot.com/2010/12/testing-startactivityforresult-and.html
http://turhanoz.com/unit-test-android-starting-an-activity/
https://github.com/codepath/android_guides/wiki/Unit-Testing-with-Robolectric

-----------------
Appium:
Appium(python) and AWS Device Farm - Cloud testing
http://docs.aws.amazon.com/devicefarm/latest/developerguide/getting-started.html
iOS Video Example (*very good tutorial*)
 https://www.youtube.com/watch?v=CLeb1wjctuU
Getting started: http://docs.aws.amazon.com/devicefarm/latest/developerguide/getting-started.html 

----------------------
XCTest

 ----------------------
Espresso

Espresso vs Robotium



----------------------


Follow this tutorial: https://codelabs.developers.google.com/codelabs/android-testing/index.html?index=..%2F..%2Fandroid-dev-summit&viewga=UA-69243313-1#5

Testing Fundamentals:
http://developer.android.com/tools/testing/testing_android.html

Slides:
http://www.slideshare.net/dtmilano/introduction-to-android-testing?related=1

CodePath testing guide 


------------------------------------------------------------------------------------------------------------




------------------------------------------------------------------------------------------------------------
Resources:
 https://developer.android.com/tools/testing-support-library/index.html#AndroidJUnitRunner
https://google.github.io/android-testing-support-library/
https://codelabs.developers.google.com/codelabs/android-testing/#0


Thursday, January 7, 2016

SharedPreferences in Android [ put string and get string ]

PUT
private SharedPreferences sharedPreferences;
sharedPreferences.edit()
        .putString("KEY_NAME", name)
        .apply();


GET
String NameURL= getPref("KEY_NAME", getContext());

public static String getPref(String key, Context context) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); 
  return preferences.getString(key, null);
 
 
 
Resources: 
https://medium.com/google-developers/sharedpreferences-is-your-answer-to-simple-storage-a7c8499ea8ff#.7eoyjrjgi

Thursday, December 17, 2015

How to run Android App with latest Android tools


Google Android info

Android Styling:
 https://blog.stylingandroid.com/percent-part-1/

Install latest Android Studio:

Install latest Android emulator:

Enable Instant run:

Google Android tech docs:


Android developers blog
http://android-developers.blogspot.com/

Android best practices:
https://github.com/futurice/android-best-practices
 http://guides.codepath.com/android

Android devices Dashboard(google)
https://developer.android.com/about/dashboards/index.html


SourceTree uncommit
http://flummox-engineering.blogspot.com/2014/10/how-to-undo-git-commit-in-sourcetree.html

Wednesday, December 16, 2015

Butterknife Library for Android

Butterknife 

Is a view "injection" library for Android. It will reduces boilerplate code.

Example:
  1. Add dependency to app/build.gradle
dependencies {
  compile 'com.jakewharton:butterknife:7.0.1'
}
  1. In main.xml declare an image widget id name "image"
  2. In main.java start using @Bind to declare each variable 

public class Main extends AppCompatActivity {
private static final String ITENT_TAG= "chapter"; 

private Chapter chapter;

@Bind(R.id.button) Button myButton; 

@Bind(R.id.textTextView myText;

@Bind(R.id.image

ImageView myImage;  

@Override public void onCreate(Bundle savedInstanceState) 

{
super.onCreate(savedInstanceState);   setContentView(R.layout.activity_detail);   ButterKnife.bind(this); 

@OnClick(R.id.button) protected void Toast(){

Toast.makeText(getApplicationContext(),"Hello Android Butter Knife",Toast.LENGTH_LONG).show();}

}

myText.setText("Hello!");

res = getResources();
myImage.setImageDrawable(res.getDrawable(R.drawable.myimage));



  • Also initialize ButterKnife in OnCreate:
 ButterKnife.bind(this);


Resources:
http://www.sitepoint.com/tidying-code-with-android-butterknife/
https://guides.codepath.com/android/Reducing-View-Boilerplate-with-Butterknife