0

Below you can see the output I get when I try to run npx react-native run-android. It suggests some options to try in order to further pinpoint the problem, however they don't work with the aforementioned command so I assume that they are related to a gradle (just an educated guess).

I know ZERO about gradle; I have just seen the name here and there and in the output shown below. So please keep that in mind when you answer. If I need to learn how to run some gradle command(s) directly, please be as verbose as possible in your answer.

The project was working fine just a bit ago, but I wanted the ability to force portrait mode for certain screens but without configuring my entire app to always have to stick to portrait mode. So I found what looked to be a solution in the react-native-orientation-locker module. I installed it with yarn and then proceeded to update files as directed: https://www.npmjs.com/package/react-native-orientation-locker.

After updating the appropriate files, I got an error that suggested axios was the problem. I uninstalled and reinstalled axios. After that didn't work, I proceeded to undo all the file changes I had just made. Then I uninstalled the react-native-orientation-locker module.

To my knowledge, I have undone everything I did between the time the project worked and stopped working.

Sadly, I had not put this into source control yet (a mistake I won't make again), so I can't revert.

Where to go from here?

enter image description here

BVernon
  • 3,205
  • 5
  • 28
  • 64
  • I think the problem is in MainActivity.js file of some syntex problem? – Nisharg Shah Nov 26 '20 at 12:07
  • @NishargShah Thanks, but I don't think there is a MainActivity.js file in react-native. Or at least there isn't one I can find. Perhaps under the hood it transpiles to code that contains that file but I don't really know much about that. – BVernon Nov 27 '20 at 06:24
  • sorry its mainActivity.java – Nisharg Shah Nov 27 '20 at 07:11
  • can you please post your whole mainActivity.java file, if you don't know where is that file here is the question => https://stackoverflow.com/questions/30016492/cannot-find-mainactivity-java-in-android-studio – Nisharg Shah Nov 27 '20 at 07:13
  • @NishargShah I added it to my post, but it's just some boiler plate code that will never change. Thankfully, I was able to create a new project, reinstall dependencies, and copy over my source files to get back up and running pretty quickly so I'm okay now. I'm keeping the old project around for a while though in hopes that I will eventually figure out what the issue was and see if I can fix it just for learning purposes. – BVernon Nov 29 '20 at 07:41

1 Answers1

1

Problems like this are hard to pin point. What you can do is open the android project in android studio and see the logs as the project is being assembled. I assume you do not have much knowledge about android either so you might need some senior resource to help you. What I usually do in this case is open android studio and if I am lucky enough, it tells me which file has an issue and I go to the file and do what android studio suggests me. Some times it fixes the problem and sometimes it doesn't. Another thing I would like to mention is that the documentation of the package you are using is important to follow. I assume you did that already but I would suggest to review it narrowly and closely.

Another guess I can tell you is try to go to your-project/android/build.gradle and over there, you'll see something like this in the start. The package you are using mentions something about target SDK 27. I think you should check that out too. May be it helps

enter image description here

Lastly I would say always use source control while working with react native. It can easily blow up at any time so you should always have a safety net to fallback to :)

  • Yup, I'm teaching myself and unfortunately don't have any senior resource to call on. Originally didn't plan to complete this much work in a project that wasn't under source control... was just planning to do a "Hello World" project but, honestly, everything up to now has gone so smoothly that I have actually completed some amount of real work as part of my "test" project before realizing "crap, I should have put this in source control". Oh well... I think probably I will need to just create a new project and copy appropriate source files over. I will try your suggestions first though. Thanks! – BVernon Nov 26 '20 at 07:04