Closed Samykills closed 5 years ago
@Samykills Hi, are you using expo? Can you provide more code snippets so we can reproduce it?
@powerful23 this is not an expo app, as soon as i import the library it blows up. have already added the logs and that i get when i see this error , a thing to notice is there is no error shown in metro when this happens
@powerful23 added a sample
@powerful23 here is a sample project, which is getting the same error. https://github.com/Samykills/AwsAmplifyExp
I got the same error, running not with expo
@dinukasal which version are you using?
To those who are still facing this issue
To resolve this followed following post https://github.com/facebook/react-native/issues/15786#issuecomment-404834632
basically this issue occurred since JavaScriptCore might be not updated on your device or emulator your best bet will be to try jsc-android-buildscripts to provide this compatibility below is the instruction to integrate same on Android
@ambeshHappiestMinds Does it solve the problem for you? i started receving this error two days ago and before that all was well. I am on target api version 27 and also i get the same on IOS
@Samykills yes it did i was able to create Andorid builds properly
@ambeshHappiestMinds ios?
opps sry for iOS i was able to create builds easily since our deployment target was greater tha iOS 10 on this we did not got this issue i suggest you may use react-native 0.57.5and check
this worked for me. thanks @ambeshHappiestMinds
@powerful23, @jordanranz - This is generating an issue with our build using react-native 0.58.X on Android.
While the workaround here may resolve the issue, I think updating to a custom JavaScriptCore version is a heavy-handed solution that's not feasible for all.
The root cause is that aws-amplify
is referencing Symbol
directly assuming that it's defined for every JS interpreter.
Here's the offending line: https://github.com/aws-amplify/amplify-js/blob/d8c972dff0ad4483db8a7122f5bf4952cc8a295a/packages/core/src/constants.ts#L18
In most other locations, Amplify checks the existence of Symbol
(example).
I believe this is definitely a bug in aws-amplify
.
@jessedoyle i replaced the code in node_modules/@aws-amplify/core/constants.ts with the one provided by you and still facing the same error, can you try the same with the sample-project i have added and verify? it would be great help :)
@Samykills - You're right - I think the guard clause is insufficient.
I think we'll need a condition similar to the other Symbol
reference checks through aws-amplify
:
export const INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER = (typeof(Symbol) !== 'undefined' && typeof(Symbol.for) === 'function') ?
Symbol.for('INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER') : '@@INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER';
I modified the corresponding code in node_modules/@aws-amplify/core/lib/constants.js
and it resolves the issue for our app.
I'm going to update my PR to include this condition.
Updating JSCore for android works!
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels or Discussions for those types of questions.
Describe the bug Using the library 1.1.27
Expected behavior No error should occur, since this was working fine untill now.
Screenshots
Smartphone (please complete the following information):
Sample code Adding the sample code here https://github.com/Samykills/AwsAmplifyExp
awsAmplify.js `import Amplify, { Analytics } from "aws-amplify"; import Config from "react-native-config"; import { Platform } from "react-native"; import { AppContext } from "react-native-ss-app-core"; class AwsAmplify { static initalize() { const amplifyConfig = { Auth: { identityPoolId: Config.AWS_COGNITO_IDENTITY_POOL_ID, region: "us-east-1" } }; //Initialize Amplify Amplify.configure(amplifyConfig);
}
/*
@param {String} value - Type of event- can be null or anything */ static recordEvent(eventName, action, title) { let attributesJson = {}; let appContext = AppContext.getAppContext(); attributesJson["action"] = JSON.stringify(action); attributesJson["title"] = title; attributesJson["zoneSelected"] = appContext.parentZoneName; attributesJson["os"] = Platform.OS; attributesJson["version"] = Config.CODE_PUSH_VERSION; attributesJson["eventTimeStamp"] = new Date().getTime().toString(); if (appContext.sessionData) { let sessionData = JSON.parse(appContext.sessionData); attributesJson["userId"] = sessionData.userId.toString(); sessionData.tenantId ? (attributesJson["tenantId"] = sessionData.tenantId.toString()) : null; sessionData.tenantDto ? (attributesJson["tenantname"] = sessionData.tenantDto.name.toString()) : null; }
Analytics.record({ name: eventName, attributes: attributesJson }); } }
export default AwsAmplify;` You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app. Adding debug log here :
Can't find variable: Symbol