Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Defined Methods and Referenced Methods in Android studio Apk Analyzer

One of the new features in android studio 2.2 preview 1 is APK Analyzer and when you try it it give you statistics Defined Methods and Referenced Methods

example output:

This dex file defines 4118 classes with 28823 methods,and references 35206 methods

like image 643
Moh'd Awad Avatar asked May 26 '16 12:05

Moh'd Awad


People also ask

How can I see all methods in Android Studio?

You can see the Structure tab below your Project tab in Android Studio. Open your file in editor and click on structure tab, it will show all the methods in the class selected.

What does an Android APK file contains explain any two components?

An APK file contains all of a program's code (such as . dex files), resources, assets, certificates, and manifest file. As is the case with many file formats, APK files can have any name needed, but it may be required that the file name ends in the file extension for being recognized as such.

What is APK analyzer in Android Studio?

Android Studio includes an APK Analyzer that provides immediate insight into the composition of your APK or Android App Bundle after the build process completes. Using the APK Analyzer can reduce the time you spend debugging issues with DEX files and resources within your app, and help reduce your APK size.


2 Answers

Defined methods are methods that you have written, or are using correctly based on the given situation. If a method is referenced, it only means that you (or other methods/objects in your code) are calling them. However, just because a method is referenced doesn't mean that their is anything defined for it, or it could be defined incorrectly. If example you're using open source libraries that may have been installed incorrectly (I have done this way too many times) you'll get a ton of referenced methods with nothing defined for them. Hope that helps!

like image 130
Mr. DROP TABLE Avatar answered Oct 24 '22 09:10

Mr. DROP TABLE


I know this is an old answer but I'll just paste a snippet of what both terms mean from the official website and what gets count toward the 64k limit.

Each package, class, and method inside the DEX file has counts listed in the Defined Method and Referenced Methods columns. The Referenced Methods column counts all methods that are referenced by the DEX file. This typically includes methods defined in your code, dependency libraries, and methods defined in standard Java and Android packages that the code uses—these are the methods counted toward the 64k method limit in each DEX file. The Defined Methods column counts only the methods that are defined in one of your DEX files, so this number is a subset of Referenced Methods.

Reference: https://developer.android.com/studio/build/apk-analyzer#view_dex_files

like image 3
Sagar Avatar answered Oct 24 '22 09:10

Sagar