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

How to compatible with react-native-amap-geolocation ? #778

Closed
magic3584 opened this issue Feb 10, 2023 · 48 comments
Closed

How to compatible with react-native-amap-geolocation ? #778

magic3584 opened this issue Feb 10, 2023 · 48 comments

Comments

@magic3584
Copy link

I could not found the best compatible versions, I have tested below conditions on iOS, the react native version is 0.68.2:

package name version
react-native-amap3d 3.1.3
react-native-amap-geolocation 1.2.0

The AMap3DMap will be removed when pod install:

Removing AMap3DMap

There is no build error in rn but then comes the error when running on iOS:
requireNativeComponent:"AMapView" was not found in the UIManager

package name version
react-native-amap3d 3.1.1
react-native-amap-geolocation 1.2.0

Dependency confict when pod install:

[!] CocoaPods could not find compatible versions for pod "AMapFoundation":
  In Podfile:
    react-native-amap-geolocation (from `../node_modules/react-native-amap-geolocation`) was resolved to 1.2.0, which depends on
      AMapLocation (~> 2.9.0) was resolved to 2.9.0, which depends on
        AMapFoundation (>= 1.7.0)

    react-native-amap3d (from `../node_modules/react-native-amap3d/lib/ios`) was resolved to 3.1.1, which depends on
      AMap3DMap (~> 9.2.1) was resolved to 9.2.1, which depends on
        AMapFoundation (~> 1.6.9)
package name version
react-native-amap3d 3.1.1
react-native-amap-geolocation 1.1.0

Crashed when running:
image

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]'
*** First throw call stack:
(0x1a3235d78 0x1bbe88704 0x1a33405d0 0x1a334b6bc 0x1a31f2984 0x1a3211628 0x1014e5e48 0x101603264 0x105160c6c 0x1051627bc 0x105172c68 0x1051727a4 0x1a31ee2f0 0x1a31a81f4 0x1a31bb6b8 0x1bf23d374 0x1a5b23acc 0x1a58a5970 0x100a09618 0x104c11ce4)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/usr/lib/libMTLCapture.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]'
@qiuxiang
Copy link
Owner

我周末把这两个的高德 sdk 都升级下应该就可以了

@magic3584
Copy link
Author

Thanks buddy
大佬辛苦

@EntityGJ
Copy link

Thanks author! I had the same problem.

@magic3584
Copy link
Author

magic3584 commented Feb 13, 2023

Waiting to be released online...
I have noticed that the version of react native has been updated too, I'm wonder whether it is still available with 0.68.2
If it's not available, could u please tell me how to update the dependencies?

@qiuxiang
Copy link
Owner

android 版在 RN 最新版测试通过了,但 ios 还没有测,我直接发到 npm 吧,晚点我再测 ios

@magic3584
Copy link
Author

Both packages were updated! I'm starting test on iOS right away!

@qiuxiang
Copy link
Owner

稍等,react-native-amap3d 还没发布成功

@magic3584
Copy link
Author

Yeah, found it🤣

@qiuxiang
Copy link
Owner

好了

@jefn76
Copy link

jefn76 commented Feb 13, 2023

刚用这个库,就赶上了最新版本,nice!!

@magic3584
Copy link
Author

Tested with react native 0.68.2 on iOS:

package name version
react-native-amap3d 3.2.0
react-native-amap-geolocation 1.2.1
Installing AMapFoundation (1.8.0)
Installing AMapLocation (2.9.0)

The AMap3DMap is still not be installed.
Could u please where should I fork and how to update the dependencies? I'm going to fix it and make a PR.

@jefn76
Copy link

jefn76 commented Feb 13, 2023

新版本安卓跑失败了,上个版本是成功的。

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • What went wrong:
    Execution failed for task ':app:checkDebugDuplicateClasses'.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class com.amap.api.fence.DistrictItem found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.DistrictItem$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.GeoFence found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.GeoFence$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.GeoFenceClient found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.GeoFenceListener found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.PoiItem found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.PoiItem$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocation found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocation$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClient found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$2 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$AMapLocationMode found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$AMapLocationProtocol found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$AMapLocationPurpose found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$GeoLanguage found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationListener found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationQualityReport found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.APSService found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.CoordUtil found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.CoordinateConverter found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.CoordinateConverter$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.CoordinateConverter$CoordType found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.DPoint found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.DPoint$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.UmidtokenInfo found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.UmidtokenInfo$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.UmidtokenInfo$a found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)

 Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.

  • What went wrong:
    java.lang.StackOverflowError (no error message)

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
==============================================================================

