_From @ZuSe on March 12, 2018 13:18_
We are using Jenkins for building, signing and uploading our native android apps.
As the keyStore containing our signing key is saved within the jenkins credentials manager I would also like to use the same process for our NativeScript-App.
Unfortunately I am not able to build an unsigned release APK (as you can do for example in Android Studio) using the tns command.
tns build android --release requires the specification of the keystore (which might not be installed on the building machine)
I would therefore suggest to let it build an unsigned-release.apk file similar to Android Studio / gradle assembleXXXRelease command which can then be signed by whatever key signer is preferred.
In case the key-path parameter is specified it should use the existing process but not require it per se.
Best
Patrick
_Copied from original issue: NativeScript/NativeScript#5526_
Please note this will require changes to the android projects' build script which is distributed by the runtime. Another mechanism of providing the signing options will need to be establish, and I can't think of another built-in option off the top of my head - https://github.com/NativeScript/android-runtime/blob/74a1cde822bba9340a21feb99f0ebbb9912502c3/test-app/app/build.gradle#L130
Why would you not just copy the path from Android-Studio?
Wouldn't it be possible to call the gradle tasks step by step from tns?
There is a quick and dirty way, as mentioned by @petekanev.
In platforms/android/app/build.gradle, set signingConfigs to null, then run:
tns build android --release --bundle --env.uglify --copy-to $HOME/Downloads/ --key-store-path /dev/null --key-store-alias NULL --key-store-password NULL --key-store-alias-password NULL
This doesn't work on Windows as there's no /dev/null.
@swlemp I can't find build.gradle in my project , i'am only found a
app.gradle
android {
signingConfigs = null
...
.
.
but when I changed to this
Script '/home/runner/work/front/front/native/App_Resources/Android/app.gradle' line: 2
A problem occurred evaluating script.
Cannot set the value of read-only property 'signingConfigs' for object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.
Command ./gradlew failed with exit code 1
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@rafilkmp3
Try to add this to android section:
buildTypes {
release {
signingConfig null
}
}
@xuhcc when I added this apk was not found :(
Preparing "Install Android SDK Build-Tools 29.0.3 (revision: 29.0.3)".
"Install Android SDK Build-Tools 29.0.3 (revision: 29.0.3)" ready.
Installing Android SDK Build-Tools 29.0.3 in /opt/android/sdk/build-tools/29.0.3
"Install Android SDK Build-Tools 29.0.3 (revision: 29.0.3)" complete.
"Install Android SDK Build-Tools 29.0.3 (revision: 29.0.3)" finished.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Calling mockable JAR artifact transform to create file: /home/runner/.gradle/caches/transforms-2/files-2.1/c1343f5409714011b10c49fda4692ea5/android.jar with input /opt/android/sdk/platforms/android-29/android.jar
Project successfully built.
No .apk found in /home/runner/work/front/front/platforms/android/app/build/outputs/apk directory.
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 127.
If I remember correctly the CLI expects output file to have a certain name but when you build unsigned APK the name is different. But the build is successful -- check the output dir.
@xuhcc they are sent to subdir release , any tips to fix build ?
find platforms -name "*.apk"
platforms/android/app/build/outputs/apk/release/app-x86_64-release-unsigned.apk
platforms/android/app/build/outputs/apk/release/app-x86-release-unsigned.apk
platforms/android/app/build/outputs/apk/release/app-universal-release-unsigned.apk
platforms/android/app/build/outputs/apk/release/app-armeabi-v7a-release-unsigned.apk
platforms/android/app/build/outputs/apk/release/app-arm64-v8a-release-unsigned.apk
After add to app.gradle
variant.outputs.all {
outputFileName = "../" + outputFileName
}
Apks are on parent folder but native still cant find apks : (
find platforms -name "*.apk"
platforms/android/app/build/outputs/apk/app-x86_64-release-unsigned.apk
platforms/android/app/build/outputs/apk/app-x86-release-unsigned.apk
platforms/android/app/build/outputs/apk/app-universal-release-unsigned.apk
platforms/android/app/build/outputs/apk/app-armeabi-v7a-release-unsigned.apk
platforms/android/app/build/outputs/apk/app-arm64-v8a-release-unsigned.apk
Project successfully built.
No .apk found in /home/runner/work/front/front/platforms/android/app/build/outputs/apk directory.
error Command failed with exit code 127.
Most helpful comment
There is a quick and dirty way, as mentioned by @petekanev.
In
platforms/android/app/build.gradle, setsigningConfigstonull, then run: