As I get ready to release my first Flutter app on Play Store I am in the process of testing the "release" APK on one of my local devices. To that end I have done the following
On Windows I issued
keytool -genkey -v -keystore path:\to\project\keys\keystore.jks -alias AliasName -keyalg RSA - keysize 2048 -validity 10000
and then proceeded to answer all the questions that were asked. I then created the file
path://to/project/android/key.properties
with the following entries
storePassword=[store password used above]
keyPassword=[key password used above]
keyAlias=[same alias as above]
storeFile=../../keys/keystore.jks
Finally I edited path://to/project/android/app/build.gradle as follows
signingConfigs
{
release
{
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes
{
release
{
signingConfig signingConfigs.release
}
}
With this done from the command line I ran
cls && flutter clean && flutter build apk --release --split-per-abi
and installed the resulting path://to/project/build/outputs/apk/release/app-arm64-v8a-release.apk on my local LG Fit smartphone. On browsing to it and trying to install it I am shown the message
Blocked by Play Protect
Play Protect does not recognize...
It is not clear to me why this is happening. As far as I can tell I have followed the steps correctly and the Flutter build process has not thrown up any problems.
Related
I have an Android app certificate with a file type of FILE that was created back in 2012 for my Android app written in Java. Now I have updated that app using React Native.
How can I use the existing certificate to generate keystore and sign my updated app to be released on Google Play?
I've tried this even though the React Native certificate extension is .keystore
keytool -importcert -file "your.cer" -keystore your.jks -alias "<anything>"
and I got the following error
keytool error: java.lang.Exception: Input not an X.509 certificate
I expect to have a .keystore file that allows me to release an update of my existing Android app.
You don't need to create keystore file. you can use existing jks file to sign the app. Do as follow:
Put your jks file in the app directory
add the following code in your gradle.poperties file.
MYAPP_RELEASE_STORE_FILE=filename.jks
MYAPP_RELEASE_KEY_ALIAS=your-key-alias
MYAPP_RELEASE_STORE_PASSWORD=your-store-password
MYAPP_RELEASE_KEY_PASSWORD=your-release-key-password
Now add the signingConfigs in build.gradle file as below:
signingConfigs{
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
Now you can sing your using your existing jks file.
One thing missed from the accepted answer.
How to fetch the existing Keystore file from the expo?
expo fetch:android:keystore
I need to know this so hopefully, it'll help someone.
I currently new developing android react-native, I have problem regarding deploying my application on other mobile device, I read the documentation of react native How to generate signed APK, i did the instruction of there document
React Native signed-apk-android
I already done configuring those requirements based on there document. I will show you the step that I did.
First: Install this in the cmd
keytool -genkeypair -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
Second: Setting up gradle variables
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias
MYAPP_RELEASE_STORE_PASSWORD=123456
MYAPP_RELEASE_KEY_PASSWORD=123456
Third: Adding signing config to your app's gradle config
...
android {
...
defaultConfig { ... }
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}
}
...
Lastly: Generating the release APK
Simply run the following in a terminal:
$ cd android
$ ./gradlew assembleRelease
Before I do the installation, I gonna make sure that the package
clearly uninstalled on my mobile device.
Release APK:
Error:
you need to click on the apk (probably with developer mode active press a few times on the build number in the settings menu)
The app works perfectly with the emulator when I run react-native run android but when I try generating the apk it shows the following error
Don't know what the problem is It works flawlessly in the emulator
It's difficult to know just like that what's the error... Did you follow all the steps ? :
=> keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
=> Place the my-release-key.keystore file under the android/app
=> Edit the file ~/.gradle/gradle.propertieswith the informations you create(store and key password). MYAPP_RELEASE_STORE_PASSWORD=*****
MYAPP_RELEASE_KEY_PASSWORD=*****
=> Edit the file android/app/build.gradle to enable release version... like this :
=> ...
android {
...
defaultConfig { ... }
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}
}
...
=> And finishing , go on main repo and run this : $ cd android && ./gradlew assembleRelease
=> The generated APK can be found under android/app/build/outputs/apk/app-release.apk
All the precise informations can be found here : https://facebook.github.io/react-native/docs/signed-apk-android.html#content
So i finally found the answer I had to delete default.png file and rename the reference in js files don't know what caused the error. But deleting the file in res folder seemed to be a workaround, if anyone finds the cause do tell me but for now the problem is resolved
I have developed my 1st application which is a location based reminder which uses google maps. When i debug my project from android studio to my device using USB cable everything goes fine but when i export my app by "Generating signed apk" in my device m unable to see map it's just a blank page with Google written below.. M unable to fetch the map.. M i missing something or is there another way to generate apk for google map project's ?
Have generated a keystore for release mode by using this command :-
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
After this i added the signing configuration to the build file for the app module as :-
android {
signingConfigs {
config {
keyAlias 'ramu'
keyPassword 'ramu#localert'
storeFile file('C:/Program Files/Java/jdk1.8.0_25/bin/my-release-key.keystore')
storePassword 'ramu#localert'
}
release {
storeFile file('C:/Program Files/Java/jdk1.8.0_25/bin/my-release-key.keystore')
storePassword 'ramu#localert'
keyAlias 'ramu'
keyPassword "password"
}
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.anand.project"
minSdkVersion 18
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
signingConfig signingConfigs.config
}
}
}
n now when i invoke assemblerelease m getting the following error :-
Error:Execution failed for task ':app:packageRelease'.
Failed to read key ramu from store "C:\Program Files\Java\jdk1.8.0_25\bin\my-release-key.keystore": Cannot recover key
Either i missed something and i am confused whether to generate a new keystore for release mode or should i use the debug keystore which i used for google maps api.. ? I ended up with generating more than 2 .apk's..
You will get separate keys for debug keystore and release keystore. Debug keystore API key won't work for signed apk, you will have to get release API key.
Well I found my solution for my problem.. For enabling my google map api i used debug keystore to get my SHA1 fingerprint and added the google map api key in my project. So when i try to run\release my application which has a debug keystore signature it wasn't fetching the map
Solution :-
The solution is u need to have a key generated by release mode to be able to view map after you run\release your app. Below is the procedure for signing your app with release mode :-
First create a keystore in command line by :-
keytool -genkey -v -keystore my-release-key.keystore -alias alias-name -keyalg RSA -keysize 2048 -validity 10000
You'll get the SHA1 fingerprint from the keystore
Use this to enable api n generate google map api key in google developers console.
Now, Goto Android Studio -> Build -> Generate Signed apk -> Locate the above created keystore by "Choose existing" -> Enter password which you gave while creating the keystore in command line -> Next -> Choose your destination folder where you want to save your .apk file -> Finish.
Now use this apk to run\release your project.
I am trying implement In-App billing in my Androd app and when I test the purchase functionality I get the error "This version of the application is not configured for billing through Google Play."
I suspect that I did not properly generate a signed APK and that the problem is with my buil.gradle file.
I genereated a keystore by following the instructions here and generated .jks. My question is what exactly do I put for the storeFile file() in signingConfigs?
The following example is from the Android docs:
signingConfigs {
release {
storeFile file("myreleasekey.keystore")
storePassword "password"
keyAlias "MyReleaseKey"
keyPassword "password"
}
}
Simply putting the path to my .jks file didn't work. Is a .jks file different than a .keystore file? If so, how do I genereate a .keystore?
UPDATE
I learned that the .keystore and .jks are arbitrary file extensions from this answer.
My plan is to simply copy the my keystore.jks file in to the app directory then add the tag as follows:
storeFile file("keystore.jks")
Is this correct? Unfortunately it will take a few hours for the apk to be published by Google Play so I can't get a quick answer on this.
I solved the problem. The key was to choose the app directory as the key store path.
Here are detailed instructions on how I generated a signed apk in Android Studio:
Go to Build->Generate Signed apk
Select the app module, click next.
Under Key store path, click create new.
The following window will pop up.
Select your app directory for the keystore path. It will create a keystore with default name "keystore.jks". You can change it if you like.
Enter a password for the keystore. We will call it "StorePassword"
Enter a Key Alias (let's call it "KeyAlias") and a Key password (let's call it "KeyPassword")
In the build.gradle file add the following:
Example Signing config:
signingConfigs {
release {
storeFile file("keystore.jks")
storePassword "StorePassword"
keyAlias "KeyAlias"
keyPassword "KeyPassword"
}
}
Continue through the Generate Signed apk Wizard and enter in the appropriate passwords and generate the apk. The key is to make sure that the build.gradle is updated in the final signed apk.
To confirm that you successfully signed the .apk see this question.
And of course, have secure backups and be extremely protective of the keystore once it is genereated.
keytool -genkey -v -keystore name_of_your_file.keystore -alias your_alias -keyalg RSA -keysize 2048 -validity 10000
This is command will generate new keys
change name_of_your_file for your name
and your_alias for your alias
the keystore will be generated in folder where you call this
Then add this to your build.gradle
signingConfigs {
config {
storeFile file("${rootDir}/name_of_your_file.keystore")
storePassword "qwerty"
keyAlias "your_alias"
keyPassword "qwerty"
}
}
buildTypes {
release {
signingConfig android.signingConfigs.config
}
}
but change qwerty to your password
and your_alias to your alias name which you use when you generate keystore
and name_of_your_file to name of your kestore
clean your project and run ./gradlew task assembleRelease
In Android Studio go to Build->Generate Signed apk and follow steps. You don't need to add signingConfigsin build.gradle At least on current android studio version which is 1.3.2