Undefined appVersion on Android crashes app
sbehrends opened this issue · 9 comments
same for me.
I ran "react-native link" and then react-native run-android and it worked
same problem
Tried to fix it myself, but could not do it.
I confirm that the package is proper linked, react-native link
was executed and the package appears on Android Studio as part of the project.
This code does something really similar. Still cannot make it work :(
https://github.com/kimxogus/react-native-version-check/blob/master/packages/react-native-version-check/android/src/main/java/io/xogus/reactnative/versioncheck/RNVersionCheckModule.java
same problem
Actually, I tried to fix it and failed. I wanted to get build number and app version.
If you still struggle with it, with alternative way you can use react-native-device-info.
https://github.com/rebeccahughes/react-native-device-info
import DeviceInfo from 'react-native-device-info';
DeviceInfo.getVersion()
DeviceInfo.getBuildNumber()
Can you give us a repro example?
@sbehrends sometimes
react-native link
doesn't link all the dependencies correctly can you check if in your MainApplication.java
you have the following lines
import com.apsl.versionnumber.RNVersionNumberPackage; // <-- This Line
// @NonNull
@Override
public List<ReactPackage> createAdditionalReactPackages() {
// Add the packages you require here.
// No need to add RnnPackage and MainReactPackage
return Arrays.<ReactPackage>asList(
Other Packages here,
new RNVersionNumberPackage() // <- This line
);
}
@alvaromb for the above mentioned issue, it got fixed as react-native link hadn't linked the dependencies correctly. In your README you can give a section for install manually.. I can give a PR if that's ok..
Sure @nitish24p!
That would be very nice.