Android

From Lost In Wonderlands
Jump to: navigation, search

Contents

Android

Opensource Technology Android wiki pages (OTA)

List of links of interest on project

Goal is to keep & share knowledge on android technologies

See Also



Android

Desiging for Android

Android Developper

About

platform

documentation

guide


Java for Android

Kotlin for Android

C/C++ for Android

Material Design

AndroidX & JetPack

Android SDK Documentation

https://developer.android.com/reference/android/view/View

facebook SDK for Android

Google Codelabs

a lot of coding labs to show many implementation of features

Android Training

Android Tutorials

Mongo DB

Android Architecture Components



Model-View / ViewModel

Android Dev Tools

Android documentation

Android Blogs

Android books


Android Articles

Android Topics

Android App Bundle

An Android App Bundle is a publishing format that includes all your app’s compiled code and resources, and defers APK generation and signing to Google Play.



API level and OS releases

Android Application architecture guide

Application() object

Android LifeCycle Cheat Sheets


Android Jetpack

Android Manifest

errors on manifest when you build

  • android:exported required in activity targeting Android 12 and Higher
    • full text is

"android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details."

 <activity
           android:name=".MainActivity"
           android:screenOrientation = "portrait"
           android:label="@string/app_name">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
</activity>
  • to change into
 <activity
           android:name=".MainActivity"
           android:screenOrientation = "portrait"
          android:exported="true"
           android:label="@string/app_name">
           <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
           </intent-filter>
 </activity>
  • we have to set once the build target is equal or superior to Android 12 (API level 31 ) and the activity owns <intent-filter>
    • android:exported="true" , the activity is exported
    • android:exported="false", the activity is not exported

Android Releases

Android X

Activities


Animations

Buttons


Broadcast Receiver



Connectivity


Connecting

coroutines



Data-Binding


articles

sample codes

Data and File storage overview


Deprecated

stuff that is deprecated by API levels, and how to replace that stuff ( this is a never-ending work , just started so there is only a few stuff)

Android kotlin extensions are deprecated

Kotlin synthetics deprecated use view binding see viewBinding

view binding is no more "synthetic" but require data binding from jetpack

ViewModelProviders.of() is deprecated, how should I create object of ViewModel?

don't :

grade : implementation 'androidx.core:core:1.1.0'
kotlin :boardViewModel = ViewModelProviders.of(this).get(BoardViewModel::class.java)

do:

grade : implementation 'androidx.core:core:1.2.0'  // and upper versions
viewModel = ViewModelProvider(this).get(MyViewModel::class.java)

and if your MyViewModel is having parameters then use a Factory:

val factory = MyViewModelFactory(myParam)
viewModel = ViewModelProvider(this, factory).get(MyViewModel::class.java)

where MyViewModel is something like

  class MyViewModel(myParam: Int) : ViewModel()  {
     ...
  }

and Its Factory something like:

class MyViewModelFactory(private val myParam: Int)
   : ViewModelProvider.NewInstanceFactory() {
   @Suppress("UNCHECKED_CAST")
   override fun <T : ViewModel> create(modelClass: Class<T>): T {
       return MyViewModel(myParam) as T
   }
}



Best is with last Android SDK API using the by ViewModels() injection one the level grants it

// Use the 'by viewModels()' Kotlin property delegate
// from the activity-ktx artifact
private val model: NameViewModel by viewModels()

//note: this is available only from an activity or a fragment

Using by viewModels()

more to be provided

by activityViewModels()

more to be provided


WebView setAppCache is deprecated in API level 30

Device running and debugging

activate your device to run an app on it

NB: sometime on a specific phone maker layer above Android legacy the "about the phone" can be located in a different system panel e.g. OnePlus is having it own about the phone panel replacement.

Intents

Common Intents


Devops corner

automatic code checking

Gradle

  • there is a Gradle plugin in Android Studio current is 7.01
  • there is a Gradle tool current is 7.2
  • both do not have the same version
  • sometime, actually soon or later, android studio is going to propose you to add a Gradle wrapper
    • this is actually creating a local gradlew tool for your project ,

you can then use ./gradlew in place of gradle in the terminal for the project to insure to run the correct version for your project it is done adding a Gradle-wrapper.properties

  • Anytime, Android is going to propose you to upgrade Gradle plugin , it will actually provide you with a view within build panels at the bottom where it will tell you what is going to change

you have to valid the changes to make ( it hapens pressing above button) else you will think you upgraded but actually until you tell so, you did not

  • you can edit your grable file by hand ( typing text)
  • you can edit your gradle file using the android studio /file/ project settings dialog...

you may encounter several errors at build time

  • bad "Source option"
Task :app:compileDebugJavaWithJavac FAILED 
error: Source option 5 is no longer supported. 
Use 6 or later. error: Target option 1.5 is no longer supported. 
Use 1.6 or later. Source option 5 is no longer supported. Use 6 or later.  
Target option 1.5 is no longer supported. Use 1.6 or later.

this has do with the java compiler version and the JVM

 compileOptions {
       sourceCompatibility JavaVersion.VERSION_11
       targetCompatibility JavaVersion.VERSION_11
   }
   kotlinOptions {
       jvmTarget = '11'
   }

in the setting dialog it is on the modules section source and target be aware that there a pop up menu , unfortunately it does not provide you with only the correct value for exemple you can select an environment variable , for me it was a $kotlinversion set to 1.5.30 unfortunately the JVM to use was JDK and JVM 11

by not having the correct JVM  and JDK version, and so, the wrong java compiler and environment, you may 
get errors in java generated source code . you should never edit these generated files  but understand what is going wrong
most of the time android studiowill tell you what to do , sometimes not  then goggle search engine is your best friend or your colleagues or me ;) 

