I have a solution based on @Cherniv answer (works on macOS for me). Two differences: I have a Main2Activity.java file in the java folder with which I am doing the same, and I am not worried about the call. / gradlew clean, as it seems that this responder package does this automatically anyway.
In any case, my solution does what Cherniv does, except that I created a bash script shell for it, since I create several applications with one set of code and want to be able to easily change the package name whenever I run my npm scripts.
Here is the bash script I used. You will need to change the name of the package you want to use and add everything you want, but here is the basic information. You can create a .sh file, give permission, and then run it from the same folder in which you run response-native from:
rm -rf ./android/app/src/main/java mkdir -p ./android/app/src/main/java/com/MyWebsite/MyAppName packageName="com.MyWebsite.MyAppName" sed -i '' -e "s/.*package.*/package "$packageName";/" ./android/app/src/main/javaFiles/Main2Activity.java sed -i '' -e "s/.*package.*/package "$packageName";/" ./android/app/src/main/javaFiles/MainActivity.java sed -i '' -e "s/.*package.*/package "$packageName";/" ./android/app/src/main/javaFiles/MainApplication.java sed -i '' -e "s/.*package=\".*/ package=\""$packageName"\"/" ./android/app/src/main/AndroidManifest.xml sed -i '' -e "s/.*package = '.*/ package = '"$packageName"',/" ./android/app/BUCK sed -i '' -e "s/.*applicationId.*/ applicationId \""$packageName"\"/" ./android/app/build.gradle cp -R ./android/app/src/main/javaFiles/ ./android/app/src/main/java/com/MyWebsite/MyAppName
DISCLAIMER: First you need to first edit the MainApplication.java comment at the bottom of the java file. The comment has the word "package." Due to how the script works, it takes any line with the word "package" in it and replaces it. Because of this, this script cannot be verified by the future, as it may be the same word that is used elsewhere.
Second Disclaimer: The first 3 sed commands edit java files from the javaFiles directory. I created this directory myself, since I want to have one set of java files that were copied from there (since I could add new packages to it in the future). You might want to do the same. So copy all the files from the java folder (go to its subfolders to find the actual java files) and place them in a new folder called javaFiles.
Third failure: you will need to modify the packageName variable to match the paths at the top of the script and at the bottom (com.MyWebsite.MyAppName for com / MyWebsite / MyAppName)
Kjell Jun 03 '17 at 18:59 2017-06-03 18:59
source share