[main]: Add mdp to lecture notes
This commit is contained in:
70 files changed
+2759
No files matched your search
@@ -0,0 +1,82 @@
|
||||
# App Optimisation, Testing & Deployment
|
||||
|
||||
### Check Memory Usage
|
||||
|
||||
- `abd shell dumpsys meminfo <package_name>`
|
||||
- Check if memory size increased since launch
|
||||
- Number of objects that have been created
|
||||
- Database information
|
||||
- Terminology:
|
||||
- Native Heap: memory used by the process itself
|
||||
- Dalvik Heap: memory allocated by DalvikVM
|
||||
- Dalvik Other: memory used for JIT
|
||||
- Pss total: all connections to the main device memory thread
|
||||
- Private dirty: actual amount of RAM the app is using on the heap since the app started
|
||||
|
||||
### Code Optimisation
|
||||
|
||||
- Minimise object creation
|
||||
- Make a method static if there is no need to modify the state of an object
|
||||
- Make any constants `static final`
|
||||
- `Int` is 2x faster than `float`
|
||||
- Use enhanced for loops (for-each instead of regular for loops)
|
||||
|
||||
### App Testing
|
||||
|
||||

|
||||
|
||||
- Generally, developing tests is done before developing code
|
||||
|
||||
#### Unit Tests
|
||||
|
||||
- Build unit tests to verify the logic of specific code in the app
|
||||
- Local tests
|
||||
- run on the local Java VM
|
||||
- Instrumented tests
|
||||
- run based on the Android dependencies
|
||||
- Can use `mockito` or `robolectric` to isolate a unit from its dependencies
|
||||
|
||||
#### UI Tests
|
||||
|
||||
- Test an entire sequence of events, user interface, end-to-end testing on emulators & devices
|
||||
|
||||
- Tools: `AndroidJUnitRunner` & `Espresso API` & UI Automator
|
||||
|
||||
- Modify `build.gradle`
|
||||
|
||||
```groovy
|
||||
dependencies{
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
}
|
||||
```
|
||||
|
||||
- Espresso records UI interactions and can use these to run a repeatable test automatically
|
||||
|
||||
#### Monkey (stress test)
|
||||
|
||||
- Runs on an emulator and generates pseudo-random streams of user events (clicks, touches, gestures and system-level events)
|
||||
|
||||
```sh
|
||||
$ adb shell monkey [options] <event-count>
|
||||
$ adb shell monkey -p your.package.name -v 500
|
||||
```
|
||||
|
||||
#### APK Generation
|
||||
|
||||
- Use a good / unique *package name*
|
||||
- `[org/com].[company].[product].[component]`
|
||||
- Build `->` Generate Signed APK
|
||||
|
||||
##### Shrink Code & Resources (Proguard)
|
||||
|
||||
```groovy
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnable true
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Can try `proguard-android-optimize.txt` for more code shrinking
|
||||
Reference in new issue
Block a user