怎麼檢視APK的方法數

2021-07-22 05:17:39 字數 2371 閱讀 7741

網上找的乙個指令碼,電腦系統為windows 親測 好用。

將下面兩個檔案printhex.ps1、dex-method-count.bat拷貝到乙個資料夾下,檔案名字和字尾都不要變,然後將需要檢測的classes.dex檔案也放在這個資料夾下

開啟命令列並切到當前目錄下,執行命令

dex-method-count.bat

classes.dex

會輸出結果

counting methods in dex file classes.dex

number of methods is 63952

方法數沒有超過65535個就可以啦,不然就要分包了

printhex.ps1

<#

.synopsis

outputs the number of methods in a dex file.

.parameter path

specifies the path to a file. wildcards are not permitted.

#>

param(

[parameter(position=0,mandatory=$true)]

[string] $path

)if ( -not (test-path -literalpath $path) )

$item = get-item -literalpath $path -force

if ( -not ($? -and ($item -is [system.io.fileinfo])) )

if ( $item.length -gt [uint32]::maxvalue )

$stream = [system.io.file]::openread($item.fullname)

$buffer = new-object byte 2

$stream.position = 88

$bytesread = $stream.read($buffer, 0, 2)

$output = $buffer[0..1]

#(" ") -f $output

$outputdec = $buffer[1]*256 + $buffer[0]

"number of methods is " + $outputdec

$stream.close()

dex-method-count.bat

@echo off

if "%1"=="" goto missingfilenameerror

ifexist "%1" (goto continueprocessing) else (goto filedoesntexist)

:continueprocessing

set filenametoprocess=%1

set filenamefordx=%~n1.dex

if "%~x1"==".dex" goto processwithpowershell

rem preprocess jar with dx

if "%~x1"==".jar" (

echo processing jar %filenametoprocess% with dx!

call dx --dex --output=%filenamefordx%

%filenametoprocess%

set filenametoprocess=%filenamefordx%

iferrorlevel

1goto dxprocessingerror

):processwithpowershell

echo counting methods in dex file %filenametoprocess%

call powershell -noexit -executionpolicy bypass "& ".\printhex.ps1" %filenametoprocess%

goto end

:missingfilenameerror

@echo missing filename for processing

goto end

:dxprocessingerror

@echo error processing file %1% with dx!

goto end

:filedoesntexist

@echo file %1% doesn't exist!

goto end

:end

如果是計算乙個開源庫的方法數,可以訪問下面這個**

檢視APK的簽名的方法

1 檢視 keystore keytool list keystore debug.keystore 結果 keystore type jks keystore provider sun your keystore contains 1 entry androiddebugkey,mar 21,20...

Android Studio 檢視總方法數

背景 由於android方法數超過65535就需要分包,需要multidex,有些機器對multidex支援不好導致啟動特別慢需要多花費3 10s時間,看下工程方法數具體是多少 classpath com.getkeepsafe.dexcount dexcount gradle plugin 0.6...

apk反編譯 檢視已有apk的簽名

1.工具的安裝 檔案儲存到c windows下時需要管理員許可權 2.反編譯apk 在剛才的終端介面,輸入 apktool d test.apk o test 解釋 test.apk為要反編譯的檔案,test為編譯後的資料夾名稱,根據需要修改,如果apk不在當前資料夾下,需要在apk前附上位置,如c...