BUILD FAILED in 24s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.

  • What went wrong:
    Execution failed for task ':app:checkDebugDuplicateClasses'.

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class com.amap.api.fence.DistrictItem found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.DistrictItem$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.GeoFence found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.GeoFence$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.GeoFenceClient found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.GeoFenceListener found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.PoiItem found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.fence.PoiItem$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocation found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocation$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClient found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$2 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$AMapLocationMode found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$AMapLocationProtocol found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$AMapLocationPurpose found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationClientOption$GeoLanguage found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationListener found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.AMapLocationQualityReport found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.APSService found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.CoordUtil found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.CoordinateConverter found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.CoordinateConverter$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.CoordinateConverter$CoordType found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.DPoint found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.DPoint$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.UmidtokenInfo found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.UmidtokenInfo$1 found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)
Duplicate class com.amap.api.location.UmidtokenInfo$a found in modules jetified-3dmap-9.6.0 (com.amap.api:3dmap:9.6.0) and jetified-location-6.2.0 (com.amap.api:location:6.2.0)

 Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.

  • What went wrong:
    java.lang.StackOverflowError (no error message)

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
==============================================================================

@qiuxiang
Copy link
Owner

ios 确实已经是最新版了:

s.dependency 'AMap3DMap', "~> 9.5.0"

@qiuxiang
Copy link
Owner

@magic3584 把你的错误提示再发完整点

@magic3584
Copy link
Author

使用下面版本的时候,android 是正常使用的,但是 iOS 是运行时崩溃,参照本 issue 第三种情况。

package name version
react-native-amap3d 3.1.1
react-native-amap-geolocation 1.1.0

当 pod install 的时候,完成的依赖安装如下

Installing AMap3DMap (9.2.1)
Installing AMapFoundation (1.6.9)
Installing AMapLocation (2.6.9)
Installing react-native-amap-geolocation (1.1.0)
Installing react-native-amap3d (3.1.1)

大佬刚更新过后的两个包版本如下

package name version
react-native-amap3d 3.2.0
react-native-amap-geolocation 1.2.1

此时 pod install, 完成的依赖安装如下

Installing AMapFoundation (1.8.0)
Installing AMapLocation (2.9.0)
Installing react-native-amap-geolocation (1.2.1)

与前次相比,缺少了 AMap3DMapreact-native-amap3d,相当于本仓库的包没有被安装。

@magic3584
Copy link
Author

ios 确实已经是最新版了:

s.dependency 'AMap3DMap', "~> 9.5.0"

https://github.com/CocoaPods/Specs/blob/master/Specs/5/f/c/AMap3DMap/9.6.0/AMap3DMap.podspec.json
iOS 最新版本是 9.6.0, "~> 9.5.0"这种写法并不能匹配成功。
不过我感觉也不是这个问题,大佬也可以更新下试试

@qiuxiang
Copy link
Owner

发布了个新版本,再试试

@qiuxiang
Copy link
Owner

@jefn76 试试在 android/app/build.gradle 的 dependencies {} 里加入这段:

implementation(project(':react-native-amap-geolocation')) {
    exclude group: 'com.amap.api', module: 'location'
}

@magic3584
Copy link
Author

测试版本如下

package name version
react-native-amap3d 3.2.1
react-native-amap-geolocation 1.2.1

有新崩溃

WX20230213-203914@2x

另外大佬,iOS 如果更新最新版本依赖,需要修改以下文件内
https://github.com/qiuxiang/react-native-amap3d/blob/main/lib/ios/react-native-amap3d.podspec

s.dependency 'AMap3DMap', "~> 9.5.0"

to

s.dependency 'AMap3DMap', "~> 9.6.0"

@magic3584
Copy link
Author

升级 AMap3DMap 到 9.6.0 后,还是同一个方法崩溃。我需要学一下 rn 怎么封装原生组件。

@qiuxiang
Copy link
Owner

我等下用 xcode 看下

@magic3584
Copy link
Author

image

也许可能是我们的问题?明天我得看下代码是怎么写的,打印的也没有 MapView

@qiuxiang
Copy link
Owner

我试了 example 是没有问题的

@qiuxiang
Copy link
Owner

qiuxiang commented Feb 13, 2023

明天再试试新建的项目

@jefn76
Copy link

jefn76 commented Feb 14, 2023

@jefn76 试试在 android/app/build.gradle 的 dependencies {} 里加入这段:

implementation(project(':react-native-amap-geolocation')) {
    exclude group: 'com.amap.api', module: 'location'
}

谢谢大佬,跑成功了!

@magic3584
Copy link
Author

我试了 example 是没有问题的

大佬请问 example 怎么跑起来?没找到 iOS 的 project

@qiuxiang
Copy link
Owner

在外面 react-native init example,然后把 example/ios 复制到 这个项目里来,然后在这个项目正常的 pos install,react-native run-ios

@jefn76
Copy link

jefn76 commented Feb 14, 2023

报错了,首先是react-native run-ios的时候,报了警告: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.
然后调用AMapSdk.init()后,app报错:
ERROR TypeError: Cannot read property 'initSDK' of null

This error is located at:
in App
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in AwesomeProject(RootComponent), js engine: hermes

打开Pods文件夹,发现并没有link到:
SCR-20230214-dkv

@qiuxiang
Copy link
Owner

我还是先改回之前的结构。@jefn76 发了新版本,再试试

@jefn76
Copy link

jefn76 commented Feb 14, 2023

我还是先改回之前的结构。@jefn76 发了新版本,再试试

成功了,完美!

