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

TypeError: Cannot read property 'initSDK' of null #818

Open
liucaptainapp opened this issue Dec 5, 2023 · 14 comments
Open

TypeError: Cannot read property 'initSDK' of null #818

liucaptainapp opened this issue Dec 5, 2023 · 14 comments

Comments

@liucaptainapp
Copy link

liucaptainapp commented Dec 5, 2023

"react-native": "0.72.6",
"react-native-amap-geolocation": "^1.2.3",
"react-native-amap3d": "^3.2.4",

ios模拟器和真机没问题,但是安卓模拟器会报错

启动项目控制台会警告⚠️

TypeError: Cannot read property 'initSDK' of null
TypeError: Cannot read property 'initSDK' of null

点开地图页面的时候就会报错❌,我猜估计是上一步初始化SDK出问题了

Invariant Violation: requireNativeComponent: "AMapView" was not found in the UIManager.

我在源码中打印AMapSdk为null

import { NativeModules } from "react-native";

const { AMapSdk } = NativeModules;

export function init(apiKey?: string) {
  console.log(AMapSdk) // null
  AMapSdk.initSDK(apiKey);
}

export function getVersion(): Promise<string> {
  return AMapSdk.getVersion();
}

react-native-amap-geolocation也会出现⚠️

TypeError: Cannot read property 'initSDK' of null

安卓打包的时候报着个错

> Task :app:stripReleaseDebugSymbols
Unable to strip the following libraries, packaging them as they are: libAMapSDK_MAP_v9_6_0.so.

> Task :app:checkReleaseDuplicateClasses FAILED

FAILURE: Build failed with an exception.
@liucaptainapp
Copy link
Author

我貌似找到问题了 但是需要作者改一下

warn Package react-native-amap3d contains invalid configuration: "dependency.platforms.ios.project" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.

翻译

包react-innative-amap3d包含无效配置:不允许使用“dependent.platforms.ios.project”。请使用“react native config”命令验证它是否正确链接,并就此与包维护人员联系。

@liucaptainapp
Copy link
Author

@qiuxiang 能不能跟新一下 react-native: 0.72.6

@shrkh
Copy link

shrkh commented Dec 18, 2023

@qiuxiang 能不能跟新一下 "react-native": "0.73.0",
TypeError: Cannot read property 'initSDK' of null

@liucaptainapp
Copy link
Author

@qiuxiang 能不能跟新一下 "react-native": "0.73.0",
TypeError: Cannot read property 'initSDK' of null
我还以为就我一个人有问题

@shrkh
Copy link

shrkh commented Dec 18, 2023

@liucaptainapp ,然后你怎么解决得?

@liucaptainapp
Copy link
Author

@shrkh 没改 估计只有等作者更新一下了

@liucaptainapp
Copy link
Author

安卓打包的时候react-native-amap-geolocation和react-native-amap3d有冲突

@shrkh
Copy link

shrkh commented Dec 18, 2023

唉,好难哦

@shrkh
Copy link

shrkh commented Dec 19, 2023

@qiuxiang 作者大佬能不能跟新一下 "react-native": "0.73.1",
TypeError: Cannot read property 'initSDK' of null

@Jazenx
Copy link

Jazenx commented Mar 11, 2024

iOS 可以试下加入 arm64 选项,我也是同样问题,现在可以 debug 调试了。
image

@wuyuyjin
Copy link

我也遇到了同样的问题,要命啊,我以为是我的问题,用是"react-native": "0.72.6",TypeError: Cannot read property 'initSDK' of null,咋处理啊,各位大佬们

@liucaptainapp
Copy link
Author

我也遇到了同样的问题,要命啊,我以为是我的问题,用是"react-native": "0.72.6",TypeError: Cannot read property 'initSDK' of null,咋处理啊,各位大佬们

感觉需要作者修改下配置,我现在用webview凑活用着

@wuyuyjin
Copy link

我也遇到同样的问题,要命啊,我还以为是我的问题,用的是"react-native": "0.72.6",TypeError: Cannot read property 'initSDK' of null,处理咋啊,各位大佬我们

需要感觉作者修改下配置,我现在用webview活用着

感谢🙏

@LukeGongde
Copy link

@qiuxiang 能不能跟新一下 "react-native": "0.73.0",
TypeError: Cannot read property 'initSDK' of null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants