-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run #1
Comments
Which file do you add that to? |
|
Tried following these steps in my own project and |
It was working for me again in a new rns project |
Below is full list of content in
Used:
|
Cool! So still no I'll keep bashing at it over the next few days to try to get it to build as a modular NativeScript plugin with typings and stuff, rather than something that you add directly to your app. In the meantime, you might want to play around with creating views and seeing whether you can insert them into the view tree! Would be worth researching what |
Sure I can try that out! |
I'm still unable to build it as a plugin – just keep finding However, I was at least able to use You'll notice that if you search for |
@Lelelo1 Could you share the whole contents of your |
A thought occurred to me just now, as to my understanding I’m failing to get the JAR from node_modules/react-native compiled into the app’s runtime... maybe I could try copying that JAR as-is into the plugin (the app’s build script looks for JAR files inside the plugin, so it would pick that up). The downside is that the plugin would never be able to stay in sync automatically with all future versions of RN (we’d have to regenerate it with each version update), but for a proof of concept plugin, it might be worth a try to get things moving. I’ll give it a go tomorrow if I can. |
I think that |
Yeah, that's the one I was thinking about in this comment:
To generate the typings, I actually entered your gradle settings into |
I'ts a bit to hard to comprehend what happens and what should happen, but we might figure something good out |
I've been trying to build it as a plugin here: https://github.com/nativescript-community/react-native-in-nativescript Could you try running my project? Wondering whether your environment works better than mine. git clone https://github.com/nativescript-community/react-native-in-nativescript.git --recursive
cd react-native-in-nativescript
npm install
npm run setup
npm run build
cd demo-react
tns build android
# Or go into Android Studio and run the app to get full error logs
tns run android --no-hmr On my side I'm getting JNI errors from React Native at startup; I can't get as far as logging out
|
Forget about cloning my project. I've just cloned your project and found yours to be working as you've described, so I compared to mine. I wasn't able to run yours successfully with the files you've committed so far (I think you've committed some build files). I had to run I decided to try each of your changes individually (the changes to I found that:
The result:
So this is the worrying thing. I think NativeScript is totally ignoring your changes to the .gradle files that tell it to build React Native from node_modules. Instead, I believe it's downloading this old build of react native from 2015: https://mvnrepository.com/artifact/com.facebook/react. I've not had any luck building from the AAR in |
I’ve had a thought. As I’m unsure whether your setup is installing the AAR from node_modules or from maven, maybe the simplest way to check would be to print out the React Native version number by console log. If you search through my typings file for the term “version”, there are only a small number of mentions. See if you can call an API to print out the version number for the build of React Native that your app is running :) |
Maybe: console.log(com.facebook.react.BuildConfig.VERSION_NAME);
console.log(com.facebook.react.BuildConfig.VERSION_CODE); |
There’s also this, if I’ve copied it correctly: console.log(com.facebook.react.modules.systeminfo.ReactNativeVersion.VERSION); |
About those version info namespaces they don't appear to correspond to the current react-native repo completely. There could som reasons to it and I don't know yet how frequently it is. However in the App_Resources, try:
You will see gradle log redlines trying to find react-native.jar on the local file system. And try to get I don't know what the |
I think that suggests that the version of React Native that this repo installs is much older than v0.63.4, which the typings were generated for. Note that when you ran this code, it logged multiple mentions of // This function handles arrays and objects // https://stackoverflow.com/questions/2549320/looping-through-an-object-tree-recursively
function eachRecursive(obj) // com.facebook
{
for (var k in obj)
{
if (typeof obj[k] == "object" && obj[k] !== null)
eachRecursive(obj[k]);
else
console.log(k);
}
} So could you try running this to get the full key paths for everything in const visitedValues = new Set();
function eachRecursive(path, value){
if(visitedValues.has(value)){
// Crude protection against following circular references in an infinite loop
console.log(`${path} [Already visited, so won't recurse]`);
return;
}
visitedValues.add(value);
for(let key in value){
const newPath = /^\d+$/.test(key) ? `${path}[${key}]` : `${path}.${key}`;
if (typeof value[key] === "object" && value[key] !== null){
eachRecursive(newPath, value[key]);
} else {
console.log(newPath);
}
}
}
eachRecursive("com.facebook", com.facebook);
When you mentioned this on Slack, you reported that it searched in these locations:
I should note that it didn't look in |
You are probably correct that it downloads from outdated online repo. If you look into are react native project though. The lines have to do something:
|
Actually those urls are not added unless being placed inside the
It will then look in two extra places: (in |
Now it uses local react native version 0.63.4. I noticed using So it is now possible to log:
|
Okay, trying on my project now. Attempt 1 🚫
Attempt 2 🚫
Attempt 3 🚫
Attempt 4 ✅
To be clear, that's this: allprojects {
repositories {
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../../node_modules/react-native/android")
}
}
}
android {
defaultConfig {
minSdkVersion 18
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
dependencies {
implementation "com.facebook.react:react-native:0.63.4";
} Encouraging to see this line during the very brief build output:
Successful build!
Now let's try running it... |
When having downloaded from the online repo (probably v0.12.2.4)
When having included the v0.63.4 AAR from node_modules (Attempt 4)
It's different! I've got yoga this time!! |
I've logged out all the runtime APIs (at least, all the ones I could find using my hasty recursive function): https://gist.github.com/shirakaba/41492e23f7610609163ecec40f16d89b 🙂 The NativeScript runtimes team told me that, at least for iOS, though, that some of the APIs are lazy-loaded. So they may not all appear just by iterating over the objects – you'd have to call the selectors exactly to make them appear. Still, though: console.log(com.facebook.react.modules.systeminfo.ReactNativeVersion.VERSION);
console.log(com.facebook.react.BuildConfig.VERSION_NAME);
console.log(com.facebook.react.BuildConfig.VERSION_CODE); ... prints:
|
npm install react-native
ns platform add android
In
my-app/platforms/android/build.gradle
add following from a react native project:To
App_Resources/Android/app.gradle
add following (as it does also does in a react native project)ns build android
(check for errors)ns run android
Log the contents of the
com.facebook
package on tap event:Press TAP ME FOR AN ALERT to log. Note yoga dependency missing in com.facebook
The text was updated successfully, but these errors were encountered: