1

What is the official source for apksigner as referenced e.g. in this answer? People are citing Android Studio, Android SDK Build Tools/Platform Tools/Command Line Tools etc. (as well as some shady archives on Google Drive), but non of these contain the program. I've downloaded, installed and searched them all.

Alternatively, what is the official source for Android SDK Build Tools 24.0.3, which allegedly contains the apksigner?

I've found an apksigner.jar and apksigner.bat inside a private Google repository, but running

apksigner verify --verbose --print-certs <APK file>
apksigner.bat verify --verbose --print-certs <APK file>
apksigner.jar verify --verbose --print-certs <APK file>

doesn't work (no output). This is the content of said batch file apksigner.bat:

@echo off
REM Copyright (C) 2016 The Android Open Source Project
REM
REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at
REM
REM     http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.

REM don't modify the caller's environment
setlocal

REM Locate apksigner.jar in the directory where apksigner.bat was found and start it.

REM Set up prog to be the path of this script, including following symlinks,
REM and set up progdir to be the fully-qualified pathname of its directory.
set prog=%~f0

rem Check we have a valid Java.exe in the path.
set java_exe=
if exist    "%~dp0..\tools\lib\find_java.bat" call    "%~dp0..\tools\lib\find_java.bat"
if exist "%~dp0..\..\tools\lib\find_java.bat" call "%~dp0..\..\tools\lib\find_java.bat"
if not defined java_exe goto :EOF

set jarfile=apksigner.jar
set "frameworkdir=%~dp0"
rem frameworkdir must not end with a dir sep.
set "frameworkdir=%frameworkdir:~0,-1%"

if exist "%frameworkdir%\%jarfile%" goto JarFileOk
    set "frameworkdir=%~dp0lib"

if exist "%frameworkdir%\%jarfile%" goto JarFileOk
    set "frameworkdir=%~dp0..\framework"

:JarFileOk

set "jarpath=%frameworkdir%\%jarfile%"

set javaOpts=
set args=

REM By default, give apksigner a max heap size of 1 gig and a stack size of 1meg.
rem This can be overridden by using "-JXmx..." and "-JXss..." options below.
set defaultXmx=-Xmx1024M
set defaultXss=-Xss1m

REM Capture all arguments that are not -J options.
REM Note that when reading the input arguments with %1, the cmd.exe
REM automagically converts --name=value arguments into 2 arguments "--name"
REM followed by "value". apksigner has been changed to know how to deal with that.
set params=

:firstArg
if [%1]==[] goto endArgs
set a=%~1

    if [%defaultXmx%]==[] goto notXmx
    if %a:~0,5% NEQ -JXmx goto notXmx
        set defaultXmx=
    :notXmx

    if [%defaultXss%]==[] goto notXss
    if %a:~0,5% NEQ -JXss goto notXss
        set defaultXss=
    :notXss

    if %a:~0,2% NEQ -J goto notJ
        set javaOpts=%javaOpts% -%a:~2%
        shift /1
        goto firstArg

    :notJ
    set params=%params% %1
    shift /1
    goto firstArg

:endArgs

set javaOpts=%javaOpts% %defaultXmx% %defaultXss%
call "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%
srhslvmn
  • 133
  • 1
  • 9

1 Answers1

0

I think the dl.google.com/android/repository/ is actually a sort of direct link to the contents of the official Android repository.
The SDK Tools repository can be found here:
https://android.googlesource.com/platform/tools/google_prebuilts/studio/sdk/remote/+/refs/heads/mirror-goog-studio-main/

To download a file from the repo, follow the links to the target file, then look at the very bottom right corner of the page for the links TEXT and JSON.
Note that essentially the links point to the current URL with a query format parameter like ?format=text or ?format=json.
Example
https://android.googlesource.com/platform/tools/google_prebuilts/studio/sdk/remote/+/refs/heads/mirror-goog-studio-main/dl.google.com/android/repository/build-tools_r34-rc3-windows.zip?format=JSON

  • if you use the TEXT link the file will be downloaded as a text file in base64 format
  • if you open the JSON link and inspect the file, there should be an URL pointing to dl.google.com for direct download of the target file.

It is also possible to download an entire directory by navigating to the target directory then clicking on the TGZ link as noted by this other answer here
https://stackoverflow.com/a/29537718/1262357


Above is the link to the current active main branch at the time of this writing, previous releases and branches can be found here (look at the left column marked red):

https://android.googlesource.com/platform/tools/google_prebuilts/studio/sdk/remote/

branches-list

Gruber
  • 2,196
  • 5
  • 28
  • 50