Open jshearer opened 5 years ago
I have the same config as you on RN 0.58.3 and it's working for me.
Did you find any resolution for this @jshearer ?
Hey @m4rcoperuano, I haven't found a solution. TBH I've been procrastinating waiting for 0.59 RC to come out which I imagine will have the full JSC implementation switched over (I'm imagining this issue is happening because the upgrade to internally managed JSC was partially implemented in 0.58, but just not enabled, leaving some remnant files, but I really have no clue). I'm going to try upgrading to 0.58.3 (I'm on 0.58.1 atm) right now, will report back.
Upgrading to 0.58.3 has the same result. I actually deleted/re-cloned my project to make sure there aren't any gradle caches included, same result.
@hhunaid are you sure your app is actually using the modern JSC and not just silently using the one baked into RN and you just didn't notice? Do Proxy objects work?
Yes I am sure. Since I am using ‘for of’ loops. Which don't work without the new JSC. I should also add that I upgraded gradle version and android gradle plugin version as well when upgrading the RN
Can you tell me what versions of gradle and android gradle plugin?
Mine are currently set to:
classpath 'com.android.tools.build:gradle:3.2.1'
and
gradleVersion = '4.7'
Gradle v 4.7 And gradle plugin version 3.2.1
When upgrading, i usually create a blank project and copy the config off of there.
Alright, I'll try that then. Thanks :)
That is strange to say the least. I'm away atm. I'll post the complete build.gradle when i get home.
EDIT: The fact that versions are same but it still doesn't work is strange 😅
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js",
bundleInStaging: true,
devDisabledInStaging: true
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
project.ext.envConfigFiles = [
debug: "environments/.env.android.dev",
release: "environments/.env.android.prod",
staging: "environments/.env.android.dev"
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "redacted"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled true
versionCode 68
versionName "2.1.18"
ndk {
abiFilters "armeabi-v7a", "x86"
}
resValue "string", "build_config_package", "redacted"
manifestPlaceholders = [app_icon: "@mipmap/ic_launcher"]
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
debug {
if (project.hasProperty('MYAPP_DEV_STORE_FILE')) {
storeFile file(MYAPP_DEV_STORE_FILE)
storePassword MYAPP_DEV_STORE_PASSWORD
keyAlias MYAPP_DEV_KEY_ALIAS
keyPassword MYAPP_DEV_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
manifestPlaceholders = [app_icon: "@mipmap/ic_launcher_prod"]
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
applicationIdSuffix 'dev'
}
staging {
initWith release
applicationIdSuffix 'dev'
matchingFallbacks = ['release']
manifestPlaceholders = [app_icon: "@mipmap/ic_launcher"]
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
// Fixed build error : Duplicate files copied in APK META-INF/xxx
packagingOptions {
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/x86/libc++_shared.so'
pickFirst '**/libjsc.so'
}
}
configurations.all {
resolutionStrategy {
force 'org.webkit:android-jsc:r236355'
}
}
dependencies {
implementation project(':bugsnag-react-native')
implementation project(':appcenter-analytics')
implementation project(':appcenter')
implementation project(':react-native-document-picker')
implementation project(':react-native-exit-app')
implementation project(':react-native-geocoder')
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation project(':react-native-linear-gradient')
implementation project(':react-native-action-sheet')
implementation project(':react-native-version-number')
implementation project(':react-native-pdf')
implementation project(':rn-fetch-blob')
implementation project(':react-native-code-push')
implementation project(':react-native-config')
implementation project(':react-native-image-picker')
implementation project(':react-native-vector-icons')
implementation project(':react-native-splash-screen')
implementation(project(':react-native-scanbot-sdk')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
}
implementation project(':react-native-keychain')
implementation project(':react-native-fingerprint-scanner')
implementation project(':react-native-pdf')
implementation 'com.android.support:multidex:1.0.2'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation("com.google.android.gms:play-services-base:${rootProject.ext.googlePlayServicesBaseVersion}"){
force = true;
}
implementation("com.google.android.gms:play-services-maps:${rootProject.ext.googlePlayServicesMapsVersion}"){
force = true
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
I have tried everything above mentioned, but it's still not working for me. react-native: 0.58.3 jsc-android: 236355.1.1 and MobX 5
Yes, I am experiencing the same problem with RN 0.58.4
My build is not working in
Family | COR-AL00 Model | COR-AL00 (HUAWEICOR-AL00) Architecture | armeabi-v7a Version | Android 9 (COR-AL00 9.0.0.157) Kernel Version | 4.9.97
Other architectures, it seems to work. I believe it is something to do with the Architecture. Maybe related to https://github.com/react-native-community/jsc-android-buildscripts/issues/50
It's weird that it's working fine on all android simulator, but a real device.
For RN Android 0.58 with arm64-v8a, x86_64, the JSC comes from RN package instead of org.webkit:android-jsc from maven.
Please also add pickFirst '**/libjsc.so'
as well.
This issue will be fixed at RN 0.59 hopefully.
thanks @Kudo , I hope it will be fixed at RN 0.59. We also hope that RN support 64bit binary. Now I am going to downgrade my RN project to 0.57.8 to use latest JSC on Android.
I also downgraded my app back to .57.x. Spent a day trying to fix it with no fix :(. Crossing my fingers for the next release!
This morning I just tested the 0.59.0-rc.1, it's working great our of the box without upgrading JSC-Android. https://github.com/facebook/react-native/releases
react-native init RN059 --version react-native@next
Yea - same issue for me on 0.58.4. The upgrade works on the simulator, but not on a real device. Shall try the RC and then all being well bide my time for the full 0.59 release.
Can confirm everything now works on the 0.59-rc2 release. Yay.
@mtford90 That's awesome! I can't wait to try the table release when it's out :)
Okay so anyone knows how the gradle file should be configured for using JSC correctly in 0.59? And what if we want to support the intl version of the package?
0.59 has the latest JSC. Why would you want to use this JSC?
@hhunaid in my case, I use decorators (i.e. @observer @action, etc.) with MobX that is only supported in later versions of javascript engines. Thats why I would want to use 0.59, so i can have the latest JSC instead of including my own each time.
I am sorry for the confusion. I was asking @danielgindi since he was asking about how to add this JSC in 0.59
It wouldn't hurt to know. I personally do not upgrade to the latest version of RN the minute it drops. I tend to let the dust settle a bit before I make the jump. After I get onto 0.59, it may take a while before I upgrade to 0.60, etc.
If a new JSC comes out in the mean time, it would be nice to be able to take advantage of it.
@m4rcoperuano I'm not asking how to use the old JSC! But the new one. 0.58 had a bug where it was using the old JSC in some cases. What I want to do is use the latest JSC, and make sure that I have intl support. Should I just remove the section from gradle referencing JSC?
I’m trying to select the android-jsc with intl support, on React-Native 59.0, nothing I do has convinced it to launch my configured version. It’s always launching the embedded version.
Does anybody have pointers? I’ve configured all the phases, and even the pickFirst workaround though I wasn’t seeing related errors.
I’m about to purge the build caches again, but I’m suspicious it’s not even attempting to build the JSC!
I am sorry current gradle maven override approach does not works for RN 0.59. It is not feasible to apply Intl version. Will try to see if there are some alternative solution in the meantime.
FYI.
For RN 0.59, please simply use this configuration.
Setup maven repo to local node_modules, in
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url "$rootDir/../node_modules/jsc-android/dist"
}
}
}
In
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
// Add below line before react-native dependency
implementation "org.webkit:android-jsc-intl:r241213"
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
android {
packagingOptions {
pickFirst '**/libgnustl_shared.so'
pickFirst '**/armeabi-v7a/libjsc.so'
pickFirst '**/arm64-v8a/libjsc.so'
pickFirst '**/x86/libjsc.so'
pickFirst '**/x86_64/libjsc.so'
pickFirst '**/libc++_shared.so'
}
}
BTW, let me send a PR to mention this to README later
This worked! You rock @Kudo -- thanks for investigating and finding this. I appreciate this and you.
@Kudo thanks for the assist!
Will this not be more future proof?
android {
packagingOptions {
pickFirst '**/libgnustl_shared.so'
pickFirst '**/libjsc.so'
pickFirst '**/libc++_shared.so'
}
}
@danielgindi That's right. thanks for the comment.
Unfortunately, implementation "org.webkit:android-jsc-intl:+"
does not work. Intl
is undefined...
@danielgindi Please make sure the implementation "org.webkit:android-jsc-intl:+"
being put before implementation "com.facebook.react:react-native:+"
, so that pickFirst will use JSC from android-jsc-intl artifact.
And retry with clean build as well.
If this does not works for your, could you please provide more information for troubleshooting:
dependencies { ... }
part in your build.gradleThank you
@Kudo It does not work... I have a gradle file like this:
android {
.
.
.
packagingOptions {
pickFirst '**/libgnustl_shared.so'
pickFirst '**/libjsc.so'
pickFirst '**/libc++_shared.so'
}
}
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.name == 'android-jsc') {
details.useTarget group: details.requested.group, name: 'android-jsc-intl', version: 'r236355.1.1'
}
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleCompatible
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.android.support:support-v4:${rootProject.ext.supportLibVersion}"
implementation "com.android.support:support-core-ui:${rootProject.ext.supportLibVersion}"
implementation "com.android.support:design:${rootProject.ext.supportLibVersion}"
//noinspection GradleDynamicVersion
implementation "org.webkit:android-jsc-intl:+"
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-base:${rootProject.ext.googlePlayServicesVersion}"
implementation "com.google.android.gms:play-services-maps:${rootProject.ext.googlePlayServicesMapsVersion}"
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-messaging:17.4.0'
implementation project(':bugsnag-react-native')
implementation project(':react-native-navigation')
.
.
.
}
@Kudo I'm looking at your README PR, it looks like some steps are missing. Will try and let you know!
@danielgindi
Thanks, just to double confirm you are using RN 0.59 right? If yes, this part is not necessary
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.name == 'android-jsc') {
details.useTarget group: details.requested.group, name: 'android-jsc-intl', version: 'r236355.1.1'
}
}
}
}
@Kudo Right :-) Just got that from the new README, but having issues debugging it as suddenly I get:
error: bundling failed: Error: Unable to resolve module `./../../../../../usr/local/lib/node_modules/@react-native-community/cli/node_modules/react-transform-hmr/lib/index.js` from `/Users/dcg/Desktop/git/sample_project/index.js`: The module `./../../../../../../../../usr/local/lib/node_modules/@react-native-community/cli/node_modules/react-transform-hmr/lib/index.js` could not be found from ...
Sounds familiar? Trying everything right now, resetting caches, deleting residue, no success yet.
@Kudo So after removing the extra resolutionStrategy
and the pickFirst '**/libgnustl_shared.so'
, the only thing that got in my way was: Location of implementation "org.webkit:android-jsc-intl:+"
.
In your README pr, it is mentioned that it should be before react-native dependency, which you also mentioned here and it makes sense.
The thing is - it WAS in the correct place, but moving it before all com.android.support:...
dependencies did the trick.
In the README it's also before the support libs, but not mentions explicitly :-)
I tried it back and forth, and it is definitely this.
Although this only works for me in release mode, as react-native start
refuses to work, complaining about a missing file which is not missing (usr/local/lib/node_modules/@react-native-community/cli/node_modules/react-transform-hmr/lib/index.js
).
@danielgindi To be honest, I am not pretty sure how gradle pickFirst to determine which one will be the first. I will update my PR to put the dependency at the first. Thanks for your testing.
Regarding the missing file issue, I think it's not related to JSC.
How about try to react-native start --reset-cache
or either to reinstall react-native-cli?
@Kudo Yes I've reset caches, deleted node_modules, delete @react-native-community/cli
from global and reinstalled. Nothing works. Anyway, I'll let you know if it gets solved somehow in the future...
As for the PR - just needs an explicit say about pickFirst placement not just before RN but before just about everything. Might be a bug in Gradle, but hell with it, let's make people's lives a bit easier :-)
FYI.
For RN 0.59, please simply use this configuration.
- Setup maven repo to local node_modules, in /android/build.gradle
allprojects { repositories { mavenLocal() google() jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven { url "$rootDir/../node_modules/jsc-android/dist" } } }
- In /android/app/build.gradle, make sure jsc-android is before RN.
dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) // Add below line before react-native dependency implementation "org.webkit:android-jsc-intl:r241213" implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" implementation "com.facebook.react:react-native:+" // From node_modules }
- In /android/app/build.gradle, do pickFirst for libjsc.so
android { packagingOptions { pickFirst '**/libgnustl_shared.so' pickFirst '**/armeabi-v7a/libjsc.so' pickFirst '**/arm64-v8a/libjsc.so' pickFirst '**/x86/libjsc.so' pickFirst '**/x86_64/libjsc.so' pickFirst '**/libc++_shared.so' } }
@Kudo it worked for me by only replacing with implementation "org.webkit:android-jsc-intl:+"
. RN 0.59.0
@Kudo I can't use react-native-v8
neither Hermes due to a library constraint; will this work with RN59.10, as seen here?
Running a detached expo project, before upgrading to Expo SDK 34 it used to work. Now trying to run intl version at r245459. Somehow the build keeps using javascript core 236355.1.0 no matter what I do (I filter logcat to see that version as indicated in the README of jsc-android buildscript github repo). I don't know where it is coming from... I tried @Kudo's solution but it doesn't work...
----- edit ------
I fixed it by upgrading to the latest SDK 34.0.2 and here is the build.gradle
https://gist.github.com/pencilcheck/55aacbf0f523119a225fae4c3cf9fdb9
After encountering and fixing the problem in #80, it appears that RN is actually still using the built in JSC instead of the one specified in
The proxy object doesn't seem to work, which would indicate an old JSC. In addition, native async/await is missing. Does this relate somehow to the upcoming integration of modern JSCs into RN core? Or maybe the
pickFirst
option is somehow picking the... wrong .so file? I don't have enough experience with the Android build process to know what might be the problem here. Has anyone else experienced this? Here's an example of what happens when I try to use this build: I'm using Mobx 5, which relies on Proxy objects for its functionality.I'm using npm version
"jsc-android": "236355.1.1
,are the modifications to the
build.gradle
files I've made.