Android: How to set the name of the compiled APK? - android

This question seems embarassingly simple, yet it vexes me still. I am using the standard ADT and Eclipse Android environment to build my Android app. The apk is named after the project name in Eclipse, but I want to name the apk something different...How can I customize the name of the apk artifact that is produced when the project builds?

android update project --name your_desired_name --path .
ant debug

You can also just edit the build.xml as following:
<project name="YourNewProjectNameHere" ...
if you are building with "ant" on the command line. Otherwise, Eclipse will always use your official ProjectName when create an apk. However, you can override that by right-clicking on project, and selecting Android Tools->Export Signed Application Package; which will then allow you to specify your own name for the package.

I am very surprised that there apparently is no way to do this, but alas I found that when finally exporting a signed apk file through eclipse you can specify the name of the APK. So that solves my problem.

Please Try This...
Please First Change \android-sdk\tools\ant\build.xml for signed release apk
These changes are onetime in build.xml because of this file every time use with your project build.xml to generate apk
<property name="out.final.file" location="${out.absolute.dir}/${ant.project.name}-release.apk" />
By
<property name="out.final.file" location="${out.absolute.dir}/${ant.project.name}.apk" />
Then execute command :
android update project --name your_desired_name --path .
ant release
Release APK Created in directory YourProjectName\bin by name :
your_desired_name.apk

If you just want to change the apk's name that appears on the smartphone's screen, you just need to go to click your project > res > values > string.xml then on app_name field inside the >< renamed the apk's name as you want.

Related

Where is the release apk file for cordova apps in Visual Studio 2015

I have created a certificate file using keytool command line. then i have updated ant.properties file ( under res -> native -> android) by adding the information i have set in the certificate file.
also, i have copied the certificate file in the same folder of ant.properties.
I followed the steps as mentioned in MSDN here:
https://msdn.microsoft.com/en-us/library/Dn757048.aspx
When i build in release mode in Visual Studio 2015, i don't see a release apk generated in the solution folder or inside the bin.
any help is appreciate it.
To generate the release apk file in Visual studio, follow these steps:
1) Select Release build option.
2) Select Android from the solution platform options.
3) Select Device "This is a must step".
4) Right click on your project and Build the cordova app.
5) Check out Release folder in (ProjectFolder/bin/Android).
6) you will find your release apk file.
If you build in command line with devenv.exe /build, you must have done this one time in order to work fine.
If you don't want to launch VS, you can add this line in your projectCordova.jsproj.user file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Android'">
<DebuggerFlavor>AndroidEmulator</DebuggerFlavor>
<AndroidEmulatorID>AndroidDevice;Device</AndroidEmulatorID>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Android'">
<DebuggerFlavor>AndroidEmulator</DebuggerFlavor>
<AndroidEmulatorID>AndroidDevice;Device</AndroidEmulatorID>
</PropertyGroup>
</Project>

Signing APK file in Cordova v-5.0 CLI is not working

i tried to add keystore properties into two files in the platforms/android directory.
key.store=Users/admin/workspace/android-keystore/keystore
key.alias=keystore
into
ant.properties
and
project.properties
File.
It worked fine in previous version, but not seems like the Cordova does not using ant in latest version.
So if i run command:
cordova build android --release
I always get only unsigned apk.
platforms/android/build/outputs/apk/android-release-unsigned.apk
How can i solve it please?
Many thanks for any help.
Because cordova now uses gradle, you need to create a file called release-signing.properties in your platforms/android/ directory
The settings looks like:
storeFile=relative/path/to/keystore.p12
storePassword=SECRET1
storeType=pkcs12
keyAlias=DebugSigningKey
keyPassword=SECRET2
You can also use JKS files:
storeType=jks
storeFile=mykeystore.keystore
For more information see:
https://cordova.apache.org/docs/en/edge/guide_platforms_android_tools.md.html
Here is what I use:
storeType=jks
storeFile=/absolute/path/to/my/file.keystore
storePassword=mypassword1
keyAlias=myaliasname
keyPassword=mypassword2

Apk location in New Android Studio

