I want to generate a signed APK but I am not able to.
This is what I did:
Generated keystore file with this command:
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
Followed this guide:
https://facebook.github.io/react-native/docs/signed-apk-android.html#content
Generated APK with this command (on windows):
gradlew.bat assembleRelease
It always generates "app-release-unsigned.apk" file, do not why.
UPDATED
Solved, I forgot to add this line to app\build.gradle file:
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release // <--- ADD THIS LINE
}
}
did you add proper code in gradle.properties and build.gradle?
please mention your
build.gradle (App)
gradle.properties
file in question , and files of android/app/
it is possible that you does not have keystore file in directory android/app/
or have different name other than you mentioned in gradle.properties
Related
I am trying to setup databricks-connect in my windows machine. While doing databricks-connect test I am getting the below error complaining java certificate is not found. ''
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:439)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:306)
at sun.security.validator.Validator.validate(Validator.java:271)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:312)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:275)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:140)
at sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:630)
... 27 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434)
... 33 more
I have java 1.8 installed and I downloaded the browser certificate and installed it
I installed the certificate using below command.
keytool -importcert -trustcacerts -alias repo -file C:\Users\ravi\Downloads\adbcert.crt -keystore cacerts "C:\Java\jdk1.8.0_333\jre\lib\security\cacerts" -storepass changeit
Still, I am facing the same issue.
Adding root certificate solved the problem.
I have cmake project which uses openssl for TLS, I have installed openssl into my system with
yum install openssl-devel
find_package(OpenSSL REQUIRED)
if (OPENSSL_FOUND)
message(STATUS "Found OpenSSL ${OPENSSL_VERSION}")
else()
message(STATUS "OpenSSL Not Found")
endif()
I got following message:
-- Found OpenSSL 1.0.2s
However, I got following error when I include openssl header file in my project
fatal error: openssl/core_names.h: No such file or directory
How can I resolve this error?
This header seems to be added in OpenSSL 3, according to this man.
Searching for the file in the OpenSSL 1.0.2s tree yields nothing.
I guess you might forget to add the following in your CMakeLists.txt
target_link_libraries(your_executable
PRIVATE
openssl
It does populate include directories of your target with path to include folder of openssl library, so the header can be found. You can check if this is your problem by adding
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
this will generate compile_commands.json file into your build folder, which contains build commands - please check if include folder of openssl library is passed as -I argument to your compiler (I assume you are using GCC, so -I argument passes include search paths
I create an simple application by react native. After finishing deploying now i want to make release apk so in order to according it's official site i have created key:
"C:\Program Files\Java\jdk1.8.0_162\bin\keytool.exe" -genkeypair -v -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
And i added :
MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=mypass
MYAPP_UPLOAD_KEY_PASSWORD=mypass
into the android/gradle.properties file and finally i added release part into signingConfigs section in android/app/build.gradle file:
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
and i added this sign config to buildTypes part:
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
but after running \android> ./gradlew bundleRelease :
PS F:\SafaProject\ReactNative\RNAuditMngm\android> ./gradlew bundleRelease
> Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
Loading dependency graph, done.
info Writing bundle output to:, F:\SafaProject\ReactNative\RNAuditMngm\android\app\build\generated\assets\react\release\index.android.bundle
info Writing sourcemap output to:, F:\SafaProject\ReactNative\RNAuditMngm\android\app\build\generated\sourcemaps\react\release\index.android.bundle.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 13 asset files
info Done copying assets
> Task :react-native-gesture-handler:compileReleaseJavaWithJavac
Note: F:\SafaProject\ReactNative\RNAuditMngm\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerButtonViewManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
> Task :react-native-reanimated:compileReleaseJavaWithJavac
Note: F:\SafaProject\ReactNative\RNAuditMngm\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesManager.java uses or overrides a deprecated
API.
Note: Recompile with -Xlint:deprecation for details.
Note: F:\SafaProject\ReactNative\RNAuditMngm\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 1m 54s
88 actionable tasks: 84 executed, 4 up-to-date
PS F:\SafaProject\ReactNative\RNAuditMngm\android>
It just create app.aab file in \app\build\outputs\bundle\release folder?
How could i create apk file?
This is complete app build.gradle
If you want to create .apk then run command :
cd android
./gradlew assembleRelease
It will generate release apk here :
android/app/build/output/apk/release/app-release.apk
If you want to generate a buldle (.aab) to upload to play store:
cd android
./gradlew bundleRelease
This is the way I generate a signed APK.
I'll also show you how to securely load in your gradle variables so that the project can be safely pushed to Git without exposing your passwords (something that is annoyingly not covered in tutorials).
1. Generate an upload key.
You can generate a private signing key using keytool. On Windows keytool must be run from C:\Program Files\Java\jdkx.x.x_x\bin.
keytool -genkeypair -v -storetype PKCS12 -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
This command prompts you for passwords for the keystore and key and for the Distinguished Name fields for your key. It then generates the keystore as a file called my-upload-key.keystore.
The keystore contains a single key, valid for 10000 days.
2. Setting up Gradle variables and safely loading them in
Place the my-upload-key.keystore file under the android/app directory in your project folder.
Create a new file in the android folder: android/keystore.properties and add the following (but obviously with your own passwords).
MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-key-alias
MYAPP_UPLOAD_STORE_PASSWORD=YOUR_PASSWORD_HERE
MYAPP_UPLOAD_KEY_PASSWORD=YOUR_PASSWORD_HERE
Then add this new file to .gitignore so you can safely push to github without exposing your variables:
keystore.properties
Next, modify your android/app/build.gradle code to load in your keystore properties:
// Load keystore
def keystorePropertiesFile = rootProject.file("keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
// ...
android{
// ...
signingConfigs {
release {
if ( keystorePropertiesFile.exists() ) {
storeFile file(keystoreProperties['MYAPP_UPLOAD_STORE_FILE'])
storePassword keystoreProperties['MYAPP_UPLOAD_STORE_PASSWORD']
keyAlias keystoreProperties['MYAPP_UPLOAD_KEY_ALIAS']
keyPassword keystoreProperties['MYAPP_UPLOAD_KEY_PASSWORD']
}
}
}
buildTypes {
release {
// ...
signingConfig signingConfigs.release
}
}
// ...
}
Doing it this way ensures that the project will still work if someone else clones it from Git without the keystore.properties file - perfect.
3. Generate the Android release bundle file manually
Remove current index.android.bundle file:
rm android/app/src/main/assets/index.android.bundle
If no such file exists then you will get ‘No such file or directory’ message.
Next, generate the android bundle, note the below is one command:
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
You will likely get a “duplicate resources” error (at least I always do). Go to /android/app/src/main/res folder and delete any files that begin with “drawable”.
4. Generate the Android signed release build APK
Navigate to android folder:
cd android
And run the following command to generate your release APK:
./gradlew clean && ./gradlew assembleRelease
If any errors, delete android/.gradle and android/app/build/ and retry.
Your signed APK should now be located at android/app/build/outputs/apk/app-release.apk.
Once your build is successful then from your project’s root folder run below command to test your app in your device:
npx react-native run-android --variant=release
If you have any issues, try the following before re-doing the steps above:
Make sure to uninstall the old app on emulator/phone.
Delete old android/.gradle and android/app/build folder.
Npm cache clean –force.
Delete and reinstall node_modules.
I wrote this answer as an article for my own future reference but feel free to bookmark it :)
Hi everybody I have been setting up remote access to node-red for my raspberry Pi. I have amended the settings.js and installed node-red-admin but when I go to start node-red I get the following error:
Error: error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small
at Object.createSecureContext (_tls_common.js:131:17)
at Server.setSecureContext (_tls_wrap.js:1152:27)
at Server (_tls_wrap.js:1030:8)
at new Server (https.js:65:14)
at Object.createServer (https.js:89:10)
at Object.<anonymous> (/usr/lib/node_modules/node-red/red.js:141:20)
at Module._compile (internal/modules/cjs/loader.js:945:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)
at Module.load (internal/modules/cjs/loader.js:798:32)
at Function.Module._load (internal/modules/cjs/loader.js:711:12) {
library: 'SSL routines',
function: 'SSL_CTX_use_certificate',
reason: 'ee key too small',
code: 'ERR_SSL_EE_KEY_TOO_SMALL'
}
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 1.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
_tls_common.js:131
c.context.setCert(cert);
This happened after I successfully created privatekey.pem and certificate.pem. To create these files I used:
openssl genrsa -out privatekey.pem 1024
then used
openssl req -new -key privatekey.pem -out private-csr.pem
after which I put in relevant info and then recieved verification "signature is ok" with
openssl x509 -req -days 365 -in private-csr.pem -signkey privatekey.pem -out certificate.pem
As the above returned privatekey.pem and certificate.pem files under ls -la I moved onto uncommented the following:
// The `https` setting requires the `fs` module. Uncomment the
following
// to make it available:
var fs = require("fs");
module.exports = {
// the tcp port that the Node-RED web server is listening on
uiPort: process.env.PORT || 1880,
and also
adminAuth: {
type: "credentials",
users: [
{
username: "admin",
password: "$2a$08$9Miva2AQEFlXQ3S7emXlIuLkLzNzi9yzgqxGYMY5dzK4FzNQa7dCu",
permissions: "*"
}
]
},
with loading fs module
https: {
key: fs.readFileSync('/home/pi/.node-red/privatekey.pem'),
cert: fs.readFileSync('/home/pi/.node-red/certificate.pem')
},
After doing this configuration I get the error message stated at the beginning.
Update: I did delete the contents of .node-red/settings.js and replaced with https://github.com/node-red/node-red/blob/master/packages/node_modules/node-red/settings.js
and node-red starts! woohoo!
However when try to reconfigure the settings.js file again it runs into the same error..
FYI I am carefully uncommenting lines however could the problem reside in the hash-pw i receive from node-red-admin? Because when I try to install node-red-admin with "npm install -g node-red-admin" after logging in as root via "su" it comes up with the following:
pi#padrejuan:~ $ su
Password:
root#padrejuan:/home/pi# npm install -g node-red-admin
/usr/local/bin/node-red-admin -> /usr/local/lib/node_modules/node-red-
admin/node-red-admin.js
> bcrypt#3.0.6 install /usr/local/lib/node_modules/node-red-
admin/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for bcrypt#3.0.6
and node#12.11.1 (node-v72 ABI, glibc) (falling back to source compile
with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir
'/usr/local/lib/node_modules/node-red-admin/node_modules/bcrypt/lib'
gyp WARN EACCES user "nobody" does not have permission to access the
dev dir "/root/.cache/node-gyp/12.11.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir
"/usr/local/lib/node_modules/node-red-admin/node_modules/bcrypt/.node-
gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
and so on.
Any help would be greatly appreciated
The problem is that the latest versions of openssl now considers keys with a bit length of 1024 to be insecure.
Re-generate the private key with a size of 2048 and then recreate the certificate.
openssl genrsa -out privatekey.pem 2048
https://github.com/debauchee/barrier/issues/126#issuecomment-505933083
It is just a matter of editing file /etc/ssl/openssl.cnf changing last line
from:
CipherString = DEFAULT#SECLEVEL=2
to
CipherString = DEFAULT#SECLEVEL=1
If you are using RHEL 8 & above, these are the steps to resolve:
update-crypto-policies --show
update-crypto-policies --set DEFAULT
reboot
My computer is behind a proxy. I have just add keystore for jcenter.bintray.com.
"%JAVA_HOME%\bin\keytool" -import -trustcacerts -alias C:\cer\p7b -file C:\cer\p7b\jcenter.cer -keystore "%JAVA_HOME%\jre\lib\security\cacerts
When i run 'tns run android' , it throws errors:
Could not resolve all files for configuration ':classpath'.
Could not download uast.jar (com.android.tools.external.org-jetbrains:uast:26.0.1)
Could not get resource 'https://jcenter.bintray.com/com/android/tools/external/org-jetbrains/uast/26.0.1/uast-26.0.1.jar'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/external/org-jetbrains/uast/26.0.1/uast-26.0.1.jar'.
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
....