Unity Client

Unity Native: Android Studio Tools

By Artem Glotov

In this article I will mention several Android Studio tools that are useful for Unity developers.

Analyze APK

Analyzing an APK is useful when you want to check the contents of .apk, .aab, .arr, or .jar archive files. It can be employed to verify if the archive actually contains specific classes, files, or resources, or to review the final AndroidManifest.xml file.

To analyze an archive, open it in Android Studio via the Build -> Analyze APK menu item.

For instance, in an .apk file, you can review compiled Java/Kotlin classes in *.dex files, resources in the resources.arsc file, and the contents of the AndroidManifest.xml file.

Analyzing Dependencies

Analyzing dependencies is useful when you want to check which version of a library was requested and resolved for each dependency. For example, you can check if there are any conflicts between library versions.

  1. Export your project via the File -> Build Settings -> Export menu item in the Unity Editor
  2. Open the exported project in Android Studio
  3. Open the Gradle tab in the right panel

Dependencies Task

If you are interested in requested and resolved dependencies, double-click on the Android -> UnityLibrary -> Tasks -> Help -> dependencies task in the Gradle tab.

In the console output, find the result for the releaseRuntimeClasspath configurations. Here you can see which version of a library was requested and resolved for each dependency.

releaseRuntimeClasspath - Resolved configuration for runtime for variant: release
+--- androidx.recyclerview:recyclerview:1.2.1
|    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    +--- androidx.core:core:1.3.2 -> 1.7.0
|    |    +--- androidx.annotation:annotation:1.2.0 -> 1.3.0
|    |    +--- androidx.annotation:annotation-experimental:1.1.0
|    |    +--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.4.0
|    |    |    +--- androidx.arch.core:core-runtime:2.1.0
|    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    \--- androidx.arch.core:core-common:[2.1.0] -> 2.1.0
|    |    |    |         \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    +--- androidx.lifecycle:lifecycle-common:2.4.0
|    |    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    +--- androidx.arch.core:core-common:2.1.0 (*)
|    |    |    \--- androidx.annotation:annotation:1.1.0 -> 1.3.0

Analyze Dependencies Button

If you are interested only in resolved dependencies, you can use the Analyze Dependencies button in the Gradle tab, which will open the Dependency Analyzer window with a resolved dependencies tree.

Summary

Now you know how to analyze the contents of .apk, .aab, .arr, or .jar archive files and how to check Android dependencies.



Tags