I started using new Android Studio and cant find the APK of the application in IDE,where it actually locates?
To help people who might search for answer to this same question, it is important to know what type of projects you are using in Studio.
Gradle
The default project type when creating new project, and the recommended one in general is Gradle.
For a new project called "Foo", the structure under the main folder will be
Foo/
settings.gradle
Foo/
build.gradle
build/
Where the internal "Foo" folder is the main module (this structure allows you to create more modules later on in the same structure without changes).
In this setup, the location of the generated APK will be under
Foo/Foo/build/apk/...
Note that each module can generate its own output, so the true output is more
Foo/*/build/apk/...
EDIT
On the newest version of the Android Studio location path for generated output is
Foo/*/build/outputs/apk/...
IntelliJ
If you are a user of IntelliJ before switching to Studio, and are importing your IntelliJ project directly, then nothing changed. The location of the output will be the same under:
out/production/...
Note: this is will become deprecated sometimes around 1.0
Eclipse
If you are importing Android Eclipse project directly, do not do this!
As soon as you have dependencies in your project (jars or Library Projects), this will not work and your project will not be properly setup.
If you have no dependencies, then the apk would be under the same location as you'd find it in Eclipse:
bin/...
However I cannot stress enough the importance of not doing this.
I am on Android Studio 0.6 and the apk was generated in
MyApp/myapp/build/outputs/apk/myapp-debug.apk
It included all libraries so I could share it.
Update on Android Studio 0.8.3 Beta. The apk is now in
MyApp/myapp/build/apk/myapp-debug.apk
Update on Android Studio 0.8.6 - 2.0. The apk is now in
MyApp/myapp/build/outputs/apk/myapp-debug.apk
There is really no reason to dig through paths; the IDE hands it to you (at least with version 1.5.1).
In the Build menu, select Build APK:
A dialog will appear:
If you are using a newer version of Android Studio, it might look like this:
Clicking the Show in Explorer or locate link, you will be presented with a file explorer positioned somewhere near wherever Android Studio put the APK file:
But in AS 3, when you click locate, it puts you at the app level. You need to go into the release folder to get your APK file.
In my case, I'm using Android Studio 1.0.2, I get my APK file from:
<myAndroidProject>/app/build/outputs/apk/app-debug.apk
If anyone would be missing his APK and couldn't find it in the locations stated in other answers (I found this question, since I couldn't find it either) it might just be in this folder (mine was)
<project folder>/target/classes/<appname>.apk
I also had a there this file:
<appname>.unaligned.apk
I am not perfectly sure, whether the apk is actually the full-blown apk, which should be generated, but I tried it on various devices (not only the target device, but also those which were supporting only the minimum SDK) and it worked.
Hope this will help someone.
It is Project_Location/app/build/outputs/apk for Gradle Project
Find apk using below step:-
Goto to your project folder.
Open project folder.
Open build folder.
Open output folder.
Open apk folder.
Now you see your apk.
hope it will help some body.
So the apk in Android studio is generated inside build folder of app module.
Correct path to apk would be \app\build\outputs\apk. I am using Android Studio Version 1.4.1. So apk could either be found at app/build/apk/ or \app\build\outputs\apk base on the version of Android studio you are using. Refer the below image
Also find more reference on these links.
Building and Running from Studio
Studio Project Overview
I'm using Android Studio and gradle.
It created the build/apk/<.apk> file only when I ran the project.
Press the following to run your project: Alt+u, u
Android Studio: 0.5.3
Gradle: 0.9.+
You can find the APK in:
YourProject\app\build\outputs\apk
The .apk file is located at [your project]\out\production\[your project name]
In the new Android Studio, the signed apk is placed directly in the folder of module for which the apk is built.
For example: For a Project ProjectA containing 2 modules Mod1 and Mod2, the apk files will be found in
/path-to-ProjectA/Mod1/Mod1.apk
/path-to-ProjectA/Mod2/Mod2.apk
Image for APK location in Android Studio
Location of apk in Android Studio:
AndroidStudioProjects/ProjectName/app/build/outputs/apk/app-debug-unaligned.apk
As of version 0.8.6 of Android Studio generating an APK file (signed and I believe unsigned, too) will be placed inside ProjectName/device/build/outputs/apk
For example, I am making something for Google Glass and my signed APK gets dropped in /Users/MyName/AndroidStudioProjects/HelloGlass/glass/build/outputs/apk
I got the .apk files in
parent_folder/out/production/projectname/projectname.apk
Build your project and get the apk from your_project\app\build\apk
You can find your apk file as follow:
yourproject>app>build>output>apk>yourproject.apk
The Android build system is the toolkit you use to build, test, run
and package your apps. The build system can run as an integrated tool
from the Android Studio menu and independently from the command line.
You can use the features of the build system to:
Customize, configure, and extend the build process.
Create multiple APKs for your app with different features using the
same project and modules.
The build process involves many tools and processes that generate intermediate files on the way to producing an .apk. If you are developing in Android Studio, the complete build process is done every time you run the Gradle build task for your project or modules.
The build process is very flexible so it's useful, however, to understand what is happening under the hood since much of the build process is configurable and extensible. The following diagram depicts the different tools and processes that are involved in a build:
Build a release version
You can now use the Build menu options to build the release version of your application for distribution.
The build generates an APK for each build variant: the app/build/apk/ (or app/build/outputs/apk) directory contains packages named app--.apk; for example, app-full-release.apk and app-demo-debug.apk.
Build output
The build generates an APK for each build variant in the app/build folder: the app/build/outputs/apk/ directory contains packages named app--.apk; for example, app-full-release.apk and app-demo-debug.apk.
Courtesy goes to Build System Overview
I am using Android Studio 3.0 canary 6.
To build apk,
Click to Build->Build APK(s).
After your apk is build, Go to:
C:\Users\your-pc-name\AndroidStudioProjects\your-app-name\app\build\outputs\apk\debug
If you have imported a Project from Eclipse and are using the new Android Studio
The directory
/bin
does exist (there maybe old binaries in here) however with the latest Android Studio update the actual current apk is stored in
/out/production
Add this in your module gradle file. Its not there in default project. Then u will surely find the APK in /build/outputs/apk/
buildTypes {
debug {
applicationIdSuffix ".debug"
}
}
open Event Log
find line: Module 'app': locate or analyze the APK.
click on locate link to open folder with apk file!
After all: "All built APKs are saved in project-name/module-name/build/outputs/apk/ Build your project LINK
Hint: If you canĀ“t see the app-debug.apk in your debug folder, you have to click on BUILD --> Rebuild Project in Android Studio.
To create apk in android studio,go to build menu->build bundles/apk->build apk
it will make the apk file of your project.After this the apk will be available in your
project directory->app->build->outputs->apk->debug->app-debug.apk
Click on Build-Build Bundles/Apks-Build Apk.
A notification will which shows app location when you click on 'locate' on the notification.
If you have already done creating apk, goto : C:\Users\\AndroidStudioProjects\\app\build\outputs\apk\debug
For Gradle look here: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.SourceSetOutput.html.
"For example: Java plugin will use those dirs in calculating class paths and for jarring the content; IDEA and Eclipse plugins will put those folders on relevant classpath."
So its depend on plugin build in configs unless you don't define them explicit in config file.
Click the little gear icon in the project view and make sure "show excluded files" is checked. Otherwise, the IDE will hide output and several other important directories under $project/$module/build/.
Hello all above all answers are right you can find the apk through the path in android studio but there is exceptions you can't find the build/output
folder some times if you can't see it just go to
app--> app.iml file and find below line in it :-
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
--> after removing this line you can see the output folder its just the adding more information to above answers as per my experience :)
THANKS!~!
For Android Studio 2.0
C:\Users\UserName\AndroidStudioProjects\MyAppName\app\build\outputs\apk
Here
UserName is your computer user name and
MyAppName is your android app name
As of Android Studio 3.0 / Gradle Build Tools 3.0.0, APK artifacts can now be found in foo/bar/build/outputs/apk/flavorName/buildType with respect to your project name, foo, and your module name, bar. There is now a directory for each apk file sorted organized first by flavor (with respect to flavor dimensions) and then by build type.

