Chronologically listed of common tricks that I cannot remember without searching the Web!!
About Android Studio 4.1 from a beginner's perspective
created March 16, 2021

Introduction

We have some Android apps developed at the time of Nougat or version 7.0, and they were dug out for recycling, and into the world of Android version 11 and onwards, of course, along with the new version of Android Studio.

It is better for me to refresh my very little development experience on mobile apps with Android Studio (version 4.1.3). At the same time, we are now talking about Flutter & Kotlin, of which I have zero understanding, but yet the need for cross mobile platform is a tactical decision in our context.

We have one Kotlin development (we called personalEdge) and in flux. So, in here, I start from the beginning again and taking notes here as I slow pace to pick up Android mobile app development.

The following is a few screen caps as I installed Android Studio ("AS") version 4.1.3 in macOS Big Sur, Version 11.2.3 on March 22, 2021 just for reference.




'Customize' should be a better choice once you have a good initial experience of using the AS and your targeted end-users' contexts known.



Personally, dark background ('Darcula') is better for me if a development session is longer than 1 hour without break - given that I am a grandpa generation. I did not read any scientific evidence on which is not good or good to the eyesight. In general, a break from staring at the screen is suggested - screen time should have breaks independent what you are using a computer monitor for.



There is a security setting to be set in macOS for the installation of "Intel x86 Emulator Accelerator (HAXM installer)" before it can proceed. [Wonder in M1-based Mac computer such Accelerator is still needed? Do not know anything about the M1 architecture.]]



The Android SDK Build-Tools version 30.0.3 is installed among other modules, and in directory ~/Library/Android/sdk/build-tools/30.0.3 where ~ is /Users/snoopy and differs to yours in term of the 'username' (in this case, is 'snoopy').


The following discussion is based on https://developer.android.com/studio/intro and onward, all credits with respect to Android and Android Studio thus are duely noted.

The UI of Android Studio

I find the "Project Structure" useful as I still find it easy to 'view' file system as a tree, rather than a flattened presentation. Yes, it is true that in development, the hard structure carries no significant impact to logic construction, especially, now with the IDE concept.

Classically, an application has the body of codes developing/developed, along with software library being used. The additional group is the 'Google App Engine modules.' The java folder is where the source codes go, the res folder contains resources that are not coding or language instruction per se, such as the XML layouts of the app's screens. Another folder is the manifests, a text-based file contains some necessary information, some relevant in some sense for me. Some hotkeys in Mac of interest to me are

Debug: Command[Control]+Shift+F12 ([Window and Linux]),

and

Run: Control+R [Shift+F10].

The Gradle plugin relieves the intense tracking of object/library dependencies, and offers effectiveness and efficiency in the old 'compile-link' or now 'build' mindset. Gradle is referred to as a build system for Android development. I need to learn Gradle, along with Groovy to gain a better handle to put the OzzO in perspective with respect to software development. So much to learn.

I do not have a version control system setup yet (likely will be using GitLab over at AWS). Not sure what is 'Lambda and operator expressions' in the "Inline debugging" (need to enable in the Debug window, then 'Settings') discussion. Also, the "Heap dump" should be a valuable inspection tool associated with Java runtime.

Install in iMac (MacOS Big Sur v11.2.x)

Simply downloadn an DMG [a Disk iMaGe file of MacOS] file, and follow the clickable steps should do the job.

Any configuration is necessary? Two configurations might be of interest: studio.vmoptions, and idea.properties. Where: ~/Library/Application Support/Google/AndroidStudio4.1.

Make your hardware devices, let's say a Pixel phone in here, for Android Studio to deploy an app into that device, by either via a USB cable, or via WiFi connection.

Occasionally, updates are available, and for example, for SDK, look at:


Select the option, and you will get a similar dialog box:


Updates will start and a status dialog box will appear:


A secondary dialog may appear asking for options and system authorization, such as:



I kinda skimmed through the remaining sections, and will bring each up at the appropriate time when such settings (e.g., Gradle) are relevant in the develpment phase.

Start a Simple App Development
    'Build your first app' section

