I get a duplicate error after running 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 and consecutively react-native run-android --variant=release.
Deleting the duplicate resources by running rm -rf android/app/src/main/res/drawable-* actually helps. However, my changes doesn't get bundled after deleting those files. Hence, when I run react-native run-android --variant=release again, my changes isn't effected in the build.
Only the drawable_* delete.
android/app/sec/main/res/ and it work.
Or
Generate keystore
Place keystore under your project/android/app/
Edit android/gradle.properties file with your password for keystore
Edit android/app/build.gradle in your project folder and add the
signing config
Run this code in the command line cd android && gradlew
assembleRelease
If you run into a problem in building APK like this error:
Unable to process incoming event 'ProgressComplete ' (ProgressCompleteEvent)
I recommend to
upgrade gradle to 4.3 to avoid building problems
or use Gradlew.bat assembleRelease instead
Related
I built a new APK after I added react-redux and persist. The debug build is working perfect but the release one seems it didn't get the new code cause its working like before.
I'm not sure, why it's happening?. I tried ./gradlew clean too but it didn't help.
Delete the build folder from the android/app directory. Delete Node Modules and do a fresh install. If this does not work then run metro bundler using the below command.
react-native start --reset-cache
The solution was to run react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ and then building the apk again
I am working on react native. When i try to create a build of android using
gradlew assembleRelease
then getting an
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'npx.cmd'' finished with non-zero exit value 1
But when i create a build using below command build succesfully build
gradlew assembleRelease -x bundleReleaseJsAndAssets
But build not run on mobile device as i am opening my app after install it just crashed.
Also when i try to create build on different System (8gm ram) with same code then it creates build with same command and the build will successfully created. Provide me a solution for this,
use cd android
after that use this ./gradlew clean
and for apk ./gradlew assembleRelease -x bundleReleaseJsAndAssets
or use this for aab ./gradlew bundleRelease -x bundleReleaseJsAndAssets
Try these commands and please tell me if it works
For me, I had to run npm run android once and then ./gradlew assembleRelease worked
UPDATE: Run following command and see output log to find the bug
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
Personally, I had to run the app form within Android Studio.
That gave me a clearer error message which allowed me to fix the issue.
The error in my case had to do with entryFile: "index.android.js", inside app/build.gradle.
I had to change it to index.js since that was the entry point in my RN project.
I inherited a react native project, the original programmers generated an apk for android, but they are not available anymore.
In the project I see react-native.config.js, package.json and an android folder with gradlew.
For the moment I'd like just to generate apk for android...but I don't know where to start...
You can create an assemble release following these commands. Open up a command line / terminal within you project and run the following commands.
Install node modules.
npm install
Link dependencies.
react-native link
Create the metro bundle.
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
Change the directory to android.
cd android
Clean the Gradle.
gradlew clean
Create the assemble release.
gradlew assembleRelease -x bundleReleaseJsAndAssets
You can find the APK in
PROJECT_PATH\android\app\build\outputs\apk\release
Follow these steps.
perform npm start in your root-dir of project
run npm i in same root-dir of project
can perform react-native link in root-dir location
now cd android
now gradlew assembleRelease
it will generate your .apk file at project_name/android/app/build/outputs/apk/release
Problem
I have just finished making a few changes in my React Native app and on the android emulator when reloading ( R, R) then changes appear.
I then ran the command:
./gradlew assembleDebug
to generate a debug apk.
When I run it on the phone then changes aren't there, it still is an old version.
I have tried:
Deleting the apk in:
./app/build/outputs/apk
Deleting the whole:
./app/build directory
Tried the command:
./gradlew cleanBuildCache
Rebooting after cleaning the cache (3) and deleting the build directory (2)
Tried the command:
gradlew clean
However I still get an old version of the apk generated each time.
I think you must generate the bundle manually since you run the app on your real device.
Unable to load script from assets index.android.bundle on windows
Go to your project directory and check if this folder exists android/app/src/main/assets
If it exists then delete two files viz index.android.bundle and index.android.bundle.meta
If the folder assets don't exist then create the assets directory there.
From your root project directory do
cd android && ./gradlew clean
Finally, navigate back to the root directory and check if there is one single entry file calledindex.js
If there is only one file i.e. index.js then run following command 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
If there are two files i.e index.android.js and index.ios.js then run this react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
Now run react-native run-android
I perform offline bundling of my react-native project using CMD
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
As bundinling is done offline i dont want JS server to start each time after running the command react-native run-android.
Is there any way out to avoid starting JS server
Internally, react-native run-android starts the packager and run installDebug task on gradlew.
To just run installDebug, on your project root directory run:
cd android && ./gradlew installDebug