13

I have checked with my friend who has Android SDK tools version 21, the apkbuilder is there. I have updated the Android SDK tools to version 22 and I can't find apkbuilder anymore.

So it seems that the Andorid SDK tool has replace the apkbuilder with something else? How can I make ant build.xml without apkbuilder? Is there some other way to build the unsigned apk for Android?

Kromster
  • 7,181
  • 7
  • 63
  • 111
tommy cheung
  • 131
  • 1
  • 1
  • 3

6 Answers6

9

You may want to look at this.

After updating to SDK Tools to rev. 22 for the first time, you may need to relaunch Android SDK Manager again and install a new item: Android SDK Build-tools. enter image description here

After installing this, clean your projects and rebuild.

Community
  • 1
  • 1
Krauxe
  • 6,058
  • 2
  • 24
  • 22
6

In old version of AndroidSDK, the apkbuilder is just like a shell, actually it calls: ${sdk.dir}/tools/lib/sdklib.jar

So, if you deep into the root of apkbuilder, you can finder there are two ways to invoke it:

  1. from ant There is an ant-extend lib under: ${sdk.dir}/tools/lib/ant-tasks.jar So, you can invoke it like this:

    <path id="android.antlibs">
        <pathelement path="${sdk.dir}/tools/lib/ant-tasks.jar" />
    </path>
    
    <!-- Custom tasks -->
    <taskdef resource="anttasks.properties" classpathref="android.antlibs" />
    
    <apkbuilder
            outfolder="${out.absolute.dir}"
            resourcefile="${resource.package.file.name}"
            apkfilepath="${out.packaged.file}"
            debugpackaging="${build.is.packaging.debug}"
            debugsigning="${build.is.signing.debug}"
            verbose="${verbose}"
            hascode="${manifest.hasCode}"
            previousBuildType="${build.last.is.packaging.debug}/${build.last.is.signing.debug}"
            buildType="${build.is.packaging.debug}/${build.is.signing.debug}">
        <dex path="${intermediate.dex.file}"/>
        <sourcefolder path="${source.absolute.dir}"/>
        <jarfile refid="project.all.jars.path" />
        <nativefolder path="${native.libs.absolute.dir}" />
        <nativefolder refid="project.library.native.folder.path" />
        <extra-jars/>
    </apkbuilder>
    
  2. for script or other development You can use ${sdk.dir}/tools/lib/sdklib.jar, the apkbuilder was included in. Take a look at apkbuild.bat in previous version, at the end of the file:

    set jarfile=sdklib.jar
    set frameworkdir=
    
    if exist %frameworkdir%%jarfile% goto JarFileOk
        set frameworkdir=lib\
    
    if exist %frameworkdir%%jarfile% goto JarFileOk
        set frameworkdir=..\framework\
    
    :JarFileOk
    
    set jarpath=%frameworkdir%%jarfile%
    
    call %java_exe% -classpath %jarpath% com.android.sdklib.build.ApkBuilderMain %*
    
yunshan
  • 61
  • 1
  • 3
5

You could copy an apkbuilder.bat to your path_to_sdk_home/tools/, then continue you build. I found a copy here, and it worked.

liuyong
  • 987
  • 10
  • 19
2

Android SDK notes for rev.22 state:

Changed the structure of the SDK by adding a new build tool SDK Component, which is based on the existing platform-tools component. This change decouples the build tools versions from the IDE versions, allowing updates to the tools without requiring an IDE update.

One of the temporary options is to roll back your SDK tools back to rev.21 where apkbuilder existed. You can do that by backing up tools folder (e.g. rename it to tools_22) and downloading previous tools from rev.21: dl-ssl.google.com/android/repository/tools_r20-windows.zip, unpack it to your SDK and it will work like before.

Kromster
  • 7,181
  • 7
  • 63
  • 111
  • THX.Iwant to find a way to edit my build.xml to fit the new version tool .Or should i change builder to gradle or sth else? – tommy cheung May 19 '13 at 10:55
  • In the case that will not roll back my sdk tool verison 21?In fact i want to know how build the apk in tools version 22?The sugest way? – tommy cheung May 19 '13 at 10:58
  • I know only of this solution. Maybe someone else knows a better way around rev.22 – Kromster May 19 '13 at 13:50
1

Doing a bit of research around this, it seems APKBuilder.bat, although deprecated, can still be used but will no longer be supported/enhanced. [1]

The new com.android.sdklib.build.APKBuilder Java class should now be used [2] as this is what will be developed, going forward.

Steven Mark Ford
  • 3,372
  • 21
  • 32
  • See liuyong's answer for a link to the bat. – Steven Mark Ford Jul 24 '13 at 10:08
  • It indeed appears as if the script has been removed. For now, using an old version works because the command line interface still exists as part of the Java class, though I wouldn't be surprised if that goes as well. – miracle2k Aug 04 '13 at 14:59
0

I find a way but i don't very sure of it. I saw a ant directory in tools directory and found a build.xml contains the new way to build apk. I also saw ant_task.jar in the tools/lib directory.When i unzip the jar i fount some classes like Apk ApkBuilderTask.class CheckEnvTask.class and so on... So i think the way is be changed to build apk with the ant Task,i 'll try to use the template to build the apk ,and if it works i will post the solution here. thanks!

tommy cheung
  • 131
  • 1
  • 1
  • 3
  • You can recreate your project build.xml to use the new method but running "android update project -p ." in your project directory. – Lionel Port Jun 07 '13 at 03:12