Although the docs mentioned
If you haven't already done so, download bundletool from the GitHub
repository.
However, the repo contains only a jar file. How do I install it so that I can run with the 'bundletool' command just like the docs' example?
If you have brew installed simply run brew install bundletool and the alias will be set up for you as well. It did the trick for me.
You can create an alias (or doskey on Windows), e.g.
alias bundletool='java -jar bundletool-all.jar'
Another alternative is access Bundletool release page and download the bundletool-all-[LAST-VERSION].jar file into some directory.
After that you could run it on the directory calling:
java -jar bundletool-all-0.10.2.jar your_arguments_here
If you want, rename the jar file to bundletool.jar, then run it calling:
java -jar bundletool.jar your_arguments_here
If you don't want call java every time, you can create an alias for that, and after that run quicly:
alias bundletool='java -jar bundletool-all.jar'
bundletool your_arguments_here
On a mac, it can be easily done using homebrew
brew install bundletool
then you can run commands like this
bundletool install-apks --apks=release.apks
you can use the command below to generate apks
bundletool build-apks --bundle=aab_path.aab --output=release.apks
The above command generates apks file which can later be extracted to give various apk files.
To make shortcut/alias in Windows 10, in cmd run:
#doskey bundletool=java -jar <youPath>\bundletool-all.jar $*
You must be already added Java folder path to system environment variables or just google it.
Apparently for Linux you have to download the jar from: https://github.com/google/bundletool/releases
and then run java -jar <PATH_TO_JAR> ...
to simplify things you can add in /usr/local/bin/ a bundletool script
#!/usr/bin/env zsh
exec java -jar "$HOME/path/to/jar" "$#"
and sudo chmod +x /usr/local/bin/bundletool
Now you can run bundletool from wherever you want
As for me, on windows, I just set assoc and ftype so that .jar will open with java -jar
First I download bundletool.someversion.jar into some folder under PATH env (so that it would exposed)
Open cmd as admin and link .jar to jarfile with cmd assoc .jar=jarfile (actually can be any name, make it jarfile is just convention in the same way as other file)
Then ftype jarfile=^%JAVA_HOME^%\bin\java.exe -jar %1 %~2
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/ftype
Then we could execute bundletool.someversion.jar or any jar to open it as java directly
You don't need to have
brew.
Install it somewhere, but not in your project directory
npm install bundletool
Related
What I am trying to do: I am trying to install ktlint on windows locally
What I tried:
Used below command in command prompt
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.38.1/ktlint && chmod a+x ktlint
Also tried above command by using in below steps in link
https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/
What is happening: Not able to install in windows.
How to install in windows ?
I was having trouble installing ktlint for Windows 10. What worked for me was going to the Releases page, downloading the ktlint file, renaming the ktlint file to ktlint.jar and adding it inside my Android project root folder (in reference to this GitHub issue) (Note: Java must be installed so that the file extension can be recognized), then running java -jar ktlint.jar --apply-to-idea-project (in the command line, from the Android project root directory). Then finally I was able to get it to work, resulting in the following text:
The following files are going to be updated:
.\.idea\codeStyles\codeStyleConfig.xml
.\.idea\codeStyles\Project.xml
.\.idea\inspectionProfiles\profiles_settings.xml
.\.idea\inspectionProfiles\ktlint.xml
.\.idea\workspace.xml
Do you wish to proceed? [y/n]
(in future, use -y flag if you wish to skip confirmation)
y
(updated)
Please restart your IDE
(if you experience any issues please report them at https://github.com/shyiko/ktlint)
Without updating the file to have the .jar extension and adding .jar to the filename command line parameter, I kept getting the following error:
Error: Unable to access jarfile ktlint
To run ktlint immediately, run java -jar ktlint.jar in the command line (in the directory where the ktlint.jar file resides).
You can install a git hook to automatically check files for style violations on commit by entering the following command in the Command Line (run "ktlint installGitPrePushHook" if you wish to run ktlint on push instead):
java -jar ktlint.jar installGitPreCommitHook
But this will only allow you to set hook for your current command line session. If you close out of Command Prompt, the settings will be reset. If you want to have the ktlinter run on every session for your project, you have to add the java -jar ktlint.jar command to your project's .git/hook/pre-commit file and paste the ktlint.jar file into the .git/hook folder as well.
Download the ktlint jar ffile from the lib and add it in your project
Run java -jar ktlint on the command line
From that point and then gradlew ktlintCheck should work
I am working on Kivy framework. I have some sample of Kivy which has .py extension which I want to convert to .apk files. I want to check whether these working on Android or not.
I have some information about this. We have two ways to build an .apk file:
Using Python for Android,
Using Buildozer.
But Buildozer is only supported on Linux. I thought it has some problems on Windows.
Hence, I want to use Python for Android. But I have no idea how to approach this one.
Have anyone tried this one.
You can use VirtualBox Get it here and any Linux Distribution such as Ubuntu Ubuntu.
After installing Ubuntu to your Virtualbox you can use below commands:
Run these commands on Terminal
sudo apt install git
sudo apt install python3-pip
git clone https://github.com/kivy/buildozer.git
cd buildozer
sudo python3 setup.py install
Now, navigate to your project directory using cd (or) goto your Project directory, RightClick -->select 'Open in terminal' and in Terminal type:
buildozer init
Above Command creates a buildozer.spec file controlling your build configuration. You should edit it appropriately with your app name, file extensions used in the project, external dependencies etc. After configuring your buildozer.spec fille run below commands:
sudo apt update
sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev
pip3 install --user --upgrade Cython==0.29.19 virtualenv # the --user should be removed if you do this in a venv
sudo pip3 install cython #(optional) If you got any Error as Cython not Found, use this
which buildozer
Above command is to check buildozer was added to your PATH), If no results found, add the following line at the end of your ~/.bashrc file--> export PATH=$PATH:~/.local/bin/
buildozer appclean
buildozer android debug
If you are asked for any licence agreement type y and click Enter
Once this process completes you will get a .apk file in your project directory bin/yourapp.apk
Kivy themselves used to have a virtual machine prepared with everything installed ready to go!
For some reason they stopped, now you have to install the Virtual Machine yourself.
You can see how to do this here
here is a link you can find everything that is related to getting .Apk files
https://python-for-android.readthedocs.io/en/latest/quickstart/#usage
Is there any way to generate an apk file from an Android Application Bundle (aab) via Terminal or using Android Studio?
So far nobody has provided the solution to get the APK from an AAB.
This solution will generate a universal binary as an apk.
Add --mode=universal to your bundletool command (if you need a signed app, use the --ks parameters as required).
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
--mode=universal
MAIN STEP: Change the output file name from .apks to .zip
Unzip and explore
The file universal.apk is your app
This universal binary will likely be quite big but is a great solution for sending to the QA department or distributing the App anywhere other than the Google Play store.
By default, the IDE does not use app bundles to deploy your app to a
local device for testing
Refer bundletool command
For Debug apk command,
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
For Release apk command,
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
--ks=/MyApp/keystore.jks
--ks-pass=file:/MyApp/keystore.pwd
--ks-key-alias=MyKeyAlias
--key-pass=file:/MyApp/key.pwd
Edit:
I have been using following commands while testing my release build for aab:
Download bundletool jar file from Github Repository (Latest release > Assets > bundletool-all-version.jar file). Rename that file to bundletool.jar
Generate your aab file from Android Studio eg: myapp-release.aab
Run following command:
java -jar "path/to/bundletool.jar" build-apks --bundle=myapp-release.aab --output=myapp.apks --ks="/path/to/myapp-release.keystore" --ks-pass=pass:myapp-keystore-pass --ks-key-alias=myapp-alias --key-pass=pass:myapp-alias-pass
myapp.apks file will be generated
Make sure your device is connected to your machine
Now run following command to install it on your device:
java -jar "path/to/bundletool.jar" install-apks --apks=myapp.apks
Edit 2:
If you need to extract a single .apk file from the .aab file, you can add a extra param --mode=universal to the bundletool command:
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks \
--mode=universal \
--ks=/MyApp/keystore.jks \
--ks-pass=file:/MyApp/keystore.pwd \
--ks-key-alias=MyKeyAlias \
--key-pass=file:/MyApp/key.pwd
and execute
unzip -p /MyApp/my_app.apks universal.apk > /MyApp/my_app.apk
this will generate a single a /MyApp/my_app.apk file that can be shared an installed by any device app installer
Ok here is the complete way I had to do:
Download bundletool-all-0.10.3.jar from this link, download the latest version available
Create an app bundle using android studio and locate its path:
In my case its E:\Projects\Android\Temp\app\build\outputs\bundle\debug\app.aab
Copy the bundletools jar to some location and get its path
In my case its E:\Temp\bundletool-all-0.6.0.jar
Use this command:
java -jar "BUNDLE_TOOL_JAR_PATH" build-apks --bundle="BUNDLE_PATH" --output=YOUR_OUTPUT_NAME.apks
In my case it will be
java -jar "E:\Temp\bundletool-all-0.6.0.jar" build-apks \
--bundle="E:\Projects\Android\Temp\app\build\outputs\bundle\debug\app.aab" \
--output=out_bundle_archive_set.apks
This will create a file out_bundle_archive_set.apks , rename it to .zip out_bundle_archive_set.zip , extract this file and done You will have multiple apk files
To install directly on external device use :
java -jar "E:\Temp\bundletool-all-0.6.0.jar" install-apks --apks=out_bundle_archive_set.apks
Check this blog post for more info . also check out official site
People have already explained on how to do this with the command-line. For completion, I thought I'd also show the way to do it via the UI in Android Studio.
When you open your "Run/Debug Configurations", you can select "APK from app bundle" (instead of "Default APK").
See screenshot:
Refer Geek Dashboard for more info.
For those who are looking to generate a single universal APK file from your Android App Bundle, you must use --universal flag while running the build-apks command.
java -jar bundletool.jar build-apks --bundle=your_app.aab --output=your_app.apks --mode=universal
Where
bundletool.jar is the bundletool jar file you downloaded here
your_app.aab is the Android App Bundle of your App
your_app.apks is the output APKs Archive File that will be generated once you run the command.
While running the above command make sure you place bundletool.jar and your AAB file in the same folder.
Now, you need to change the your_app.apks file format to your_app.zip and extract it to find the universal.apk file
Note: Use –overwrite flag to overwrite the APKs file if there is already one with the same name. Otherwise, bundletool command will throw you a fatal error.
on mac it can be easily done using homebrew
brew install bundletool
you can use the command below to generate apks
bundletool build-apks --bundle=aab_path.aab --output=release.apks
above command generates apks file which can later be extracted to give various apk files. To see all generated files change the extension from .apks to .zip and just extract the files.
then you can install apk using this command on connected device
bundletool install-apks --apks=release.apks
There's a tool called bundletool, which can create APK's out of your AAB file:
Find details about this tool here: https://developer.android.com/studio/command-line/bundletool
But here some highlights taken from that site:
Building APKs
When bundletool generates APKs from your app bundle, it includes them in a container called an APK set archive, which uses the .apks file extension. To generate an APK set for all device configurations your app supports from your app bundle, use the bundletool build-apks command, as shown below:
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
Note that the command above creates an APK set of unsigned APKs. If you want to deploy the APKs to a device, you need to also include your app’s signing information, as shown in the command below.
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
--ks=/MyApp/keystore.jks
--ks-pass=file:/MyApp/keystore.pwd
--ks-key-alias=MyKeyAlias
--key-pass=file:/MyApp/key.pwd
Installing APKs
bundletool install-apks --apks=/MyApp/my_app.apks
Generate a device-specific set of APKs
bundletool build-apks --connected-device --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
I have developed a windows tool for converting .aab files to .apk in Python.
It supports creating both debug and signed apk which can be directly installed to default android device connected through USB.
It uses google’s bundle tool in the backend.
https://aabtoapkconverter.com/
Edit:
The Source code is now available now on github.
This is first tool that I have developed and shared with the world. Hope it is useful. I am open to suggestions and bug reports.
Here is what i did.
First thing is, i am on a Mac.
So in this official guide https://reactnative.dev/docs/signed-apk-android, followed below steps.
Run this command sudo keytool -genkey -v -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
you can change the name of my-upload-key to your choice
Setup the gradle variables as per the guide
Also do the same as per the guide for point "Adding signing config to your app's Gradle config"
Now rather than continuing (which will generate an AAB file) what you can do is below.
4.1 I open the same project(android folder) in Android Studio
4.2 From the Menu Options > Build > Clean Project
4.3 Click on the Make Project button and let it complete (if you can run using npm run android, then this should finish without any issues)
Make Project
4.4 Once done, click on Menu options > Build > Generate Signed Bundle/APK...
Generate Signed Bundle/APK...
4.5 In the next Screen Choose APK radio button and Click Next
Choose APK option
4.6 In the next screen, Browse to the keystore file which you generated as the first step, its password, alias name and its password, click Next.
Final Step
Wait for it to complete. You may see some errors but more importantly in the end you should get a popup in the right bottom corner saying "Locate". Click on that and you will find your app-release.apk.
I think this method much more efficient
As mentioned in Bundletool Documentation
I'm giving following command on Android Studio terminal:
bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
I'm getting following error:
'bundletool' is not recognized as an internal or external command,
operable program or batch file.
I've downloaded the bundletool 0.6.0 jar
On bundletool github, there are no steps given to install it on windows.
Execute bundletool from the command line as follows. Make sure paths to java/bundletool/aab/jks are set and correct.
java -jar bundletool-all-0.6.0.jar build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks --ks=keystore.jks --ks-key-alias=key0
For those who are looking to generate a universal APK from the .aab file on mac, you can use the below steps
Use the following command to generate the '.apks' file from the '.aab' file:
java -jar bundletool-all-1.1.0.jar build-apks --bundle=/path_to_aab/myapp.aab --output=/path_to_aab/myapp.apks --mode=universal
Rename the myapp.apks file to myapp.zip
Unzip and you will find universal apk
I have been trying to get my head around using uiautomator and I understand creating the test cases. I tried the first two steps of building the JAR according the the Android developer guide for UI Testing (http://developer.android.com/tools/testing/testing_ui.html) and that worked fine, but I am unsure on how to follow the next steps and building the JAR file with ant. Please can anyone help me with this issue.
Here are the steps that I have done so far:
<android-sdk>/tools/android create uitest-project -n <name> -t 1 -p <path>
set ANDROID_HOME=<path_to_your_sdk>
This is the step that I am stuck on:
ant build
The error I get when I use the command prompt is:
'ant' is not recognized as an internal or external command, operable program or batch file.
In the terminal run
which ant
It seems you do not have ant installed. If no location like /usr/bin/ant shows up after you run the command above, use this to install it:
sudo apt-get install ant
Try again after. It should work.
If you're using ADT, I recommend downloading Apache ant and placing it within the sdk/tools/ant folder. Then change your PATH variable to direct to the ant bin folder.
you have this error because you wrote "ant build" from incorrect path.
I did (this command generate build.xml, local.properties, project.properties files):
<android-sdk>/tools/android create uitest-project -n <name> -t 1 -p <path>
I changed in build.xml first line like:
<project name="name" default="build">
after that I run ant from eclipse. Build was success.
Have you installed ant? If not then do it from this site: http://ant.apache.org/manual/install.html
If yes then follow these steps:
Navigate to your project directory and means (go to bin of your project)
Using command window execute the function: ant build
Ensure that your default JAVA_HOME points to JDK installation, not the JRE, and check if your compiler is in the PATH. Try to type “javac” in the command prompt. If javac is not found, then you should put your bin directory in the PATH.
For example, in Windows:
SET PATH=c:/jdk1.5.0_07/bin;%PATH%
This site might help further: http://looksok.wordpress.com/2014/02/08/uiautomator-in-eclipse/
If you have ADT with Eclipse then you can find ant in the plugins directory of Eclipse.