gradle project setting dialog

  • it lists all the modules your integrated in your project in Dependencies

you can update to newer version by changing it

  • it provides you with suggestions for modules version to upgrade to

BUT sometime it is just wrong you should remember the previous version in case of issues in order to go back

  • note that android studio is also providing such suggestions in the pop up menu that is shows near by the text when mouse cursor is above the text

JVM

JAVA

Kotlin


Lifecycle, activities and fragment, architecture component, jetpack, android X

LiveData, architecture component, jetpack, android X

Layout and Bindings Expression


Data Binding Sample


Layouts


layout in Material

Layout resources

reusing layouts

trainings on layouts

samples on layouts


Android Library /Module Repository local or remote you managed

Life Cycle, Transformation Maps and Bindings Expression

Fragments


Media , Formats etc...

Navigation, architecture component , Android JetPack

Parcelables

the android way to serialize object into a bundle of key , value pairs

once an object is parcelized we can add it as an object with a key into a bundle

Bundle for exemple used to save /restore state of an application when asked to do so (See Activity lifecycle)

Permissions

Resources

App Resources

Available Resources Types

More Resources types

String Resources

Adding resources in Android Studio

Room, architecture component , Android Jetpack






room and coroutines


RecyclerView RecyclerViewAdapter





a Sample from Google

ListAdapter, DiffUtil

Samples on github


Shared Preferences

save key-value data

SQLite


Type Mismatches

list weid type mismatch and possible way to solve it


On Edit Text, you cannot assign a String ??

  • Type mismatch.

Required: Editable Found: String

editText.text  = String
  • why ?
When generating a synthetic property for a Java getter/setter pair Kotlin first looks for a getter. 
The getter is enough to create a synthetic property with a type of the getter. 
On the other hand the property will not be created if only a setter presents.
When a setter comes into play property creation becomes more difficult. 
The reason is that the getter and the setter may have different type. 
Moreover, the getter and/or the setter may be overridden in a subclass.
  • use setText accessor (the best solution)
Use setText(String), since editText.text expects an Editable, not a String.
  • cast the EditText as Text View
(binding.userName as TextView).text = "oh"
  • build an Editable object from the string
fun String.toEditable(): Editable =  Editable.Factory.getInstance().newEditable(this)
mEditText.text = myString.toEditable()

Snackbar , MaterialUI

Text Appearence

Testing

Vibrator API


View Binding

NOTE : Android Kotlin extensions are deprecated so you have to migrate from Kotlin Synthetics to Jetpack view binding

note an older pre- viewbinding , binding solution is, among others, Butterkinife

Work Manager

work manager google codelab

Android Studio

Android on Youtube


Android Trainnings

  • UDEMY

Android NDK

Android Wear

Android TV

Android Car

Android Things (IOT)

Android on Chrome OS

Android AOSP

Android Harware

Android Architecture


AOSP

Building

repo

git repositories

Android Devevelopment

a Few Libraries of Interest

ButterKnife

a deprecated by viewBindings (see focuses section) for bindings

SQLDelight

JSON

Moshi

a JSON Parser lib in kotklin and java

Workflow

a finite state machine for swift and kotlin

Picasso

an imaging and caching library

I/O Libraries

okio

A modern I/O library for Android, Kotlin, and Java.

RetroFit

a HTTP client for android and Java

OkHttp

a Http lib , efficient , modern ,

OwnCloud

ExoPlayer

ExoPlayer is a media player library developed by Google.

Dagger / Dagger 2

a java dependency injection for android obsolete prefer koin or kodein (see below)

Koin

a kotlin dependency injection for android

Kodein

a kotlin dependency injection for android

kTor

have to be move to the kotlin page


a client server dev toolkit with kotlin


tornadoFx

have to be move to the kotlin page


a JavaFx toolkit for kotlin


Timber

a Log Extension Utility Library


RxJava for Android

RxJava bindings for Android for RxJava2 RxAndroid: Reactive Extensions for Android

Splitties

a collection of small libraries that can be added individually not limited to Android , but to kotlin even if currently most are only targeting Android

Android Game Developement

Google Play Store

Android Testing

https://developer.android.com/training/testing/fundamentals
https://developer.android.com/training/testing/index.html
https://developer.android.com/training/testing/integration-testing/index.html
https://developer.android.com/training/testing/unit-testing/local-unit-tests.html
https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests.html
tools
https://developer.android.com/studio/test/command-line.html
https://developer.android.com/studio/test/monkeyrunner/index.html
https://developer.android.com/studio/test/monkey.html
https://source.android.com/devices/tech/debug/dumpsys.html
UI Testing
https://developer.android.com/training/testing/ui-testing/index.html
https://developer.android.com/training/testing/ui-testing/uiautomator-testing.html
https://google.github.io/android-testing-support-library/docs/uiautomator/
testing support library
https://google.github.io/android-testing-support-library/
https://developer.android.com/topic/libraries/testing-support-library/
testing display performance
https://developer.android.com/training/testing/performance.html

testing a service
https://developer.android.com/training/testing/integration-testing/service-testing.html
testing a content provider
https://developer.android.com/training/testing/integration-testing/content-provider-testing.html
testing -samples
https://github.com/googlesamples/android-testing
testing templates
https://github.com/googlesamples/android-testing-templates
CodeLab Testing android app
https://codelabs.developers.google.com/codelabs/android-testing/index.html#0


testing and debugging with android studio
https://www.youtube.com/watch?v=2I6fuD20qlY