at the moment I am facing a problem which I try to solve since 3 days already.. I want to rename my package name for my react native android application.
So, to be completely sure I am doing everything correct I have created a new project and tried to rename the package name. I have done this to be sure the error is not coming from my project and I haven't been able to fix my error yet.
I have initialized a new project like always: react-native init MyAwesomeProject
.
Then I have replaced com.myawesomeproject
in the following files with com.awesome.project
.
/android/app/BUCK:
android_build_config(
...
package = 'com.awesome.project',
)
android_resource(
...
package = 'com.awesome.project',
)
android/app/src/main/AndroidManifest.xml
package="com.awesome.project"
android/app/build.gradle
defaultConfig {
applicationId "com.awesome.project"
...
}
Also I have replaced package com.myawesomeproject;
with package com.awesome.project;
and moved the MainActivity.java
and MainApplication.java
file from android/app/src/main/java/com/myawesomeproject/
to the new path android/app/src/main/java/com/awesome/myawesomeproject/
.
After I have done all those changes I runned ./gradlew clean
inside my android folder followed by this command react-native run-android
.
However, I am still facing exact the same problem I am facing in my actual project.
> Task :app:compileDebugJavaWithJavac FAILED
/Users/max/Desktop/Max/MyAwesomeProject/android/app/src/main/java/com/myawesomeproject/MainApplication.java:19: error: cannot find symbol
return BuildConfig.DEBUG;
^
symbol: variable BuildConfig
1 error
FAILURE: Build failed with an exception.
Also, I have already tried to add the following code to the top of the MainApplication.java
file:
import com.facebook.react.BuildConfig;
But I have added the code to the MainApplication.java
located in android/app/src/main/java/com/myawesomeproject
like it is saying it in the error output. If you do that, the console is not throwing any error after running react-native run-android
, however, the App myawesomeproject
gets installed and if you try to open it, the app crashes.
This clearly shows that react is still using the wrong path!
I even have tried the npm rename package and runned the following command:
react-native-rename "project" -b com.project
.
Not even this is solving my problem. I still get exactly the same error when running react-native run-android
.
You guys can see the problem is not coming from my project cause I have exactly the same problem after I have set up a new project which is completely build from the scratch!
I would appreciate any kind of help! Thank You guys.