Skip to content
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

Adapty NativeModule is not defined #132

Open
yuhr opened this issue Nov 22, 2024 · 23 comments
Open

Adapty NativeModule is not defined #132

yuhr opened this issue Nov 22, 2024 · 23 comments
Assignees
Labels
bug Something isn't working

Comments

@yuhr
Copy link

yuhr commented Nov 22, 2024

Description

screen

I'm experiencing this while migrating our bare React Native 0.73.4 project to Expo 52 CNG setup. The installation guide doesn't help as we're not using EAS Build yet; we want to stick to expo run:* for now to avoid wasting the free quota of build count.

Could someone provide any clue about what might cause this error?

Few notes:

  • We're already using Adapty for years. Before integrating Expo, Adapty SDK just worked.
  • We're using pnpm 8.10.2 for package management.
  • I know react-native-adapty 2.11.3 is outdated, but upgrading to 3.0.1 didn't solve the issue.

Version

v2.11.3

What platforms are you seeing the problem on?

Android

System info

System:
  OS: macOS 15.0
  CPU: (8) arm64 Apple M1
  Memory: 82.44 MB / 16.00 GB
  Shell:
    version: 3.7.1
    path: /opt/homebrew/bin/fish
Binaries:
  Node:
    version: 18.18.2
    path: ~/.local/share/mise/installs/node/18.18.2/bin/node
  Yarn: Not Found
  npm:
    version: 9.8.1
    path: ~/.local/share/mise/installs/node/18.18.2/bin/npm
  Watchman:
    version: 2024.08.19.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/yuhr/.local/share/mise/installs/ruby/3.2.1/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.0
      - iOS 18.0
      - macOS 15.0
      - tvOS 18.0
      - visionOS 2.0
      - watchOS 11.0
  Android SDK:
    API Levels:
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 28.0.3
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 32.0.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-29 | Google APIs ARM 64 v8a
      - android-32 | Google APIs ARM 64 v8a
      - android-32 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2020.3 AI-203.7717.56.2031.7935034
  Xcode:
    version: 16.0/16A242d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /Users/yuhr/.local/share/mise/installs/java/adoptopenjdk-17.0.10+7/bin/javac
  Ruby:
    version: 3.2.1
    path: /Users/yuhr/.local/share/mise/installs/ruby/3.2.1/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 12.3.4
    wanted: ^12.3.4
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.2
    wanted: 0.76.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
@yuhr yuhr added the bug Something isn't working label Nov 22, 2024
@vladd-g
Copy link
Contributor

vladd-g commented Nov 22, 2024

Hi @yuhr, thank you for the report!

We're working on making expo auto-linking work! Could you try disabling the expo auto-linking for now?

@Bjarkinn
Copy link

Having the same issue on Android

  • expo: 52.0.11
  • react: 18.3.1
  • react-native: 0.76.3
  • react-native-adapty: 3.0.1

Disabling auto linking with the following did not fix the problem

react-native.config.js

module.exports = {
  dependencies: {
    'react-native-adapty': {
      platforms: {
        android: null,
      },
    },
  },
}

The app builds but the following error is thrown when the app loads Error: Adapty NativeModule is not defined, js engine: hermes [Component Stack]

Hope this gets resolved soon

@vladd-g
Copy link
Contributor

vladd-g commented Nov 25, 2024

Hi @yuhr @Bjarkinn

Could you please try 3.0.2-canary.0?

@Bjarkinn
Copy link

Hi @yuhr @Bjarkinn

Could you please try 3.0.2-canary.0?

Was able to run the app with 3.0.2-canary.0 and everyting seems to be working like before. GJ!

Will this be released soon?

@yuhr
Copy link
Author

yuhr commented Nov 26, 2024

@vladd-g 3.0.2-canary.0 is working as expected, thanks!

@MuhammedYesilyurt
Copy link

MuhammedYesilyurt commented Nov 27, 2024

@vladd-g Iam using this versions but still getting same error:
"@adapty/react-native-ui": "^3.0.1",
"react-native-adapty": "^3.0.2-canary.0",