I will try to work past 'Hello, World!' and into an application that, based on user's input, shows the dining menu of the day (varied to compete with other facilities around the eatery), or the dining menu of a restaurant (fixed, with non-frequent udpates).

The menu information is provided by a cloud service (for now, a RESTful Web Service) and represented in a JSON format.

One other feature is to receive 'push' messages from a subscribed cloud service) whatever the context is. Let's go.

In the outset, these terms required further exploration: 'Activity' - an app component that can be directed to, from within and without, 'other app components (),' layouts for different form factors, and required resources on the host (the mobile phone).

    Diversion: somehow, to learn basics, step by step, a separate URL (developer.android.com/courses/android-basics-kotlin/unit-1) for development in Kotlin was given. Will follow through that link in another card. In here, we continue with creation of the simple Android app using Java.

   



Let's follow the instructions and create an 'empty activity' first.

   

The applicatin name will be 'time2Eat' with other entries to be made. I change the 'com.example...' structure to 'a2a.hospitality...' or 'companyName.industryName...' And I select the backward compatibility all the way down to API 21 Android 5.0 (compares to API 30 when the AS was installed).

Likely to repeat the same for using Kotlin in next card below.



It takes a minute or two to finish other configurations (e.g., Gradle).

Note the heap size was being asked to bump up from 1G to 2G based on machine's RAM (16 GB 1600 MHz DDR3 is what I have in the laptop). I did take action based on their recommendation and AS closes and re-opens again.



Now, to the niddy griddy coding tidbits. First, the layout in app>res>layout>activity_main.xml.



Note the first left box: I change that to Pixel 4 (there is no Pixel 4a of screen size 5.81 with resolution about 1080 x 2340, 443 PPI density, viewport size 393 x 851 pixels, ratio about 2.75 - have no idea at this point of the development implication of the last two entries here!!).

Next, I prefer coding view of the layout, visual design is good once I have my coding done to see the final effect!! So, the next box on the top right is the selections of view. You might want the 'Split' view. Likely a full 'Code' view is preferred.



Bringing up the 'activity_main.xml' for editing (in a Code view), I change the 'Hello...' string to 'Time to Eat....' as a String object (which appears/is defined in ..>res>values>strings the file 'strings.xml (night)' [I remember I selected 'night' somehow when going into the layout, but have no idea what it means!! We will see.]



To be continued [March 26, 2021] after my follow through a tutorial at https://www.tulane.com


Notes for now:
  • In the original development, a few class libraries were used, and were put into the ./libs directory, and in app's build.gradle
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.1.1'
        compile 'com.android.support:design:23.0.0'
        compile files('libs/org.eclipse.paho.android.service-1.0.2.jar')
        compile files('libs/org.eclipse.paho.android.service-1.0.2-sources.jar')
        compile files('libs/org.eclipse.paho.client.mqttv3-1.0.2.jar')
        compile files('libs/library-1.0.16.jar')
        compile files('libs/library-1.0.16-javadoc.jar')
        compile files('libs/library-1.0.16-sources.jar')
    }
                  
    In this new AS, all jars are put in directly in the flat directory, and the build.gradle is edited with additional lines in 'dependencies' hopefully to eliminate the indicative compilation errors as

    implementation 'org.eclipse.paho.android:service:1.0.2'
    for the jar file org.eclipse.paho.android.service-1.0.2.jar. After that, the help tooltip asked to be sync and the class lib was recognized in the build process, removing indicative errors.



  • This line is added to build.gradle:
    org.eclipse.paho.client:mqttv3:1.0.2

    and 'sync now' is performed.




   

Source | Background
How do a simple Kotlin app
created March 25, 2021

Doing Kotlin



   



   

Source | Background
How to remove the @ in MacOS's file privileges using Terminal
created March 16, 2021

the @ sign of a file

xattr -cr [directory] | [file]

Well, this should remove the (extended) attributes that might create unnecessary prompts when backing up files to some cloud services providers. If it is a [directory], it will be done recursively - be careful if this option should be used.



   

Source man xattr
To zip a directory with a password in MacOS using a command in Terminal
created whatDate

zip -er [zipFileName] [zipDirectory]

To be continued...



   

Background