Monday, May 4, 2020

Develop android applications with react-native, without installing android studio - Troubleshooting

 In this previous post we discussed about hot to install Android SDK without installing Android Studio. It is pretty much sure most of the audience couldn't complete it without facing some difficulties. This post contains the Questions and answer help for few problems you could face.

Q: Keystore file '/<project-root>/android/app/debug.keystore' not found for signing config 'debug'
A: https://github.com/facebook/react-native/issues/25629 contains this answer. You have to go <project-root>/android/app/ and run this command

keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
and run npx react-native run-android warning-mode=all

Q: Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory,
I have installed jdk 8 and java & javac commands also working
A: add "JAVA_HOME" system variable as "C:\Program Files\Java\jdk1.8.0_241" matching with your installation folder
Open a new terminal and try npx react-native run-android warning-mode=all

Q: I was debugging my application in real device, next time I started debugging, it fails to start debug application in the device
A: uninstall the previous installation and start debugging script in the machine
adb shell pm uninstall <your-package-name>
ex: adb shell pm uninstall com.abc
Then re-run npx react-native run-android warning-mode=all

Q. Still I cant start my debugging session
We need to retry with some advanced cleaning
adb shell pm uninstall <your-package-name>
cd <project-root>/android
.\gradlew clean
npm install --save-dev jetifier
npx jetify
npx react-native run-android warning-mode=all 


Q. Making the production release
.\gradlew clean
.\gradlew assembleRelease 


Q. Vector icons not rendered, unknown square symbol
goto: android/app/build.gradle
add: apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"








Q. Error: rngesturehandlermodule.default.direction
open android/app/src/main/java/com/ks2/MainActivity.java
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

// after protected String getMainComponentName()
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
  return new ReactActivityDelegate(this, getMainComponentName()) {
    @Override
    protected ReactRootView createRootView() {
      return new RNGestureHandlerEnabledRootView(MainActivity.this);
    }
  };
}


No comments:

Post a Comment