React-native Getting error when running - cd android && ./gradlew assembleRelease - android

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

Related

Flutter application release is different than debug

I have created an app in flutter using Android studio which I want to deploy.
Flutter version is 2.10.
Dart version is 2.16.0.
When I run or debug main.dart from Android studio everything works as expected.
I have signed the application following the instructions from here:
https://docs.flutter.dev/deployment/android
I have created the keystore using the following command:
"C:\Program Files\Android\Android Studio\jre\bin\keytool" -genkey -v -keystore c:\upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
Created key.properties file with the following content
storePassword=password from previous step
keyPassword=password from previous step
keyAlias=key
storeFile=location of the key store file, such as /Users/<user name>/upload-keystore.jks
in [project]/android/app/build.gradle added the keystore information before the Android block as follow
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
and replaced
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now,
// so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
with
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
And after changing the gradle file I ran flutter clean.
After the specified steps the application can still the debugged and can be ran as expected.
I am building a bundle with the following command
flutter build appbundle
The build is successful and I get the output file in
build\app\outputs\bundle\release\app-release.aab
Using bundletool I convert the .aab file to apks and install it on my phone with the following commands:
java -jar "PATH/bundletool-all-1.8.2.jar" build-apks --bundle=PATH/app-release.aab --ks="PATH/upload-keystore.jks" --ks-key-alias=key --output=PATH/app-release.apks
java -jar "PATH/bundletool-all-1.8.2.jar" install-apks --apks=PATH/app-release.apks
where PATH is the path to the directory of the file.
After the app is being installed and launched I get the attached window
which is completely different than the app I wrote.
Can someone please tell me what am I doing wrong?
Best regards,
Stanko
Thanks to Tomas's comment I have found the solution.
Running the following command
flutter run
a different project has been started, so I had to use this instead
flutter run PATH/lib/src/main.dart
which started the correct project, similarly for the app bundle I had to run
flutter build appbundle PATH/lib/src/main.dart
Thank you for your help!
Best wishes,
Stanko

Flutter signed APK blocked by Play Protect

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.

How to fix app not installing compiled apk on my mobile device, using generating signed APK of react-native

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)

Unable to view google map when i export my project from android studio

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.

Android Studio: how to generate signed APK using Gradle?

I've searched on Google and SO but cannot find my answer.
This is the first time I'm working with the Gradle system and I am now at the point of generating a signed APK to upload to Google Play (project is imported from eclipse).
Now, I've read the part here that you should add signingConfigs to your build.gradle.
I've added these lines and now I saw that you need to run ./gradlew assembleRelease but running this in my CMD returns
'gradle' is not recognized as an internal or external command,
operable program or batch file.
I've also tried to right click on the build.gradle and run it, saying it was sucessful but once I look in the build/apk folder only a file called app-debug-unaligned.apk.
So, how do I generate the signed APK using the Gradle system?
There are three ways to generate your build as per the buildType. (In your case, it's release but it can be named anything you want.)
Go to Gradle Task in right panel of Android Studio and search for assembleRelease or assemble(#your_defined_buildtype) under Module Tasks
Go to Build Variant in Left Panel and select the build from drop down
Go to project root directory in File Explore and open cmd/terminal and run:
Linux: ./gradlew assembleRelease or assemble(#your_defined_buildtype)
Windows: gradlew assembleRelease or assemble(#your_defined_buildtype)
If you want to do a release build (only), you can use Build > Generate Signed apk. For other build types, only the above three options are available.
You can find the generated APK in your module/build directory having the build type name in it.
It is possible to take any existing Android Studio gradle project and build/sign it from the command line without editing any files. This makes it very nice for storing your project in version control while keeping your keys and passwords separate:
./gradlew assembleRelease -Pandroid.injected.signing.store.file=$KEYFILE -Pandroid.injected.signing.store.password=$STORE_PASSWORD -Pandroid.injected.signing.key.alias=$KEY_ALIAS -Pandroid.injected.signing.key.password=$KEY_PASSWORD
You can use this code
android {
...
signingConfigs {
release {
storeFile file("../your_key_store_file.jks")
storePassword "some_password"
keyAlias "alias_name"
keyPassword "key_password"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
...
}
then from your terminal run
./gradlew assembleRelease
you will get the apk at
your-android-app/build/outputs/apk/your-android-app-release.apk
I think this can help you https://www.timroes.de/2013/09/22/handling-signing-configs-with-gradle/ then just select the Release from the Build Variants
If you live in certain countries, be sure to use a VPN.
step1: run this command in the command-line:
keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
it will ask you for some information such as password, name,... and enter them.
step2: create a file name key.properties in your android folder.
write these lines in the created file
storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=key
storeFile=<location of the key store file, such as ~/key.jks>
keep the key.properties file private, always keep a backup of the key.properties file and never publish publicly.
step3: Replace the following lines in app-level Gradle
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
step4:
keytool -list -v -keystore ~/key.jks -alias key -storepass <password> -keypass <password>
step5:
I recommend building APK, using android studio.
Build > Generate Signed Bundle/APK...
This is for Kotlin DSL (build.gradle.kts).
You could either define your properties in local.properties file in the project root directory or define them as environment variables (which is especially useful for CIs like GitHub Actions).
// See https://stackoverflow.com/q/60474010
fun getLocalProperty(key: String) = gradleLocalProperties(rootDir).getProperty(key)
fun String?.toFile() = file(this!!)
// Could also use System.getenv("VARIABLE_NAME") to get each variable individually
val environment: Map<String, String> = System.getenv()
android {
signingConfigs {
create("MyAppSigningConfig") {
keyAlias = getLocalProperty("signing.keyAlias") ?: environment["SIGNING_KEY_ALIAS"] ?: error("Error!")
storeFile = (getLocalProperty("signing.storeFile") ?: environment["SIGNING_STORE_FILE"] ?: error("Error!")).toFile()
keyPassword = getLocalProperty("signing.keyPassword") ?: environment["SIGNING_KEY_PASSWORD"] ?: error("Error!")
storePassword = getLocalProperty("signing.storePassword") ?: environment["SIGNING_STORE_PASSWORD"] ?: error("Error!")
enableV1Signing = true
enableV2Signing = true
}
}
buildTypes {
getByName("release") { // OR simply release { in newer versions of Android Gradle Plugin (AGP)
signingConfig = signingConfigs["MyAppSigningConfig"]
// ...
}
}
}
myProject/local.properties file:
signing.keyAlias=foo
signing.keyPassword=bar
# also called keystore
signing.storePassword=abcdefgh
signing.storeFile=C\:\\my-files\\my-keystore.jks
NOTE: Do NOT add your local.properties file to your version control system (like Git), as it exposes your secret information like passwords etc. to the public (if it's a public repository).
Generate your APK with either of the 3 ways that this answer mentioned.
build menu > generate signed apk

Categories

Resources