Developer Tools covered:
-> deployment, on smartphone
-> debugging, via system messages
-> the best practices
Namely, popular libraries, naming conventions, and news to keep up to date.
The strength of Android is its community, follow it, to adopt its best practices.
42. B. Debugging
B Use of Android Log
Log.e(String tag, String message, Throwable tr)
43. B. Debugging
B Use of Android Log
Log.e(TAG,”Error!")
TAG = "HomeActivity"
44. B. Debugging
B Use of Android Log
Log.i( MainActivity::class.simpleName,"I am I :)")
45. B. Debugging
@ Debug resources
L Build > Clean
L File > Invalidate Caches / Restart …
M Run: Compilation Error
N Error in Kotlin files
N Error message window
A Look for the fake resource
A Look for the wrong XML attribute
49. B. Debugging
@ Debug step to step
P Place break point
@ Launch the debugger
N Zoom on Debug console
_ Go to next break point
_ Go to the next line
_ Go to the next line inside code
_ Observe a variable
_ Execute flying code
A
Q
Q
M
R
70. C. Best Practices
U Unit Tests
package (androidTest)
+
B ActivityInstrumentationTestCase2
71. C. Best Practices
U Unit Tests
com.chillcoding.home (androidTest)
L (droit) Run > All tests
72. C. Best Practices
U Unit Tests
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
...
testCompile 'junit:junit:4.12'
}
B gradle
Reference [Android]: Expresso
73. C. Best Practices
U Unit Tests
public class HomeActivityTest extends ActivityInstrumentationTestCase2<HomeActivity> {
public HomeActivityTest()
@Override
protected void setUp() throws Exception
public void testPreconditions()
public void testText()
74. C. Best Practices
U Unit Tests
public class HomeActivityTest extends ActivityInstrumentationTestCase2<HomeActivity> {
public HomeActivityTest() {
super(HomeActivityTest.class);
4 Initialize the class
75. C. Best Practices
U Unit Tests
public class HomeActivityTest extends ActivityInstrumentationTestCase2<HomeActivity> {
@Override
protected void setUp() throws Exception {
super.setup();
4 Initialize test environment
76. C. Best Practices
U Unit Tests
public class HomeActivityTest extends ActivityInstrumentationTestCase2<HomeActivity> {
public void testPreconditions()
4 Check pre-conditions
77. C. Best Practices
U Unit Tests
public class HomeActivityTest extends ActivityInstrumentationTestCase2<HomeActivity> {
public void testText()
4 Do the test
78. Random tests
Z
: ./adb shell monkey -p com.chillcoding.mycuteheart -v 500
C. Best Practices
( Monkey Stress Test
4 500 random evts
79. C. Best Practices
U Naming Convention
U Naming Convention
U Naming Convention
( Shortcuts
81. Legend:
L Click
L Enter Key
L Control Key
L Command Key
L Shift Key
L Option or Alt Key
C. Best Practices
( Shortcuts
Alt
Ctrl
⌘
L
82. C. Best Practices
( Shortcuts
Alt Solve any pb.
⌘ Alt L Indent code
Valid proposal of AS
Ctrl L Go to class / file
See the documentation
Rename a variable, a file
Generate super classe fun
F6
⌘ N
Ctrl Q / F1
Look for something into the project
Ctrl / Comment
Ctrl
Ctrl
Y
D
Delete a line
Duplicate a ligne or a selection
Ctrl O Override a method
83. IF YOU THINK
YOU ARE TOO
SMALL
TO MAKE A
DIFFERENCE
TRY SLEEPING
WITH A MOSQUITO.
_ African Proverb
84. References
• Quizz Outils du Développeur Android
• ChillCoding: Android references
• Udacity: Android Development for Beginners (Video)
• Developer Android: Application Fundamentals (API Guide)
• Edition Eni : Android 5 Les fondamentaux du développement d'applications Java (Livre)
• Improve Your Code with Lint
• TDD in Android Kotlin
• Must Have Libraries
• wasabeef: Awesome android ui
• https://www.raywenderlich.com/category/android
• Jakewharton: Just say no to hungarian notation
• https://medium.com/ekohe/how-to-write-good-code-an-introduction-to-sandi-metz-s-rules-89bb3d749d53
• https://choosealicense.com/
• https://github.com/ribot/android-guidelines/blob/master/project_and_code_guidelines.md
• https://developer.android.com/kotlin/style-guide
• https://kotlinlang.org/docs/reference/coding-conventions.html