Titanium CLI not accepting the .keystore file provided - android

I am trying to make android build, target set to build for dist-playstore from Titanium CLI. I am using this command
titanium build -p android -b -d /Users/ajeetpratap005/Documents/Titanium_Studio_Workspace/androidTest
-f -L androidTest -A /Users/ajeetpratap005/android-sdks
-K /Users/ajeetpratap005/android-test.keystore
-T dist-playstore -O /Users/ajeetpratap005/Documents/Titanium_Studio_Workspace/androidTest/dist
It builds successfully but I am not able to get my build in the output folder. when I checked the build which is getting generated in the build/android/bin folder, it is signed with the default keystore file which is present in the
<titanium mobile SDK location>/3.0.0.G.A/android/dev_keystore
How do I make titanium CLI to take my .keystore file and dump the production build to the output folder mention in the command..

Please refer to this document
https://wiki.appcelerator.org/display/guides/Packaging+for+the+Android+Market
There are instructions on the android developer site for generating the certificate key file here: http://developer.android.com/guide/publishing/app-signing.html#cert
See this video for more clarity http://vimeo.com/10278960

Related

Generate Apk file from aab file (android app bundle)

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

How to build Expo APK local

Is it possible to build the APK of an expo app locally?
The doc says:
If you haven’t used exp before, the first thing you’ll need to do is login with your Expo account using exp login.
I tried exp start, exp build:android but the commands require a login.
I don't want to build the APK using expo server. Is there a way to run this build locally? So no login and push of source code required?
If not, can I view the whole source code of the generated APK?
New to the party, so guessing this wasn't available at the time of the post - Instructions for building expo apps locally:
Building Standalone Apps on Your CI
Update Jan, 2023:
You may want to check out the updated version:
This doc was archived in August 2022 and will not receive any further updates. SDK 46 is the last SDK supported by Classic Builds and the Classic Build service will stop running for all SDK versions after January 4, 2023. Check out Running builds on your own infrastructure and Triggering builds from CI.
if you want to generate apk eject the CRNA with npm run eject command. Then you will get android and ios folders suppurate in mac and you will get an only android folder in windows. and follow the instruction which is in a given link below
"https://facebook.github.io/react-native/docs/signed-apk-android.html"
I've straggled with similar issue, I managed to solve it following several steps found on the web, and tweaking a bit:
https://forums.expo.io/t/expokit-full-local-build-without-publish-android/31400/2
Run the https server your machine, note that the server must have a certificate since it is a HTTPS server (I used port 4443), but it does not need to be trusted by your machine - it works anyway (I found it easy to use: https://gist.github.com/dergachev/7028596 - Python 2.7,
https://gist.github.com/dergachev/7028596#gistcomment-1989299 - Python 3.X)
Go to your Expo project folder, make sure there is no dist
folder in it; alternatively you can provide dist path with the --output-dir flag
(the react-native bundle and assets will be generated to it).
Open command line and run:
expo export -t bare --dev --public-url https://localhost:4443/, once done you will have the android bundle and assets in the output-dir (default - dist)
Copy the android bundle from dist/bundles/android-<bunch of numbers (MD5)>.js to <YourExpoProjectFolder>/android/app/src/main/assets/index.android.bundle and to <YourExpoProjectFolder>/android/app/build/generated/assets/react/release/index.android.bundle (note: the name of the bundle must be index.android.bundle)
In /dist/bundles/assets you'll have your assets files, but they would be named as their MD5 value, copy each of them to <YourExpoProjectFolder>/android/app/src/main/assets/, but add the asset_ prefix and .<ext> for each. e.g. for a PNG image file with MD5 value of de57a0c7a3a23aabcaceaf1185b1e79e:
copy <YourExpoProjectFolder>/dist/bundles/assets/de57a0c7a3a23aabcaceaf1185b1e79e <YourExpoProjectFolder>/android/app/src/main/assets/asset_de57a0c7a3a23aabcaceaf1185b1e79e.png
cd android
gradlew.bat assemble
expo diagnostics output:
Expo CLI 3.18.6 environment info:
System:
OS: Windows 10 10.0.18363
Binaries:
Node: 12.16.2
Yarn: 1.22.0
npm: 6.14.4
npmPackages:
expo: ~37.0.3 => 37.0.8
react: ~16.9.0 => 16.9.0
react-native: ~0.61.5 => 0.61.5
react-navigation: ^4.3.9 => 4.3.9
If you want to build the app locally without using the turtle CLI of expo, you can build it just how you would build a normal react native app
But beware that you will have to touch some native android code (gradle only)
But only one or two files....
Steps:
Generate a release Keystore by keytool
Link the keystore in build.gradle file
Run cd android && ./gradlew assembleRelease to build the apk
Check out this post to follow these steps in detail
Motivation: build local, test performance of release build on a real device.
Environment: Expo SDK 46 managed project, on AlmaLinux 8.6 (ymmv)
Caution:
I keep a copy of my entire project dir in case things get messed up:
cd <project *parent* dir>
\cp -far <project dir name> <project dir name>.bak
and update that when appropriate with
cd <project dir> # if not there
rsync -atvi --delete . ../<project dir name>.bak/
Steps to create android project dirs/files and a debug build apk :
cd <project dir>
npx expo run:android # not the same as "npm run android"
see ref in official expo docs here
release build:
cd <projectDir>/android/app
keytool -genkey -v -keystore <projectName>.keystore -alias <<projectName>> -keyalg RSA -keysize 2048 -validity 10000
ammend android/app/build.gradle file - see details here but do not use the build instructions (atow). Then ...
cd ../../ # to project dir
npx expo run:android --no-install --no-bundler --variant release
(although tbh I'm guessing for now that --no-bundler is to do with the Metro server)
You should find a release apk in
<project dir>/android/app/build/outputs/apk/release
Note this includes full expo and the build can take quite a while. It took more than 12 mins on the following:
Operating System: AlmaLinux 8.6
KDE Plasma Version: 5.23.3
KDE Frameworks Version: 5.88.0
Qt Version: 5.15.2
Kernel Version: 4.18.0-372.32.1.el8_6.x86_64 (64-bit)
Graphics Platform: X11
Processors: 12 × Intel® Xeon® CPU E5-2620 v3 # 2.40GHz
Memory: 31.1 GiB of RAM
Graphics Processor: AMD CEDAR
You can reduce build time and the final apk size by going for an expo development build or moving your code to a porn project (plain old react-native) :-)

Android INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES

I am getting the following error when I'm trying to install an APK with a higher version and same packageName over an existing one. The existing APK is a system app. It fails with the following error:
INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES
However when I manually inspect the 2 apks their certificates seem to match. I used the following command:
unzip -p $package META-INF/CERT.RSA | keytool -printcert
Is there a different parameter which might be affecting this?

Building liblinphone for Android

I am building Linphone application for android. I am using windows xp 32 bit.
1) Download android ndk
2) Installed the autotools: autoconf, automake, aclocal, libtoolize pkgconfig
3) run the ./prepare_sources.sh/
I got the output in terminal as
$ ./prepare_sources.sh /cygdrive/d/android/androidNdk/android-ndk-r8d
using /cygdrive/d/android/androidNdk/android-ndk-r8d as android NDK
./prepare_sources.sh: line 23: git: command not found
Applying patch to ffmpeg
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
|--- submodules/externals/ffmpeg/libavcodec/arm/int_neon.S.orig 2011-09-30 19:43:21.935593025 +0200
|+++ submodules/externals/ffmpeg/libavcodec/arm/int_neon.S 2011-09-30 19:44:21.115168033 +0200
File to patch:
Any info, questions or anything really is highly appreciated
Part 1
The following steps can help you create and install the build on your device or emulator(Tested on Mac):
Step1: you need to have the Android SDK and NDK configured and istalled
Also install Autotools Mac users can use this link (Follow point 2.3 only in the link)
Other platform users please make sure you install it correctly.
Step2: Mac users open up your terminal and clone the git repo on any directory you want
to by running the following command: (Other users sorry i don't know how but i think you can figure it out that how you can get the git repo on your directory using command promt or whatever you are using)
$ git clone git://git.linphone.org/linphone-android.git --recursive
After you get the Repo copied into your directory now go to the directory and open the README file and read out the whole file.
Step3: Now we will follow as the instructions written in README file
First Go to root directory of the downloaded project using the following command on Terminal:
Mac users on terminal write cd and
then drag and drop the "linphone-android" folder on terminal
(when you drag and drop the folder terminal will get the path of the folder and then you can hit enter to get into the directory of that folder)
$ cd /Users/myname/Desktop/Android/linphone-android
or just use simple command cd to get into the folder
$ cd Desktop
$ cd Android
$ cd linphone-android
Now when you get into the directory on terminal then check your PATH of SDK & NDK installed on your Mac run
$ echo $PATH
if you see the path with SDK and NDK location then it's ok to proceed with Step4 and skip the below part and if not then you need to setup the PATH before you execute the make and make install script in Step 4:
To set up path use :
$ export PATH=/Users/myname/Documents/adt-bundle-mac-x86_64-20130729/sdk/platform-tools:/Users/myname/Documents/adt-bundle-mac-x86_64-20130729/sdk/tools:/Users/myname/Documents/android-ndk-r9:$PATH
it's like export PATH=(Path of your SDK platform tools folder):(Path of your SDK tools folder):(Path of your NDK folder):$PATH
This will set up the path and to confirm again run
$ echo $PATH
Now you will see that the path of SDK and NDK is there.
Step 4: Now if the Path is already setup you can simply run
$ make
Now connect your Device to you Mac/Pc and see if eclipse has detected it.
After the device is connected run:
$ make install
$ make generate-sdk (optional)
This will install the application into your phone. (you need to have an working SIP username and password to configure in the app)
This above steps worked for me and i was able to get the app running on my device.
Part 2
Importing into Eclipse :
After you have made your build then now you need to import it into eclipse.
Step1: Go to eclipse click on File Menu then Import then select
Existing Android Code into Workspace
Hit Next and Browse to the linphone-android project folder
And Only tick linphone-android folder and Leave Copy project into workspace untick.
Do this Like the below image:
And hit finish.
Now you right click on "linphone-android" (project name) and go to Properties and Java Build Path and then Order and Export and then reorder them as my image below and untick gcm.jar
Hit OK
And Boom No errors
Now just run it on device or emulator. (Make sure your minimum target SDK matches with your device or emulator.)
The above steps worked fine for me and it will work for you as well.
All the Best !!
According to README in root dir of linphone-android you don't need to run prepare_sources.sh, remaining steps for you is to run "make" and "make install":
LINPHONE for ANDROID
**************
To build liblinphone for Android, you must:
0) download the Android sdk with platform-tools and tools updated to latest revision (at least API 16 is needed), then add both 'tools' and 'platform-tools' folders in your path.
1) download the Android ndk (>=r8b) from google and add it to your path.
2) install the autotools: autoconf, automake, aclocal, libtoolize, pkgconfig
2bis) on some 64 bits systems you'll need the ia32-libs package
3) run the Makefile script in the top level directory. This will download iLBC source files and convert some assembly files in VP8 project.
$ make
4) To install the generated apk into a plugged device, run
$ make install
Existing answers shows how to build old linphone but to Build Latest Linphone for Android You can follow these Steps:
1) First Download Android SDK (at least API 16 is needed)
2) Then Download Android NDK(>=r9d) from Google.
3) Then Install cmake, python, yasm nasm Dependencies which is further required while installing Linphone. you can install these tool through Terminal.
4) Then You have to download source code of Linphone using following command:
git clone git://git.linphone.org/linphone-android.git --recursive
5) After Downloading Source code You have to set Path of Android SDK,NDK and also JDK
in Android SDK You have to give path upto Tools.
For Example : in console type following command
export SDK_PATH=/home/rajesh/android/adt_bundle/sdk
export NDK_PATH=/home/rajesh/android/android-ndk-r10c
export JDK_PATH=/usr/lib/jvm/java-7-openjdk-i386/
export PATH=$PATH:$NDK_PATH:$SDK_PATH/platform-tools:$SDK_PATH/tools:$JDK_PATH
6) After setting path you have to navigate through Linphone directory and type command “./prepare.py” then This will configure the build and generate a Makefile in the top level directory.
If you get following error: CMake Error Could not find the intltoolize program then
Refer
http://lists.nongnu.org/archive/html/linphone-users/2015-07/msg00092.html
7) After setting path you have to navigate through Linphone directory and type command “make” then it will generate apk for Linphone.
8) To generate a liblinphone SDK zip containing a full jar and native libraries, run
$ make liblinphone-android-sdk
I hope this helps.

How to build .apk file from Windows command-line?

How can I build and signed (keystore) the .apk file using 'apkbuilder.bat' via windows command-line ?
I try to run the following line:
apkbuilder.bat %APK_File_Name% -u -z %Project_Path%\bin\resources.ap_ -f %Project_Path%\bin\classes.dex -rf %Project_Path%
but I'm getting the following exception:
java.lang.ArrayIndexOutOfBoundsException: 1
at com.android.sdklib.build.ApkBuilderMain.main<ApkBuilderMain.java:61>
Please help. Thanks
You can do it in command line (.bat) in windows using ant.
with:
"ant release"
You build the apk unsigned.
Then you need to add the call to "jarsigner" and "zipalign" in the bat to complete the task.
You can find an example of the command line to call these tools here:
http://developer.android.com/guide/publishing/app-signing.html#signapp
Best,
I would suggest using Ant and the build files generated by the Android tools rather than trying to handroll your own. If nothing else, you can use the build files as a reference to determine how it uses the various tools to perform each step.

Categories

Resources