Robolectric

How does it work

  • Shadow object
  • View and resource loading
Read More

Android Studio Robolectric

New Resource :

目前在網路上的 Android Studio unit test 的範例可以說是少得可憐,尤其是 Android StudioGradle 這兩個大傢伙不斷低更新,要找到比較符合現狀的組合又更少了。

android-unit-testandroid-studio-unit-test-plugin 這兩個 repo 來設置 Robolectric 是我目前看到最簡單的設定。

建置環境:

Read More

Build Android with Gradle (List)

Build Android with Gradle (Dependency & Compile)

Dependencies, Android Libraries and Multi-project setup

Dependency Local & Remote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
repositories {
mavenCentral()
}

dependencies {
// Local packages
compile files('libs/foo.jar')

// Remote artifacts
compile 'com.google.guava:guava:11.0.2'
}

android {
...
}
Read More

Build Android with Gradle (Build Type + Product Flavor = Build Variant)

Product flavors

app/build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
android {
....

productFlavors {
pro {
...
}

free {
...
}
}
}
Read More

Build Android with Gradle (Signing)

Signing Configurations

  • A keystore
  • A keystore password
  • A key alias name
  • A key password
  • The store type
Read More

Build Android with Gradle (Build Type)

  • release (Default)
  • debug (Default)
  • custom build type (Ex: alpha, beta)
Read More

Build Android with Gradle (Basic Config)

Manifest entries

  • minSdkVersion
  • targetSdkVersion
  • versionCode
  • versionName
  • applicationId
  • Package Name for the test application
  • Instrumentation test runner
Read More

Build Android with Gradle (Sourcesets)

Project Structure

source sets
├── source components(Java Plugin)
└── source components(Android Plugin)
Read More

Build Android with Gradle (Pre)

Gradle Plugin User Guide

首先,可以先參考這個連結Gradle: The New Android Build System下面的影片
並且下載的gradle,連結

# Mac install
brew search gradle
brew install gradle
Read More