Skip to content

Commit

Permalink
Android: start describing chunking apps into library modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtigger committed Jul 25, 2016
1 parent 42d34fa commit 15a6bd1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
23 changes: 11 additions & 12 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
- Get familiar with the two primary app components: [Activities](https://developer.android.com/guide/components/activities.html) and [Fragments](https://developer.android.com/guide/components/fragments.html).
* pay special attention to the lifecycle stuff.
- Go through the [Android Testing Codelab](https://codelabs.developers.google.com/codelabs/android-testing/index.html) to get a feel for how TDD can look on Android.
- (TODO: Dagger 2)
-
- (TODO: Dagger 2)


## Installing Android Studio
Expand Down Expand Up @@ -53,8 +52,8 @@ Install Sessions:
1. activities, services, and broadcast receivers that are actively doing work.
- activities that are paused but still visible (or services bound to such activities)
- background services (i.e. launched with `startService()`)
- backgrounded activities (i.e. that have been `onStop()`'ed.
- Practical implication: a process doing the same work through a Service will be higher priority than a process using an async task.
- backgrounded activities (i.e. that have been `onStop()`'ed.)
- Practical implication: a process doing the same work through a Service will be higher priority than a process using an async task.

#### Multi-Threading

Expand All @@ -77,14 +76,14 @@ Install Sessions:

### The Activity Lifecycle

* `onCreate()`allocate resources, start fetches,
- `onStart()`
- `onRestoreInstanceState()` — restore UI and local app state
- `onResume()`
* `onCreate()`initialization required only once (e.g. creating and injecting depedencies)
- `onStart()`things that should be done each time the Activity becomes activty, again.
- `onRestoreInstanceState()` — restore UI and local app state
- `onResume()`
- `onPause()` — store data that should be persisted across application launches or that might be used by an Activity taking over.
- `onSaveInstanceState()` — save local app state *(not called if app is definitely quitting)*
- `onSaveInstanceState()` — save local app state *(not called if app is definitely quitting)*
- `onStop()`
* cancel any background tasks (e.g. `AsyncTask` instances)
* cancel any background tasks (e.g. `AsyncTask` instances)
- `onDestroy()`

![The Activity Lifecycle](https://developer.android.com/images/activity_lifecycle.png)
Expand All @@ -96,9 +95,9 @@ Install Sessions:

Out-of-The Box:
* Most `View`s can save their own state (and will do so via the default implementation of `Activity.onSaveInstanceState()`).

> **Tip:** only widgets with an `android:id` will be saved.

## Visual Aspects

Expand Down
4 changes: 4 additions & 0 deletions android/architecture/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

# Application Architecture

## Chunk Application Into Modules

* for each Activity/Content Provider/Sync Adapter/(android component), create a separate [Android Library](https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/user-guide#TOC-Library-projects) module.
* see also: [build](../build) for details of how to make the app module dependent on the libraries.

## Dependency Injection with Dagger2

Expand Down
15 changes: 15 additions & 0 deletions android/build/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@


# Partition Application into Module per Component

Not only does splitting the application into modules (i.e. an Android Application module dependent
on a set of Android Library modules) make it easier to locate resources, it makes it easier to
navigate the codebase.

## Workaround for Gradle Deficiency

Until https://code.google.com/p/android/issues/detail?id=52962 is resolved, you must manually
propagate the active Gradle Configuration from the app to libraries:

* each library [publishes all build variants](https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/user-guide#TOC-Library-Publication).
* the app module names a dependency for each buildVariant (as described [here](https://code.google.com/p/android/issues/detail?id=66805)).

# Group Dependencies by Need

... in `build.gradle`

* you can always get a listing of the classpath using `./gradlew dependencies` but nothing else will tell you what set of dependencies are present for a given need.


# Resolving unwanted transitive dependencies

Because the app APK and test APK share a classpath, they have to agree on library versions (and it's just good practice anyway).
Expand Down
14 changes: 14 additions & 0 deletions android/proguard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# Raw Notes

* By default, ProGuard removes code that is not explicitly referenced by seeds, transitively.
* You can keep classes by:
* including a line like `-keep public class MyClass` in the `proguard-rules.pro` file.
* adding the `@Keep` annotation
* defined in the [Annotations Support Library](https://developer.android.com/topic/libraries/support-library/features.html#annotations).


# Resources

* (ProGuard Troubleshooting](https://stuff.mit.edu/afs/sipb/project/android/sdk/android-sdk-linux/tools/proguard/docs/index.html#manual/troubleshooting.html)

0 comments on commit 15a6bd1

Please sign in to comment.