apk build file come with errors in react native android - android

Here, I have built the react native android app using this documentation Doc
in jenkins which was configured on ubuntu 16.04 (in virtual machine).
Here is the build command which I used to build the react native app(android) in Jenkins
cd $WORKSPACE && chmod -R 777 ./android && cd ./android && npm install && ./gradlew clean && ./gradlew assembleDebug
The build process end successfully creating an apk file in the following path
build_release_v1/ws/android/app/build/outputs/apk/
Note build_release_v1 is the jenkins project name and ws is for the workspace of it.
Though the apk is created it comes up with following errors
What may be the case ....please help me with this ...Thanks in advance...

The problem is that if you want a debug build (since you are using assembleDebug), React Native generates an APK that expects to have a connection to the bundle server (it does the same as react-native run-android). My guess is that you want to test the app without the bundler, so you have two options: either run assembleRelease instead (have a look here for more details) or manually create the bundled JavaScript code and then create the APK. Please refer to this question for details.

Related

"ENOENT: no such file or directory" when building Android project in AWS CodeBuild and sending artifact to Visual Studio AppCenter

I have an android project that i build with AWS CodeBuild. The project is built successfully, the .apk is stored in s3 bucket with no problem. Now, I'm also trying to upload that .apk to Visual Studio App Center, but when i run the CodeBuild project, I get this error
Error: Command 'distribute release --app Test/Android-Test --file SourceCode/MobileApp/android/app/build/outputs/apk/release/app-release.apk --group test' failed with exception "ENOENT: no such file or directory, stat 'SourceCode/MobileApp/android/app/build/outputs/apk/release/app-release.apk'"
Here is my buildspec.yml
version: 0.2
phases:
install:
runtime-versions:
android: 29
java: corretto8
nodejs: 12
pre_build:
commands:
- cd SourceCode/MobileApp
- npm install -g react-native-cli
- yarn
- cd android
build:
commands:
- ./gradlew clean
- ./gradlew assembleRelease
post_build:
commands:
- npm install -g appcenter-cli
- appcenter login --token tokenhere12345
- appcenter apps list
- appcenter distribute release --app Test/Android-Test --file SourceCode/MobileApp/android/app/build/outputs/apk/release/app-release.apk --group "test"
artifacts:
files:
- SourceCode/MobileApp/android/app/build/outputs/apk/release/*.apk
discard-paths: yes
Now, you might be wondering, maybe I put the wrong path? Well no because on the artifactsblock, i can upload my .APK to s3 bucket with no problem, that is why I know the path is correct, otherwise it would reject it. I suspect that the path (in the app center distribute command) needs to be formatted, but I'm not sure if that is the case as Microsoft and AppCenter docs do not mention any format for the path. Anyone know what am I missing? TIA!

Signed Apk not found in directory React Native - Android

I am using react-native 0.60 version and my Gradle version is 5.4.1. Now I'm trying to extract signed apk. When I execute, all the steps the apk build successfully. But When I checking this path F:\React Native\AwesomeProject1\android\app\build\outputs\apk
please check this screenshot https://prnt.sc/p391mr.
Use this command to generate release apk
react-native run-android --variant=release
 Note that --variant=release is only available if you've set up signing as described above.
You can kill any running packager instances, since all your framework and JavaScript code is bundled in the APK's assets.
Please follow this link
https://facebook.github.io/react-native/docs/signed-apk-android
You using this command
$ cd android
$ ./gradlew bundleRelease
You only generate android apk bundle (AAB)not an apk.The generated AAB can be found under 
android/app/build/outputs/bundle/release/app.aab
On windows if you're going to use gradlew directly you need to run the windows variant of the command. See https://developer.android.com/studio/build/building-cmdline
So you should be running gradlew bundleRelease
From your screenshot you are running the *nix variant of ./gradlew bundleRelease. Note the removal of the leading ./ in the Windows version.

How to build react native android app for producation in ubuntu

I have a react native project in ubuntu, and I want to build android app for production.
I have read this article Generating Signed APK, which say run the following in a terminal:
$ cd android
$ ./gradlew assembleRelease
But when I run this I got this error message
sudo: ./gradlew: command not found
My question is what package I have to install on ubuntu to start build andriod's app

'gradlew' is not recognized as an internal or external command error in Android Studio terminal

Getting error - 'gradlew' is not recognized as an internal or external command. operable program or batch file. inside Android Studio terminal.
Can anyone please tell why it's not recognizing gradlew
gradlew command is available in your project directory. If you are trying to run this command from somewhere else it will throw error.
Also gradlew command package is automatically generated by Android studio when you create a new project. It will also prompt you to generate new gradle wrapper when you open the project.
you have to use ./gradlew instead of gradlew , if you are using Mac or Linux
It's under the Android folder, so you have to do cd Android first from your project root folder, then :
PS C:\code\my_app\android> ./gradlew signingReport
in vscode do this step
go to your project directory
cd to android
type ./gradlew in your terminal instead of gradlew
voila, it works for windows user
Assume that you app's name is video_compresser, so when you open terminal on Windows PC(because I am trying this on Windows) it shows the prompt like this.
C:\Users\Nuwan\StudioProjects\video_compresser>
If you run gradlew from here you will get the below message
'gradlew' is not recognized as an internal or external command,
operable program or batch file.
so you have to go to android directory by typing cd android command from terminal.
then the prompt should be like this,
C:\Users\Nuwan\StudioProjects\video_compresser\android>
then type gradlew followed by other commands you need and the error should be gone.
Try using,
./gradle clean
./gradle assembleRelease
worked for me.
make sure you have debug.keystore file in
PS C:\code\my_app\android>
before you run
./gradlew signingReport
Instead of the powershell, use the Windows Command Prompt to run the command.
(This is an accidental finding. I used the visual studio code terminal to run the command gradlew assembleRelease to build the apk of a react-native project, but it outputs an error similar to above. I tried bash terminal, again failed to run. Out of curiosity, I used the Windows command prompt, then it worked. Hope this will help if other solutions are not working).
If you use powershell, and the gradlew file is in the terminal current work directory, try .\gradlew instead of gradlew. Powershell don't run the command in the current work directory automatically.
ionic cordova build android --prod --release --alias=cos-android --password=abcd --versionCode=00001 --versionName=00001 -- -- -- --packageType=bundle
cordova build android --prod --release --alias=cos-android --password=abcd --versionCode=00001 --versionName=00001 -- -- --packageType=bundle
gradlew command is only available in your project directory or gradlew file location. If you are trying to run this command from somewhere else it will throw error.
so go to that particular location where gradlew file available
go to android directory by typing
"cd android" in terminal.
then the prompt should be like this,
PS C:\src\offx> cd android
PS C:\src\offx\android>
(//then type) ".\gradlew signinReport"
PS C:\src\offx\android> .\gradlew signinReport
Then you will get your sha keys
I am using windows OS and have to run a Java project in IntelliJ. I used the command prompt in admin mode then it worked for me.

'node' is not recognized as an internal or external command error with jenkins

I am trying to set up continuous code integration with the help of jenkins v1.592
I have an android hybrid code, which I'm, trying to build with jenkins.
I have set up environment variables for ANT_HOME, JAVA_HOME, ANDROID_HOME, and added then to the PATH respectively. I also have added nodejs and npm to the PATH.
ant version 1.9.2
java version 1.8.0_25
npm version 1.4.28
cordova android version 3.5.1
C:\Users\userName>path
gives
C:\Users\userName\AppData\Roaming\npm;C:\Program Files\nodejs;C:\whateverElse...
jenkins $WORKSPACE = C:\Program Files (x86)\Jenkins\jobs\myProject\workspace\
now I set my cmd prompt to jenkins workspace and execute the following commands
cd myProject
cordova build android
I get BUILD_SUCCESSFUL after 24 seconds
Similarly, when I go to my local jenkins server
The jenkins dashboard is shown and I have set up myProject there and
in the project configuration I have added the lines
"cd myProject
cordova build android"
in the build step and saved the configuration.
When I try to build I get the following error
Started from command line by anonymous
Building in workspace C:\Program Files (x86)\Jenkins\jobs\myProject\workspace
Updating repository at revision '2014-12-02T15:20:23.437 +0530'
At revision 263
no change for repository since the previous build
[workspace] $ cmd /c call C:\Windows\TEMP\hudson3297478415472069526.bat
C:\Program Files (x86)\Jenkins\jobs\myProject\workspace>cd myProject
C:\Program Files (x86)\Jenkins\jobs\myProject\workspace\myProject>cordova build android
'node' is not recognized as an internal or external command,
operable program or batch file.
Build step 'Execute Windows batch command' marked build as failure
Archiving artifacts
Finished: FAILURE
Any help would be appreciated
The same issue exists on mac OSX
Best Regards
Several things can be at play here
Did you add node to %PATH% through command line, or through the Windows UI? If done through UI, it can take affect immediatelly. If done through command line, it doesn't take affect until the next process spawns from shell, therefore Jenkins server restart is required.
Jenkins runs as "Local System" by default on Windows. You are listing C:\Users\userName as part of your paths, i.e. a user specific path. Did you set the %PATH% for all users, or just for your user userName? If it's not set for all users (or a specific user that Jenkins runs with), then Jenkins won't see it. You can change what user the service runs as.
2a. If Jenkins is running as "Local System" user, does that account have access to C:\Users\userName?
And lastly, if you set the %PATH% from command line, did you set it as a permanent entry using setx command?
In either case, from your job configuration, add a build step "Execute Windows Batch Command" and type just set (to display all environment variables) or #echo %PATH% (to see just the %PATH%) and verify that the environment is set correctly

Categories

Resources