Reputation: 136
I've came up with this problem as in my recent project in which I'm using react native 0.70, I need to change the android package name and all the solutions which I found were on pervious versions but the structure changed a little in React native 0.70 so I was getting errors
I tried many solutions which were provided many they were telling to change these files
Upvotes: 2
Views: 5256
Reputation: 136
So I've found the solution to this and sharing it here so if anyone going through the same can get help from this As the structure has changed a little in react native 0.70 we need to make changes in some extra files also So these are the changes which we need to make, i'ive used newApp but you've to use your package name there
In:android/app/src/main/java/yourApp/MainActivity.java:
package com.newApp
In:android/app/src/main/java/yourApp/MainApplication.java:
package com.newApp
In: android/app/src/main/AndroidManifest.xml:
package="com.newApp"
In: android/app/build.gradle:
applicationId "com.newApp"
In:android/app/_BUCK:
android_build_config(
package="com.newApp"
)
android_resource(
package="com.newApp"
)
In: android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h
static constexpr auto kJavaDescriptor =
"Lcom/newApp/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;";
In: android/app/src/main/jni/MainComponentsRegistry.h
constexpr static auto kJavaDescriptor =
"Lcom/yournewpackagename/newarchitecture/components/MainComponentsRegistry;";
In:android/app/src/main/java/yourApp/newarchitecture/MainApplicationReactNativeHost.java: make changes in these 4 lines
package com.newApp.newarchitecture;
import com.newApp.BuildConfig;
import com.newApp.newarchitecture.components.MainComponentsRegistry;
import com.newApp.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
In:android/app/src/main/java/yourApp/newarchitecture/components/MainComponentsRegistry.java:
package com.newApp.newarchitecture.components;
In:android/app/src/main/java/yourApp/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java:
package com.newApp.newarchitecture.modules;
after these steps just clean your project by typing this in your project terminal
cd android
./gradlew clean
now just go back and run your project and it would be a good approach to use android studio to run it for the first time
Upvotes: 7