Ant- Android building not create release version

I've created a android project using eclipse. But I needs to do that same using command line. So, I use below command
> android update project --path .
> ant clean debug
Using above command its created-- Welcome-debug.apk and WelCome-debug-unaligned.apk
I also write the ant.properties file below-
key.store=./mykey.keystore
key.alias=MA
key.store.password=mypassword
key.alias.password=mypassword
now when I tried to build release version-
> ant relase
Unfortunately its not creating any release file. How do i create the release version using command line.
Expecting your response.
Thanks,
Pijman
You have a typo: it should be ant release.
You don't need to do anything specific. ant clean release should do the trick. However, note the clean target: ant is lazy and is trying to skip as much of the work as possible - thus if you do not clean it will not recreate the class files and you will actually pack an apk featuring the debug compiled files.

Android ant build: how to run android upload and not update build.xml, proguard.cfg

I am running the standard ant script build.xml which gets created when you run the android create project command. In order to verify my local.properties is set correctly, I added a task at the beginning of the build.xml script to run the command:
android update project -p .
I now get the following message each time I run the ant script, which clobbers my build.xml file and creates a proguard.cfg file!
File build.xml is too old and needs to be updated
So, I moved the ant script to a different file that won't get clobbered.
Is there a way to run the command android update project -p . that doesn't clobber build.xml and create proguard.cfg?
I think this is a bug. I have registered a new bug with Google here:
http://code.google.com/p/android/issues/detail?id=17825
If anyone else thinks it's a bug, then please star it and perhaps contribute your thoughts.
Workaround for this. Add the following code in build.xml.
<!-- The following will prevent for 'android' tool to overwrite this file.
(until sdk r12)
classname="com.android.ant.SetupTask"
(since sdk r13 FIXME)
version-tag:custom
-->
With the piece of comment, 'android update project' will not complaint or overwrite the build.xml.
As of now, there might be chance for changes in r13.
sdk r13 not yet released
it's based on aosp/master branch
updateProject() in package com.android.sdklib.internal.project.ProjectCreator determine to update the build.xml or not.
(The code from sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java)
The build.xml generated by android has the following comment:
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
so, it looks like Atham is right.

Categories

Resources