react-native-rename
react-native-rename copied to clipboard
MainActivity.java problem
whenever I run this command npx react-native-rename 'appName' -b 'packageName'
this command deletes files MainActivity.java and MainApplication.java from this path 'android\app\src\main\java\com' please fixed this soon thank you
@iAyubAnsari Make sure that you use the latest version v2.7
I always use latest version .
Could you provide more details about your project? the old and new bundle id.
I have tested locally and all works fine with source code which was generated by react-native init
I have faced same issue my old bundle id is com.app and i am renaming to com.app.appname then it deletes MainApplication.java and MainActivity.java both and new one is also not created.
I used command with npx so it must be latest as i am not installing it as global package and using npx instead.
I also faced this bug. I noticed this happens when there is <space>
in your name. To fix this I did the following steps :
- Get the package name from
AndroidManifest.xml
from themanifest
tag. For my case the new name wascom.annotationapp
- Create a new
MainActivity.java
file by copying from the previous one and change the name in two places.
- package com.awesomeapp // Remove this
+ package com.annotationapp // Add this
...
protected String getMainComponentName() {
- return "Awesome App"; // Remove this
+ return "Annotation App"; // Add this
}
Also search if any another place your name is there, change there also
- Similarly go create a
MainApplication.java
by copying the previous one and change it:
- package com.awesomeapp // Remove this
+ package com.annotationapp // Add this
...
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
- Class<?> aClass = Class.forName("com.awesomeapp.ReactNativeFlipper") // Remove this
+ Class<?> aClass = Class.forName("com.annotationapp.ReactNativeFlipper"); //Add this
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
...
Search if any another place name is there, change it.
Then do a clean rebuild by cd android && gradlew clean && cd ..
and then do start the server by resetting cache npm run android --reset-cache
Is there any fix for this? The bug still occurs even if there is no space-character in the name.
All files from android\app\src\main\java\com\oldappname
get deleted but the empty android\app\src\main\java\com
directory is left. It also creates the new path android\app\src\main\java\com\myapp\appname
but it's completely empty.
I'm using the latest version.
+1, same issue
+1 same issue
Please try the latest version v2.7.1 and let me know if it works for you
Please try the latest version v2.7.1 and let me know if it works for you
Didn't work =(
Please try a new version with a potential fix.
I was having a similar issue where after renamed the project, the folder that contains MainApplication.java doesn't got renamed correctly. It's keeping with the same old previous name.
Closing, check v3 now.