I'm working on Ionic project now whereby I want to zipalign the android-release-unsigned.apk file. I followed this guide by Ionic.
When I run zipalign -v 4 /Users/zulhilmizainudin/Desktop/kl-parking/platforms/android/build/outputs/apk/android-release-unsigned.apk android-release.apk command, I get -bash: zipalign: command not found error.
This is where zipalign sit in my system:
/Users/zulhilmizainudin/Library/Android/sdk/build-tools/21.1.2
I tried to copy zipalign inside it and put it inside my Ionic project folder and run the zipalign command again. But still get the same command not found.
What should I do now?
Solved!
I copied zipalign file from my Library/Android/sdk/build-tools/21.1.2 into my Ionic project folder
I add ./ in front of the zipalign command like this - ./zipalign -v 4 /Users/zulhilmizainudin/Desktop/kl-parking/platforms/android/build/outputs/apk/android-release-unsigned.apk android-release.apk
Done. Now I get android-release.apk inside my Ionic project folder.
Thanks to Michael for the solution!
If you're using Windows, the right way is to add path to zipalign.exe as PATH environment variable.
Finding where zipalign.exe is located in your PC, in my case this was
C:\Users\random-username\AppData\Local\Android\sdk1\build-tools\24.0.1
Then add this location as one of the entries in your PATH environment variable.
To avoid specifying or navigating to your sdk/build-tools/* directories each time you intend to build release version, you can simply add the path to your environment variable.
$ sudo nano ~/.bash_profile
copy and paste the below:
export PATH=${PATH}:/Library/Android/sdk/build-tools/21.1.2
You can then save and exit:
control + o // to save to file
control + x // to close the file
$ source ~/.bash_profile
You can then run your zipalign command from your project CLI directory.
This worked for me on Mac. Install and run Android Studio (important to start it one time).
Then find zipalign:
find ~/Library/Android/sdk/build-tools -name "zipalign"
Windows
the right way is to add path to zipalign.exe as PATH environment variable.
Finding where zipalign.exe is located in your PC, in my case this was
C:\Users\username\AppData\Local\Android\sdk1\build-tools\29.0.2
Then add this location as one of the entries in your PATH environment variable.
MAC
To avoid specifying or navigating to your SDK/build-tools/* directories each time you intend to build a release version, you can simply add the path to your environment variable.
$ sudo nano ~/.bash_profile
copy and paste the below:
export PATH=${PATH}:/Library/Android/sdk/build-tools/21.1.2
You can then save and exit:
control + o // to save to file
control + x // to close the file
$ source ~/.bash_profile
You can then run your zipalign command from your project CLI directory.
if you are making ionic release build then you can make build.json file on your app's root folder with these information given below
{
"android": {
"release": {
"keystore": "Your keystore",
"storePassword": "password",
"alias": "alias name",
"password" : "password",
"keystoreType": ""
}
} }
make sure that you can place your keystore on your app's root folder or provide full path of your keystore at keystore object
now just you can run this command as below
ionic cordova build android --release
this command automatically find your build.json and make signed release build.
Solved!
I copied zipalign file as Michael Said
( from my Library/Android/SDK/build-tools/28.0.3 into my Ionic project folder)
BUT when I run
./zipalign -v 4 app-release-unsigned.apk botellamovil.apk
I got
./zipalign: ERROR while loading shared libraries: libc++.so: cannot open shared object file: **No such file or directory**
So, I also copied lib & lib64 files, and then it Works!!
I hope it will be helpful :) (and sorry for my English)
You should do (align, sign, and verify)for APK.
In mac, you should do the following steps:
A - Aligning APK:
1- you should locate zipalign your build tools inside android SDK:
/Users/mina/Downloads/sdk/build-tools/29.0.3/zipalign
2- you should locate your unsigned apk:
/Users/mina/Desktop/apks/app_unsigned.apk
3- you should run command contains:
zipalign_path + -v -p 4 + unsigned_apk_path + output_aligned_apk_name
/Users/mina/Downloads/sdk/build-tools/29.0.3/zipalign -v -p 4
/Users/mina/Desktop/apks/app-unsigned.apk app_aligned.apk
4- output is Verification successful
B - Signing APK:
1- you should locate apksigner your build tools inside android SDK:
/Users/mina/Downloads/sdk/build-tools/29.0.3/apksigner
2- you should locate your release-Keystore in your pc:
/Users/mina/Desktop/keys/release-Keystore.jks
3- you should run command contains:
apksigner_path + sign --ks + release-Keystore_path + --out + output_signed_apk_name + from_aligned_apk_name
/Users/mina/Downloads/sdk/build-tools/29.0.3/apksigner sign --ks
/Users/mina/Desktop/keys/release-keystore.jks
--out app_signed.apk app_aligned.apk
4- enter your key store password
C- Verifying APK:
1- run the following command : apksigner_path + verify + app_signed.apk
/Users/mina/Downloads/sdk/build-tools/29.0.3/apksigner verify
app_signed.apk
Notes: you may find some warnings:
WARNING: META-INF/....
Here is some description about that:
Apk Metainfo Warning
In practice, these files are not important, they're mostly versions of libraries you depend on, so even if someone modified those, it wouldn't have any impact on your app. That's why it's only a warning: those files in your APK can be modified by someone else while still pretending that the APK is signed by you, but those files don't really matter.
D- find your signed APK:
/Users/mina/app_signed.apk
I solved this problem by making the zipalign path an environment variable:
export ZIPALIGN_PATH=~/Library/Android/sdk/build-tools/30.0.3/zipalign
Then I replaced zipalign with $ZIPALIGN_PATH in the script I was trying to run
I'm running into several problems since I installed Kali from the USB live installer.
I found out that I needed to add this into my sources.list file in /etc/apt folder.
Just replace the content of sources.list with:
deb http://http.kali.org/kali kali-rolling main contrib non-free
deb-src http://http.kali.org/kali kali-rolling main contrib non-free
deb http://old.kali.org/kali sana main non-free contrib
deb http://ftp.de.debian.org/debian wheezy main
Related
In the Android project that I am working on, we are using GitLab CI/CD to automatically build and upload in Diawi the .apk file. In current settings build application's name is static because it needs to be known and sent to the Diawi framework as a curl request. The script looks like this:
- ./gradlew assembleRelease && cp app/build/outputs/apk/release/app-release.apk app-release.apk && curl -v --http1.1 https://upload.diawi.com/ -F token=$DIAWI_TOKEN -F file=#app-release.apk -F find_by_udid=0 -F callback_emails="mymail#company.com"
But this causes some troubles during the manual testing because the .apk files with the same name can be easily mistaken or overwritten.
My idea is to add some metadata in the .apk file's name to be unique and to avoid such errors. Do you have any ideas about how this could be done?
First thing you can do is create version bump functionality. You can do it via version bumping tool and git sync.
For version bumping you can use our open source tool - https://github.com/relizaio/versioning . Now, assuming that you sync via a file called apk_version, you first initialize this file with the current version like:
docker run --rm relizaio/versioning -s YY.0M.Patch > apk_version
Then in your CI context, you can bump it with something like
docker run --rm relizaio/versioning -s YY.0M.Patch -v $(cat apk_version) -a bump > apk_version
Now, in GitLab CI you need to have a block that resolves this. Note, that you also need to commit apk_version file at the end of the bump.
For inspiration - see this question How to grant permission for semantic-release to push code to master and also our sample CD project on GitLab - https://gitlab.com/taleodor/sample-helm-cd/-/blob/master/.gitlab-ci.yml
Also my article here may be helpful (note it's a bit outdated at this point): https://worklifenotes.com/2020/02/27/automatic-version-increments-with-reliza-hub-2-strategies/
Finally, for other things that you can add to version GitLab has a list of pre-defined env variables that you can use in whole or partially as modifiers: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
I am trying to add a sign tool to my app installation setup.
I have opened the installation script in Inno setup, then use Tools to Configure Sign Tools... Named it MsSign and used the path: C:\Program Files (x86)\Windows Kits\10\bin<sdk version>\x64\SignTool.exe for the sign tool.
I added SignTool=MsSign $f in the .iss file for the installer.
I get an errorInnosetup compile error 2
Here is part of my script
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
SignTool=MsSign $f
AppId={{B6149292-1303-475E-A4E5-F3DA50F61C20}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={autopf}\{#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=D:\Xcreator\Mathsquest\Mathsquest license.Tops.txt
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=D:\Xcreator\Mathsquest\Mathsquest Installer Modise
OutputBaseFilename=MATHSQuestSetup
SetupIconFile=D:\Xcreator\Mathsquest\icon\logo_5_dc0_icon.ico
Password=mq142019tm
Compression=lzma
SolidCompression=yes
WizardStyle=modern
I have installed Windows 10 SDK and Visual studio 2019 community and I get the same error.
How do I fix this. I want to be able to use Inno Setup Extractor to open the app in Android.
SignTool = it's just a string of whole sign command;
$f = it's for your file name, you need to put it in the end of the sign command (SignTool);
for example MsSign =
"C:\Program Files (x86)\Windows Kits\8.1\bin\x86\signtool.exe" sign /tr http://timestamp.digicert.com /f "D:\WORK\Projects\YourProject\your.pfx" /fd sha256 /as /p yourpfxpass $f
I am trying to import a custom tool into the pipeline Jenkinsfile script (specifically, the Android SDK). From the build console, it says that I need to set the ANDROID_HOME environment variable to build my Android app. However, when I tried adding the SDK download and set it to the ANDROID_HOME variable, it's telling me that the directory does not exist:
Caused by: java.lang.RuntimeException: The SDK directory '/var/jenkins_home/tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/Android_SDK_CLI_tools_4333796/bin' does not exist.
In the global tools configuration page, here's how I added the Android SDK:
Name: Android_SDK_CLI_tools_4333796
Tool home: bin
Command: (below)
if [ ! -f "Android_SDK_tools_4333796/" ]; then
echo "curl"
curl -O https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
echo "unzip"
yes | unzip -q sdk-tools-linux-4333796.zip
rm sdk-tools-linux-4333796.zip
echo "licenses"
yes | tools/bin/sdkmanager --licenses
fi
Below is how I set my Jenkinsfile:
pipeline {
agent any
environment {
ANDROID_HOME = tool 'Android_SDK_CLI_tools_4333796'
//ANDROID_HOME = tool name: 'Android_SDK_CLI_tools_4333796', type: 'com.cloudbees.jenkins.plugins.customtools.CustomTool' //alternative but still has the same results.
//env.PATH = "${env.PATH}:${androidSDKHome}"
}
tools {
jdk 'JDK_9.0.4'
}
stages {
stage('Pre-build') {
steps {
// seeing if Java JDK installed correctly
sh 'java --version'
print (env.ANDROID_HOME) // prints: /var/jenkins_home/tools/com.cloudbees.jenkins.plugins.customtools.CustomTool/Android_SDK_CLI_tools_4333796/bin
}
}
stage('Test') {
steps {
echo 'Testing stage...'
sh './gradlew clean --stacktrace' //ERROR (above)
}
}
}
}
My question is, am I pulling in this custom tool into the build properly? It seems Jenkins can't find it the custom tool even though I trying to access the absolute path.
I tried referencing this SO question; However, this is for me to obtain the executable whereas I'm looking to set the env var for Gradle to pick up the ANDROID_HOME env var automatically.
Ok, after struggling with this for the past few days, I realized many new things, the most important was how the dir structure has to be for commands to work.
The folder structure should be in this layout:
/<unpacked_location>
/tools
/bin
...
/build-tools
/licenses
/platforms
From there, everything should fall like dominos. My problem was, when Jenkins unpacks the Android SDK cli tools download, I was setting the home to bin. That's wrong since when you unpack the Android SDK, /bin is located inside the /tools dir. Jenkins kinda confused me by not allowing me to leave the home dir blank (makes sense since you can also set absolute paths if needed), so I set it to the present working dir (. in this case).
The other major thing that I was missing was installing the latest Android SDK version. I just added this to the global tool config script for Android SDK:
yes | tools/bin/sdkmanager "build-tools;28.0.3"
I have Qt application to deploy on Android. I am using command line build to generate an apk signed with my .keystore file. I am well able to do it using following command where I am using androiddeployqt.
androiddeployqt --sign my_key.keystore myAlias --storepass my_password --output android --verbose --input my_app.so-deployment-settings.json
Above command works great from my shell script to generate a signed apk. But I want to avoid writing my password on the command as done above. Typing androiddeployqt -help shows that there is a --sigfile <file>: Name of .SF/.DSA file option that I can use. But I don't know how to create this sigfile of extension .SF/.DSA.
Can someone please suggest how to create a sigfile of extension .SF/.DSA which I can use with androiddeployqt command with --sigfile as option ? Am I correct in understanding that I need a file of extension .SF or .DSA ?
Or, is there some other way I can hide my password from showing up on the script's code ?
Okay, I had to look at the oracle docs..as long as you have a keystore cert you supply the sigfile names it it creates those files for you per:
https://docs.oracle.com/javase/tutorial/deployment/jar/signing.html
and the qt tool you are using plugins into that so you should be good to go
I'd like to know if some of you worked out how to generate signed APKs and IPA with multiple configurations (ie : beta for hockeyapp, and production for stores) in a single command.
I'm exploring all the possibilities there, it looks like there are lots of ways to do this.
I'd also like to be able to pass a variable like ENVIRONMENT to set Javascript constants such as an API url or turn on/off debugs.
Here's what I'm thinking right now :
Using https://www.npmjs.com/package/react-native-config to solve the former problem.
On android :
I'm thinking about adding a type in buildTypes in gradle. So far, I couldn't get it to work, I'm not very experienced with native configurations.
I would then make a bash script to create the offline bundle with the chosen env (staging / dev / prod) and use gradle's assembleRelease / assembleBeta. Do you think that's doable ?
On iOS, it looks a bit more complicated :
It looks like it's hard to change the project's configuration in CLI when building. So I was thinking that I should duplicate the project for each environement : project-dev.xcodeproj, project-prod.xcodeproj... you got the point.
Once again, I would make the bundle, then cp it inside the given project. A nice touch would be to trigger the xcode compilation in CLI too, I don't know if this is hard to set up.
What do you think about this ? Maybe some of you are already using custom scripts to do that ?
The icing on the cake would be to use HockeyApp's 'puck' cli tool to upload it, but that should be quite easy to set up once the application has been build for both iOS and Android.
This is the process I use for command line build with parameters. My system builds a release version .ips file and then copies and resigns that file with a development provisioning profile that I can put on my development devices to test exactly what is being sent to the customer or to the app store. Not all of this will be useful to you, but hopefully some will.
First, I have a variables file that sets the global parameters that I'm going to use for the build:
Scheme="(The scheme I am going to build inside my project)"
WindowsSavePath="(path to my source archive directory on a shared computer)"
InstallSavePath="(path to my .ipa archive directory on a shared computer"
Customer="(relative path inside archive directories)"
Fleet="(Continued relative path)"
PathToProject="(path to the folder on my Mac with the xcode project file)"
ProjectName="(project name).xcodeproj"
PlistPath="$Scheme-Info.plist"
appScheme="$Scheme"
AppName="(The name that I want to give my .ipa file)"
Version="(The version number for this build)"
AppendedFileName="-QA" //I use this for QA and Production distinction
exportPath="$InstallSavePath/$Fleet/$Customer/$Version$AppendedFileName/"
CompanyAppIdentifierPrefix="(my generic provisioning profile identifier)"
ArchiveLocation="$WindowsSavePath/$Fleet/$Customer/$Version$AppendedFileName"
SourceCodeDestination="(my compiled absolute path to the archive directories)"
This is all contained in a SetVariables.sh file. Now we get to start building the project. In another .sh file first I call the SetVariables file, then I start compilation:
#Update the version number in the plist file for the project
/usr/libexec/PListBuddy -c "Set :CFBundleShortVersionString $Version" "$PathToProject/$PlistPath"
/usr/libexec/PListBuddy -c "Set :CFBundleVersion $BuildVersion" "$PathToProject/$PlistPath"
#Now build and archive the project, the create the .ipa file for either submittal or giving to customers
mkdir -p "$exportPath"
mkdir -p "${ArchiveLocation}/dSYM"
xcodebuild -project "$PathToProject/$ProjectName" -scheme "$Scheme" DSTROOT="$exportPath" DEBUG_INFORMATION_FORMAT="dwarf-with-dsym" DWARF_DSYM_FOLDER_PATH="${ArchiveLocation}/dSYM" archive -archivePath "$exportPath${appScheme} $Version$AppendedFileName.xcarchive"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${exportPath}Applications/${AppName}.app" -o "${exportPath}${appScheme} $Version$AppendedFileName.ipa"
#Now resign and create an internal dev version to test on development ipads
rm -r Payload SwiftSupport
unzip -q "${exportPath}${appScheme} $Version$AppendedFileName.ipa"
BUNDLE_ID=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "Payload/${AppName}.app/Info.plist")
. ./CreateInternalEntitlements.sh "$CompanyAppIdentifierPrefix.$BUNDLE_ID"
. ./resign.sh "${exportPath}${appScheme} $Version$AppendedFileName.ipa" "${exportPath}${appScheme} ${Version}${AppendedFileName} Internal" internalDev.mobileprovision "(My developer account tied to the internal provisioning profile" Entitlements.plist
rm -r Payload SwiftSupport
#Now delete the intermediate files from the installs directory
rm -rf "$exportPath${appScheme} $Version$AppendedFileName.xcarchive"
rm -rf "${exportPath}Applications"
I have left out a few things in there (resign.sh, createentitlements.sh), but those processes I found on stackoverflow, so it shouldn't be too hard for you to find as well.
I've never done it, but I'm relatively certain that you can change the command line arguments for the xcodebuild to build either release or debug like you are trying to do. You could also run the xcodebuild twice, once for debug and once for release, and save the builds to different locations.
I hope this helps you at least a little with your goals. This took my a week or two to put all together and get working for my needs. Good luck.