Metadata of an Android App – AndroidManifest.xml and build.gradle

      Comments Off on Metadata of an Android App – AndroidManifest.xml and build.gradle

AndroidManifest.xml and build.gradle

Metadata of the app.

Icons, App name, theme, entry Activity are all configured here.

Icon

Icons are png files which have five different dpis.

In Package view, Icons can be located at mipmap-mdpi, mipmap-hdpi, mipmap-xhdpi, mipmap-xxhdpi, mipmap-xxxhdpi. Remember to replace them all or delete those unwanted.

The icon files should be specified in AndroidManifest.xml : android:icon=”@mipmap/iconname”

Version Code

In AndroidManifest.xml, there may be something like android:versionName="1.0", but it will always be overridden by gradle script.

AndroidStudio uses gradle script to manage the resources.

We configure the public version name in build.gradle at android.defaultConfig.versionName. Besides, we can have an inner version code to help developing at android.defaultConfig.versionCode

Entry Activity

  1. Create a new Java class (e.g. SplashActivity) and make it inherit Activity, overriding onCreate.
  2. setContentView(R.layout.activity_splash). Create activity_splash.xml following the hints of AndroidStudio.
  3. Add the activity in AndroidManifest.xml and set it to be the launcher. action.MAIN and category.launcher defines the default Activity which are a must for the app to run.






Java Version

The default Java version supported is Java 7 (although not all features). However, we can change the compiler to jack to support Java 8 features such as lambda expressions and streams. To do so, we add jackOptions {enabled true} to build.gradle at android.defaultConfig. However, using jack we lost the benefit of Instant Run which increases building speed when project is large. I believe there must be good solution to this problem in the future.

About Instant Run:
In Android Studio 2.3 and higher, Instant Run significantly reduces the time it takes to update your app with code and resource changes. After deploying your app to a target device running Android 5.0 (API level 21) or higher, you can click Apply Changes to push certain code and resource changes to your running app without building a new APK—and, in some cases, without even restarting the current activity.