gradle / build Flashcards

1
Q

What is Gradle?

A

A build automation tool

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the Manifest responsible for declaring? (4)

A

App’s package name (used by build tools and Google Play)
App’s components (Activities, Services, Broadcast Receivers, Intent filters etc)
Permissions
Hardware and software required (for device compatibility)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Manifest data used by?

A

Android OS, Android build tools, Google Play

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is AndroidX?

How is it enabled?

A

Jetpack libraries - they ship separately from the Android platform and replace the Support Library.

Enabled by setting 2 gradle.properties:
android.useAndroidX = true
(this uses androidX libraries instead of Support Libraries)
enableJetifier = true
(migrates existing third-party libraries to use AndroidX dependencies by rewriting their binaries)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What do the following properties define and where can they be found?

  • compileSdkVersion
  • targetSdkVersion
  • minSdkVersion
A

Found in build.gradle(Module:app)
android{

compileSdkVersion
// specifies the Android API Gradle should use to compile your app. Newest supported version.
targetSdkVersion
// most recent API tested against - usually same as compileSdkVersion - may be different from compile version if app was developed to target an earlier version of Android
minSdkVersion
// Oldest version of Android on which the app will run.

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How are the 3 xml namespaces defined and what are their purposes?

A

xmlns:android=”http://schemas.android.com/apk/res/android”
Enables use of keys from core Android libraries (standard keys eg android:id, android:layoutHeight, etc)

xmlns:tools=”http://schemas.android.com/tools”
For use in previewing layouts in development

xmlns:app=”http://schemas.android.com/apk/res-auto”
For attributes originating from custom code or non-core Android libraries (includes constraintEnd_toEndOf etc). Can be useful for backwards compatibility using androidx.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the effect of setting the following?

  • tools:context
  • tools:layout

With what syntax should they be set?

A

tools:context=”fully.qualified.activity.name”
Enables the preview to display with the activity’s theme (stored in the manifest and thus otherwise unavailable until compile time)

tools:layout=”@layout/my_fragment_layout_xml”
Enables a fragment layout, for example, to be previewed on the specified main layout. Also useful in displaying layouts in nav_graphs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does Gradle do with vector drawables when building for API < 21?
Why?
Why might this be a problem?

A

Gradle auto-creates png files from vector drawables.

Vector drawables only supported from API21 onwards. This can be a problem as it increases app size.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you enable vector drawables on unsupported APIs ( < 21 ) ?

A

vectorDrawables.useSupportLibrary = true
( in build.gradle(Module:app) )

Replace android:src with app:srcCompat

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the main differences between the following?

  • build.gradle
  • settings.gradle
  • gradle.properties
A
build.gradle
define dependencies, plugins and configurations for app module and other modules

settings.gradle
include all subprojects / components / features so gradle knows what’s included in the build

gradle.properties
k-v properties for things like enabling Jetpack, R8 etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Where are constants stored for dependency versions?

A

In build.gradle(Project:)
ext{
version_navigation = “1.0.0” // (example)
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What 2 things might DSL stand for?

A

Domain-Specific Language

Digital Subscriber Line
(formerly Digital Subscriber Loop)
DSL = a family of technologies that are used to transmit digital data over telephone lines.
Usually DSL = ADSL (Asymmetric DSL)
The asymmetric part of the tech (sending data down copper wires) means download speeds are greater than upload speeds.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the Application class?

How do you override it? (2)

A
Base class for maintaining global application state.
The main object the OS uses to interact with your app. 

Override by creating a subclass and specifying the fully-qualified name as the “android:name” attribute in your AndroidManifest.xml’s ^application^ tag.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does APK stand for?

A

Android Package Kit

a package file format

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

You can put code in the application class if… (2)

A

The whole app will use it

It needs to be initialised once, before everything else is set up

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between the Application class and the Context class?

A

Application Class

  • a base class for maintaining global application state.
  • this is the class we override if we have application-wide tasks to initialise before anything else (eg Timber).
  • Application extends ContextWrapper; ContextWrapper extends Context

Context

  • an interface to global information about an application environment.
  • an abstract class whose implementation is provided by the Android system.