Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Saturday, 9 July 2022

Android Jetpack

Jetpack is a collection of useful Android libraries.  A typical Android app will have multiple layers: a UI layer, an (optional) domain layer and a back-end ("data") layer. A candidate for code in the domain layer would be complex business logic that is used across multiple ViewModels.

LiveData and ViewModel are examples of JetPack components. LiveData is interesting, it follows the Observer pattern and notifies Observer objects when the underlying data changes. This way you don't need to write update code in the UI every time the underlying application data changes. Observers have a void return onChanged method that gets called every time data is changed.

Sunday, 5 June 2016

Debugging On-Device from Android Studio

You need to have the appropriate OEM drivers installed for ADB (Android Debug Bridge).

What does a Basic App Look Like in Android Studio?

There are two folders:

1. One for your App - which will be called "YourAppName"
2. One for the Gradle build - which will be called "Gradle Scripts"

What does "YourAppName" I look like?

There's a .idea folder (which relates to IntelliJ settings), an app folder (that's your code), and gradle folder containing gradle-wrapper.jar.

What does "Gradle Scripts" look like?

Bunch of files, most important is gradle.properties.



Failed to Sync Gradle Project in Android Studio

A look at the error detail reveals the following - "Unable to start the daemon process: could not reserve enough space for object heap. Please assign more memory to Gradle in the project's gradle.properties file".

More detail on Gradle's configuration can be found here.

More information about GC configuration can be found here.

To get around this error, try adjusting the -Xmx setting in gradle.properties. Just be careful not to increase it beyond the "maximum representable size".

Why does Android need a Java SDK to run?

The Android build process, which converts an application into an APK (or Android Application Package) relies on the JDK to a large extent.  Also, jarsigner is needed to sign the APK.  Since the JDK is required, ensure that your JAVA_HOME variable is set and that you can run javac from the command line (edit your system PATH to ensure you can do this).

Tuesday, 31 May 2016

An Idiot's Guide to Android Studio

Android Studio is the official IDE for Android development. The latest version has support for N preview development, the next version of Android after Marshmallow. C and C++ integration is available via the Android NDK. There is an additional overhead and complexity so evaluate carefully whether you ought to be using the NDK.

Installing Android Studio is a 1-day job.  Even once you install and extract the relevant files, the first time you run Studio it will still need to download additional components, this takes quite a while.

One of the final steps is the creation of the Android virtual device. This requires installation of Intel HAXM (Hardware Accelerated Execution Manager) to speed up Android application on the host machine.