@moe12572
Copy link

Screenshot 2024-11-29 at 5 22 54 PM Same issue! I'm using : "react-native-adapty": "^3.0.2-canary.0", "@adapty/react-native-ui": "^3.0.1",

i have an urgent roll out

@vladd-g
Copy link
Contributor

vladd-g commented Nov 30, 2024

@MuhammedYesilyurt @moe12572 Could you please try a clean and prebuild?

@moe12572
Copy link

moe12572 commented Nov 30, 2024

@vladd-g I'm using Expo Go on iOS (iPhone only). Still getting the same issue:
Adapty NativeModule is not defined.

Package.json...
{ "name": "scribble-mobile", "version": "1.0.0", "main": "expo/AppEntry.js", "scripts": { "start": "expo start", "tunnel": "expo start --tunnel", "updates": "npx eas update", "android": "DARK_MODE=media expo run:android", "ios": "DARK_MODE=media expo run:ios", "web": "DARK_MODE=media expo start --web" }, "dependencies": { "@adapty/react-native-ui": "^3.0.1", "@expo/ngrok": "^4.1.0", "@expo/vector-icons": "^14.0.2", "@gorhom/bottom-sheet": "^4.6.4", "@react-native-async-storage/async-storage": "1.23.1", "@react-native-clipboard/clipboard": "^1.15.0", "@react-native-community/masked-view": "^0.1.11", "@react-navigation/bottom-tabs": "^6.5.20", "@react-navigation/native": "^6.1.17", "@react-navigation/stack": "^6.3.29", "@rneui/base": "^4.0.0-rc.8", "@rneui/themed": "^4.0.0-rc.8", "@supabase/supabase-js": "^2.43.4", "@types/react": "~18.3.12", "base64-arraybuffer": "^1.0.2", "eas-cli": "^9.0.8", "expo": "^52.0.11", "expo-av": "~15.0.1", "expo-clipboard": "^7.0.0", "expo-constants": "~17.0.3", "expo-file-system": "~18.0.4", "expo-keep-awake": "~14.0.1", "expo-linear-gradient": "^14.0.1", "expo-sharing": "^13.0.0", "expo-status-bar": "~2.0.0", "expo-updates": "~0.26.9", "global": "^4.4.0", "install": "^0.13.0", "lottie-react-native": "7.1.0", "npx": "^10.2.2", "react": "18.3.1", "react-native": "0.76.3", "react-native-adapty": "^3.0.2-canary.0", "react-native-audio-recorder-player": "^3.6.7", "react-native-audio-visualizer": "^0.0.1", "react-native-gesture-handler": "~2.20.2", "react-native-reanimated": "^3.16.3", "react-native-render-html": "^6.3.4", "react-native-safe-area-context": "4.12.0", "react-native-screens": "~4.1.0", "react-native-svg": "15.8.0", "react-native-url-polyfill": "^2.0.0", "react-native-webview": "13.12.2", "typescript": "~5.3.3", "wavesurfer.js": "^7.7.15", "zustand": "^5.0.1" }, "devDependencies": { "@babel/core": "^7.20.0", "expo-asset": "~11.0.1", "react-native-svg-transformer": "^1.5.0" }, "private": true }

@MuhammedYesilyurt
Copy link

@vladd-g @moe12572 I just clean the project then I rebuild the project by expo so its working successfully now but iam getting error on another process;

const placementId = 'xx-placement';
const paywall = await adapty.getPaywall(placementId);
i receive 200 response but the detailed error is:

