I have an issue with an npm package react-native-video where it says 'no variant found for :react-native-video.' I've tried uninstalling and reinstalling, deleting node_modules and yarn.lock and clearing gradle, invalidating caches and restarting Android Studio, and any permutation of the above things.
The app builds and syncs perfectly find without react-native-video, but any time I reinstall it and add the files back in the app.gradle and other files (per the installation instructions) it gives me the same error. Has anyone had this issue before, and how do you fix it? I'm assuming it's an Android Studio/Gradle issue, but I'm at a complete loss as to how to fix it.
Please check your version of React Native and react-native-video.
In my case, I use React Native 0.64.1 and react-native-video 5.1.1, and it works well.
Other solution
Assuming you are on a later version of React Native, In android/build.gradle you need to add jcenter(), in this case best to be explicit and only include what is necessary:
...
allprojects {
repositories {
... other repositories
jcenter() {
content {
includeModule("com.yqritc", "android-scalablevideoview")
}
}
}
}
Related
I'm trying to fix an issue in React Native, I forked the RN repo, added some code to some java files, and run the rn-tester App, my fix was working fine on the rn-tester App, but when adding this fix to a react-native package inside node_modules directory and patching it using patch-package, my fix not working even if I deleted the node_modules and installed them again, I see my code inside react-native java files but it have no effect on the App.
Also, any Log.d or System.out.println messages appear on the rn-tester App but don't appear on the other App.
added some code to /node_modules/react-native/ReactAndroid/.../somefiles.java that fixed an RN issue on the rn-tester App.
run npx patch-package react-native and inside package.json file under scripts added "postinstall": "npx patch-package" .
deleted node_modules and run npm i .
checked /node_modules/react-native/ReactAndroid/.../somefiles.java and my code existed.
run npm run android .
The RN issue still exists.
Expected
The code fixed the issue on the rn-tester App so it should fix it on the other App.
Because Rect Native takes its Java dependency as an AAR archive any changes to node modules will be skipped. You need to build react native from source as described here: https://reactnative.dev/contributing/how-to-build-from-source
Regarding react-native + expo, I would like to use latest #type/react in order to resolve typing issues (i.e. 'MaterialIcons' cannot be used as a JSX component), but expo start always require I install the typescript libraries and then proceeds to insist they be an older version (17.0.21). Why? How can I either ignore this behaviour (btw. answering with 'n' ends the startup and directs to either install the typescript requirements or clean the config of typescript refs -- ok expo thanks for nothing!)
The problem that I was resolving with #types/react is detailed here: 'Stack.Navigator' cannot be used as a JSX component
update to "#types/react": "~18.0.12" ( fix for eslint )
but you cant run project
Bumped into this and after some research I found this github comment from the expo repo. Which made think about this resolutions fix.
In my yarn.lock I have two versions 17.0.21 and 17.0.47, and in my package.json I point to 17.0.21
resolutions": {
"#types/react": "~17.0.21"
},
Ran yarn once again
Opened the VSCode Command Palette -> Typescript:
Reload project
No problems with eslint and was able to run the project.
App font is working fine on all platforms before publishing.
Once the app is published, expo publish, font is just not showing.
I have added the font through Xcode. Like that.
Font is added to the app following expo's instructions
Checked, rechecked and reinstalled the yarn package seem to exist (checked by showing some text on screen). Added the package using yarn add 'use-expo/font'
This is how the font is loaded:
import { useFonts } from "#use-expo/font";
export default function App() {
let [fontsLoaded] = useFonts({
Rayando: require("./assets/fonts/crayonsRegular.ttf"),
});
return (
<>
{fontsLoaded && <Text style={[styles.answerText, {fontFamily: "Rayando"}]}>{number ? 1 : 0}</Text>}
</>)
}
Any advice on how resolve this issue, am I missing something?
Using latest version of expo (37.0.0) expo-cli and yarn.
I was also running into a similar problem. As far as I understood expo publish does not behave as expected in ejected projects: the app loads assets differently.
Found out about this in here.
The suggested solution is running expo publish --target managed or, as of my case, deleting ios and android folders to convert bare project to expo-managed.
I've tried looking for a way to solve this error. It's occurring to me while I try to install my app with react-native run-android.
Already took a look at the solutions from this thread, but my project isn't named native, ./gradlew clean from the android folder didn't work, and I tried deleting the .gradle folder. I've also tried my own simple solutions that sometimes work for whatever reason - uninstalling the app from my phone before re-running react-native run-android and reopening VSCode.
This error started occurring after I installed react-native-unimodules, following the android instructions. A potential problem I see from this is just that react-native-unimodules is supposed to be for Expo and I'm doing things with React Native CLI, but from what I understood, this is allowed.
My react-native version is 0.61.5, react-native-cli is 2.0.1.
Edit:
build.gradle file, as requested.
Also, I don't know if it's relevant, but since it was part of one of the suggested answers, I'll mention this as well: in the gradle.properties file,
android.useAndroidX=true and android.enableJetifier=true were already present.
This is a pretty common case, but what ive figured out during my app building, these steps always helped.
First you need to add below lines in gradle.properties file
android.useAndroidX=true
android.enableJetifier=true
Then after that you need to install, jetfier via either yarn or npm like :
npm i jetifier // first this then the below
npx jetify
After that again re-bundle your code and then run, hope it helps. Feel free for doubts
I have been trying to migrate from react-native 0.59.4 to 0.61.2.
After solving many many build and runtime problems on ios and android, this was the final problem before the successful launch of my react-native app on android. The app would build successfully but when it is time to launch on the emulator it would pop for a very brief moment then a white screen and application crashed with an app keeps crashing type of popup message. I can't even debug the app remotely on the chrome console since it doesn't launch in the first place.
Any ideas?
Note: This solution worked for my specific problem. To find out your problem try adb logcat *:E to see what is wrong in your case.
Ok, there is a very important command (I am on mac) that helps you see in the logs what is going on even if you can't launch the app on emulator: adb logcat *:E
In my case there were 2 main problems that caught my attention in the logs.
Channel is unrecoverably broken and will be disposed
and
couldn't find DSO to load: libhermes.so
Once I got these messages on my radar I started to dig/google for them.
After going through a lot of SO and GitHub topics here is what worked for me:
First, make sure you have made all the necessary modifications in your:
gradle.properties
app/build.gradle
android/build.gradle
package.json
etc
files (Use react-native upgrade helper to do this).
Then, if it is not installed already, do npm install jsc-android to install the required jsc package on your project.
Add the below in android/build.graddle inside allprojects -> repositories
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
Inside gradle.properties add
android.useAndroidX=true
android.enableJetifier=true
In some cases you may need to add below line to package.json
"postinstall": "npx jetify"
Also, in some cases it may help to replace the below line (dependencies section of app/build.gradle) with the exact version of the react-native you are using:
implementation "com.facebook.react:react-native:+"
Replace like so:
implementation "com.facebook.react:react-native:**0.61.2**"
I hope this helps to solve or at least make some progress with your problem.
Cheers.