jsc-android-buildscripts
jsc-android-buildscripts copied to clipboard
Android using old JSC on RN 0.58.x
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
configurations.all {
resolutionStrategy {
force 'org.webkit:android-jsc:r236355'
}
}
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
,
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"
}
}
}
packagingOptions {
pickFirst '**/libjsc.so'
}
configurations.all {
resolutionStrategy {
force 'org.webkit:android-jsc:r236355'
}
}
are the modifications to the build.gradle
files I've made.
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.