[2024-11-30T18:01:50.995Z] [[email protected]] "fetch/get_paywall": Calling bridge function: OK {"error": [Error: {"type":"AdaptyError","data":{"adapty_code":2006,"message":"Response decoding failed","detail":"HTTPError.decoding(GET /sdk/in-apps/public_live_1Qb3CUdj/paywall/variations/xx-placement/caf8b348824cb3c376826a993faa8a39/, [3.0.3]: Adapty/HTTPRequestWithDecodableResponse.swift#61, statusCode: 200, dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "data", intValue: nil), _CodingKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "attributes", intValue: nil), CodingKeys(stringValue: "paywall_builder", intValue: nil), ContainerCodingKeys(stringValue: "paywall_builder_config", intValue: nil), CodingKeys(stringValue: "assets", intValue: nil), _CodingKey(stringValue: "Index 113", intValue: 113), CodingKeys(stringValue: "value", intValue: nil)], debugDescription: "Encountered Data is not valid Base64.", underlyingError: nil)))"}}]}
DEBUG [2024-11-30T18:01:50.997Z] [[email protected]] "getPaywall": Calling method: OK {"error": [Error: #2006 (decodingFailed): Response decoding failed]}

@moe12572
Copy link

What commands are you running @MuhammedYesilyurt @vladd-g ?

I ran expo start -c and rm -rf node_modules and yarn install

@MuhammedYesilyurt
Copy link

i just remove ios folder with node modules then run only yarn install packagename, then for build;
eas build --platform ios --profile development
after the build i just install the app to my iphone

@MuhammedYesilyurt
Copy link

@vladd-g @moe12572 I just clean the project then I rebuild the project by expo so its working successfully now but iam getting error on another process;

const placementId = 'xx-placement'; const paywall = await adapty.getPaywall(placementId); i receive 200 response but the detailed error is:

[2024-11-30T18:01:50.995Z] [[email protected]] "fetch/get_paywall": Calling bridge function: OK {"error": [Error: {"type":"AdaptyError","data":{"adapty_code":2006,"message":"Response decoding failed","detail":"HTTPError.decoding(GET /sdk/in-apps/public_live_1Qb3CUdj/paywall/variations/xx-placement/caf8b348824cb3c376826a993faa8a39/, [3.0.3]: Adapty/HTTPRequestWithDecodableResponse.swift#61, statusCode: 200, dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "data", intValue: nil), _CodingKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "attributes", intValue: nil), CodingKeys(stringValue: "paywall_builder", intValue: nil), ContainerCodingKeys(stringValue: "paywall_builder_config", intValue: nil), CodingKeys(stringValue: "assets", intValue: nil), _CodingKey(stringValue: "Index 113", intValue: 113), CodingKeys(stringValue: "value", intValue: nil)], debugDescription: "Encountered Data is not valid Base64.", underlyingError: nil)))"}}]} DEBUG [2024-11-30T18:01:50.997Z] [[email protected]] "getPaywall": Calling method: OK {"error": [Error: #2006 (decodingFailed): Response decoding failed]}

@vladd-g do you have any suggestion for this issue?

@vladd-g
Copy link
Contributor

vladd-g commented Dec 1, 2024

@MuhammedYesilyurt this appears to be related to the specific paywall, not the SDK itself, please feel free to reach out to [email protected]

@johannbuscail
Copy link

Hello, the app is working fine for me when i run expo run:ios, but as soon as I want to build it with eas it fails with the same error. I installed all the latest versions as you said:

yarn run v1.22.21
$ /Users/expo/workingdir/build/node_modules/.bin/expo export:embed --eager --platform ios --dev false
Starting Metro Bundler

iOS Bundled 7723ms node_modules/expo-router/entry.js (1185 modules)
Exporting server

λ Bundled 3688ms node_modules/expo-router/build/static/getServerManifest.js (905 modules)

Metro error: Adapty NativeModule is not defined

Error: Adapty NativeModule is not defined
    at new NativeRequestHandler (/Users/expo/workingdir/build/node_modules/react-native-adapty/dist/native-request-handler/native-request-handler.js:14:19)
    at factory (/Users/expo/workingdir/build/node_modules/react-native-adapty/dist/bridge.js:21:19)
    at loadModuleImplementation (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:184:12)
    at require (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:92:7)
    at factory (/Users/expo/workingdir/build/node_modules/react-native-adapty/dist/adapty-handler.js:6:18)
    at loadModuleImplementation (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:184:12)
    at require (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:92:7)
    at /Users/expo/workingdir/build/node_modules/react-native-adapty/dist/index.js:5:26
Adapty NativeModule is not defined
Error: Adapty NativeModule is not defined
Error: Adapty NativeModule is not defined
    at new NativeRequestHandler (/Users/expo/workingdir/build/node_modules/react-native-adapty/dist/native-request-handler/native-request-handler.js:14:19)
    at factory (/Users/expo/workingdir/build/node_modules/react-native-adapty/dist/bridge.js:21:19)
    at loadModuleImplementation (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:184:12)
    at require (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:92:7)
    at factory (/Users/expo/workingdir/build/node_modules/react-native-adapty/dist/adapty-handler.js:6:18)
    at loadModuleImplementation (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:277:5)
    at guardedLoadModule (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:184:12)
    at require (/Users/expo/workingdir/build/node_modules/metro-runtime/src/polyfills/require.js:92:7)
    at /Users/expo/workingdir/build/node_modules/react-native-adapty/dist/index.js:5:26
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@vladd-g
Copy link
Contributor

vladd-g commented Dec 3, 2024

Hello @johannbuscail

Does this algorithm not work for you?

@johannbuscail
Copy link

@vladd-g No, only when doing expo run:ios. Otherwise it doesn't work with eas

@vladd-g
Copy link
Contributor

vladd-g commented Dec 3, 2024

@johannbuscail could you please share what eas version you use, and its json configuration?

@johannbuscail
Copy link

johannbuscail commented Dec 3, 2024

Yes,

eas-cli/13.4.2 
darwin-arm64 
node-v22.9.0 
expo-v0.21.8

And eas.json:

{
	"cli": {
		"version": ">= 12.5.2",
		"appVersionSource": "remote"
	},
	"build": {
		"development": {
			"developmentClient": true,
			"distribution": "internal",
			"ios": {
				"enterpriseProvisioning": "universal"
			}
		},
		"preview": {
			"distribution": "internal",
			"ios": {
				"enterpriseProvisioning": "universal"
			}
		},
		"production": {
			"autoIncrement": true
		}
	},
	"submit": {
		"production": {}
	}
}

app.json

{
	"expo": {
		"name": "",
		"slug": "",
		"version": "1.0.0",
		"scheme": "",
		"newArchEnabled": true,
		"web": {
			"bundler": "metro",
			"output": "server",
			"favicon": "./assets/favicon.png"
		},
		"plugins": [
			[
				"expo-font",
				{
					"fonts": [
						"node_modules/@expo-google-fonts/inter/Inter_400Regular.ttf",
						"node_modules/@expo-google-fonts/inter/Inter_500Medium.ttf"
					]
				}
			],
			[
				"expo-build-properties",
				{
					"ios": {
						"swiftVersion": "5.0"
					},
					"android": {
						"extraMavenRepos": [
							"../../node_modules/react-native-adapty/lib/android/localMaven",
							"../../node_modules/@adapty/react-native-ui/android/localMaven"
						]
					}
				}
			],
			"expo-build-properties"
		],
		"experiments": {
			"typedRoutes": true,
			"tsconfigPaths": true
		},
		"assetBundlePatterns": [
			"**/*"
		],
	}
}

@vladd-g
Copy link
Contributor

vladd-g commented Dec 3, 2024

@johannbuscail thank you!

You can remove the "extraMavenRepos" block as it's not needed since v3

Could you please share your metro.config.js as well?

@johannbuscail
Copy link

Yes, metro.config.js:

// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');
const { withNativeWind } = require('nativewind/metro');

/** @type {import('expo/metro-config').MetroConfig} */
// eslint-disable-next-line no-undef
const config = getDefaultConfig(__dirname);
config.resolver.unstable_enablePackageExports = true;
config.resolver.unstable_conditionNames = ['browser', 'require', 'react-native'];
module.exports = withNativeWind(config, { input: './global.css' });

@vladd-g
Copy link
Contributor

vladd-g commented Dec 4, 2024

@johannbuscail thank you! Does it happen with dev EAS builds too?

@johannbuscail
Copy link

Yes, absolutely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants