To run react-native first download and install node.js in windows.
After installing node.js open cmd and run this following command:
// https://instamobile.io/android-development/generate-react-native-release-build-android/
https://stackoverflow.com/questions/53239705/react-native-error-duplicate-resources-android
This command for initiating the project
npx react-native init projectname
yarn global remove react-native
yarn global remove react-native-cli
npm uninstall -g react-native
npm uninstall -g react-native-cli
check that nothing related to react-native presents in these lists:
yarn global list
npm -g list
install new react-native global
npm install -g react-native-cli
npm install -g react-native
then also download vscode and install react-native tools in vscode:
Now using cmd go the project folder and run the project using the following command:
keytool -genkey -v -keystore your_key_name.keystore -alias your_key_alias -keyalg RSA -keysize 2048 -validity 10000
you need to copy the file your_key_name.keystore and paste it under the android/app directory in your React Native project folder
For some reason I needed to create the assets
folder as per below.
android/app/src/main/assets
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
C:\Users\User\myandroidpapp>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
Generate the build using gradle
cd android && ./gradlew assembleRelease
in windows
cd android && gradlew assembleRelease
What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> [drawable-mdpi-v4/node_modules_reactnative_libraries_newappscreen_components_logo] C:\Users\ranjan\react-native\projectname\android\app\src\main\res\drawable-mdpi\node_modules_reactnative_libraries_newappscreen_components_logo.png [drawable-mdpi-v4/node_modules_reactnative_libraries_newappscreen_components_logo] C:\Users\ranjan\react-native\projectname\android\app\build\generated\res\createBundleReleaseJsAndAssets\drawable-mdpi\node_modules_reactnative_libraries_newappscreen_components_logo.png: Error: Duplicate resources
I deleted drawable-mdpi, mipmap-mdpi then build duplicate resources error gone and build successfully
SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\ranjan\react-native\projectname\android\local.properties
sdk.dir=C\:\\Users\\ranjan\\AppData\\Local\\Android\\Sdk
Upload the APK to your phone. The -r
flag will replace the existing app (if it exists)
adb install -r ./app/build/outputs/apk/app-release-unsigned.apk
For me, the solution was to add the "package" tag to the manifest tag. I didn't have to create another dummy folder.
The manifest open tag now looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourProjectName">
Comments