Create Android app. Basics

I will learn how to create android app and going to make some notes here to help me in the future.

apps android development how with android and Smartphones|lower


ANDROID APPLICATION HINTS

1. Install Android Studio.

2. If you have an error with remember () function // import androidx.compose.runtime.* or

import androidx.compose.runtime.getValue

import androidx.compose.runtime.setValue

2.1. or declare like: val a = remember { mutableStateOf(0) }

3. Instead of startActivityForResult(intent, REQUEST_CODE) use:

val intent = Intent(context, Activity1::class.java)

getResult.launch(intent)

private val getResult = registerForActivityResult(

        ActivityResultContracts.StartActivityForResult()

    ) {

        if (it.resultCode == Activity.RESULT_OK) { val value = it.data?.getStringExtra("input")  }

    }

4. To access internet in AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

5. I have to decrease Android Studio RAM usage somehow.

5.1. In bottom right corner - > right click -> memory indicator

5.2. File -> Settings -> Plugins-> Installed  Disable plugins: Github, Google // Doesn't help a lot but I get problem with import.

5.3. File -> Power Save mode // Now I have problems with running app on device // Disable Power save

5.4. File->Settings->Editor->Inspections. Uncheck unnecessary.

6. When I am trying to import project I get some gradle error. // Go to gradle scripts -> change plugins to previous version -> try again. // I will get error during compilation.

7. How to import retrofit lib for network access. // Try to install plugin OK, Gradel // NO

7.1. Just type in build.gradle and it should download automatically

8. If you add second activity and app crashed with Intent add activity to xml.

 

 HOW TO CREATE APK

1. To add app into google store you have to pay 25$