问题
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
回答1:
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!
回答2:
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
来源:https://stackoverflow.com/questions/37461328/what-is-the-difference-between-defined-methods-and-referenced-methods-in-android