Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

addImage bug in v7.0.12 for android

Đang mở
#118 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
android, typescript
Lĩnh vực
mobile-dev

Hướng nghiên cứu

Bắt đầu trong @nativescript-community/ui-mapbox/index.android.js, tập trung vào addImage và lệnh gọi fetchImageSource của nó. So sánh style-image API hiện tại của Mapbox Android SDK v11 với lời gọi addImage trực tiếp và xác minh hành vi đã được sửa so với NoSuchMethodError được báo cáo. Hoàn tất khi có thể thêm hình ảnh trên Android mà không gặp lỗi crash do chữ ký.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hello, first thank you very much for upgrading the library. The nativescript community is amazing and very glad to see it constantly evolve and being maintained.

I think I found a bug. The contract changed slightly with mapbox sdk v11+ in Android for addImage as it seems its expecting to be wrapped by a ImageExtensionImpl builder before providing the image.

Therefore I was getting this error when trying to add an image in mapbox sdk

Error: java.lang.NoSuchMethodError: no static method "Lcom/mapbox/maps/MapboxStyleManager;.addImage(Ljava/lang/String;Landroid/graphics/Bitmap;)Lcom/mapbox/bindgen/Expected;

After debugging the problem I figured out reading the very clear documentation about the migration (this was a sarcasm of course)

I could not find any other reference that properly cast the image it seems like

style.addImage('id', imageBitMap)

should be supported but in my case it looks like the signature did not match thus crashed consistently.

So I got a proposition to fix this issue from reverse engeneering the implementation but I suspect this is not the proper way.

@nativescript-community/ui-mapbox/index.android.js

In addImage I changed :

const imageSource = await this.fetchImageSource(imagePath);
theMap.getStyle().addImage(imageId, imageSource.android);

To

const imageSource = await this.fetchImageSource(imagePath);
const bitmap = imageSource.android;

const ImageExtensionImpl = com.mapbox.maps.extension.style.image.ImageExtensionImpl;
const imageBuilder = new ImageExtensionImpl.Builder(imageId, bitmap);
const image = imageBuilder.build();

image.bindTo(theMap.getStyle());

resolve();

making sure that the bitmap is properly casted.

If anyone has a better solution or if I am totally mistaken let me know thank you.

Ngôn ngữ chính
TypeScript
Star
38
Fork
26
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nativescript-community/ui-mapbox

Tất cả issue của nativescript-community/ui-mapbox

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.