@magic3584
Copy link
Author

magic3584 commented Feb 14, 2023

在外面 react-native init example,然后把 example/ios 复制到 这个项目里来,然后在这个项目正常的 pos install,react-native run-ios

不行啊, nom run iOS 报错如下
image

@EntityGJ
Copy link

还是之前同样的问题
image

下载的依赖关系
image

package.json里面的版本
image

@qiuxiang
Copy link
Owner

在外面 react-native init example,然后把 example/ios 复制到 这个项目里来,然后在这个项目正常的 pos install,react-native run-ios

不行啊 image

这已经和 ios 项目没关系了,这是 js bundle 错误

@qiuxiang
Copy link
Owner

不对,是原生的错,你先试试提示的操作,重新 pod install,yarn start --reset-cache

@magic3584
Copy link
Author

不对,是原生的错,你先试试提示的操作,重新 pod install,yarn start --reset-cache

可以了,我的错,如下修改就可以了。
image

接下来用最新版本的库去看我们项目的代码了,所以可能还是我们的代码有问题,但是相同代码 android 可以跑 emmm
我再研究研究,辛苦大佬~

@qiuxiang
Copy link
Owner

RN 项目和原生耦合太深了,为了排除原生项目配置的问题,我干脆把 example 的原生项目都移除了,构建的时候再 react-native init 一个新的。我只能保证在新项目里能跑起来,其他项目跑不起来大概就是配置问题。

build action 可以作为参考:

- run: npm pack
- run: npx react-native init example
- run: cp index.js example/
- run: cp -r example-app example/
- run: npm i ../react-native-amap3d-0.0.0.tgz
working-directory: example
- run: npm i @react-native-picker/picker @react-navigation/native @react-navigation/native-stack react-native-safe-area-context react-native-screens
working-directory: example
- run: sed -i.backup -r 's/(enableSeparateBuildPerCPUArchitecture = )false/\1true/' build.gradle
working-directory: example/android/app
- run: ./gradlew assembleRelease
working-directory: example/android

@magic3584
Copy link
Author

但是大佬,本 issue 的问题仍然存在,依赖如下时,仍然无法导入地图的库

image

Installing AMapFoundation (1.8.0)
Installing AMapLocation (2.9.0)
Installing react-native-amap-geolocation (1.2.1)

@magic3584
Copy link
Author

请教这个 action 如何执行?

@qiuxiang
Copy link
Owner

这个 action 只测了 android

@qiuxiang
Copy link
Owner

准备写下 ios 的 action,可以 fork 下来,自己改,提交了就会运行

@magic3584
Copy link
Author

大佬这两个库的兼容问题还会去查吗?这俩库一般都搭配使用的吧

@qiuxiang
Copy link
Owner

我只能晚上回去再看,公司没有 mac

@qiuxiang
Copy link
Owner

现在写下 ios 的 action,估计也能看出一些问题

@qiuxiang
Copy link
Owner

@magic3584 看起来是没有问题的

https://github.com/qiuxiang/react-native-amap3d/actions/runs/4170573648/jobs/7219670017

image

而且上面 @jefn76 也反馈没问题了

@magic3584
Copy link
Author

针对两个版本的 react native 0.68.20.71.2,分别创建新项目使用相同版本的两个库

package name version
react-native-amap3d 3.2.3
react-native-amap-geolocation 1.2.1

测试结果如下:

  1. 0.68.2

Installing AMapFoundation (1.8.0)
Installing AMapLocation (2.9.0)
Installing react-native-amap-geolocation (1.2.1)

仍然缺少地图库

  1. 0.71.2

Installing AMap3DMap (9.6.0)
Installing AMapFoundation (1.8.0)
Installing AMapLocation (2.9.0)
Installing react-native-amap-geolocation (1.2.1)
Installing react-native-amap3d (3.2.3)

可以正常安装两个库。

不确定是否是本仓库以前的包所依赖的 RN 版本导致的。
还需要再进一步去验证

@qiuxiang
Copy link
Owner

看起来是 RN 升级过后查找原生依赖的策略发生了一些变化,这种事也发生过,现在主要受 react-native.config.js 影响,还有一些隐含的策略,为此我看过,调试过 RN 这部分的源码。但现在过去了这么久,以至于我都忘了为什么要写两个 podspec 才能让 RN 查找到依赖。

https://github.com/qiuxiang/react-native-amap3d/blob/main/react-native-amap3d.podspec
https://github.com/qiuxiang/react-native-amap3d/blob/main/lib/ios/react-native-amap3d.podspec

@qiuxiang
Copy link
Owner

react-native-amap-geolocation 这个项目没有问题是因为 xcodeproj 的存在,这就是其中隐含的查找策略

https://github.com/qiuxiang/react-native-amap-geolocation/tree/main/lib/ios/AMapGeolocation.xcodeproj

我现在懒得深究这个问题了,就只保证能兼容最新的 RN

@magic3584
Copy link
Author

好的大佬,感谢您及时跟进解决,我再研究研究。如果您以后再看到相关文档解释,烦请再在这里贴一下

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

4 participants