rust-mobile / ndk

Rust bindings to the Android NDK
Apache License 2.0
1.12k stars 111 forks source link

Unresolved import error "ndk::bitmap" #86

Closed SeptimusX75 closed 3 years ago

SeptimusX75 commented 3 years ago

I'm a rust noob so I apologize for my naïveté. I'm trying to use this library from another rust library with no main method (not sure if this matters). I added a dependency to ndk = "0.2.1" and imported it with use ndk::bitmap::{AndroidBitmap, AndroidBitmapInfo};. When I attempt to compile I get the following:

error[E0432]: unresolved import `ndk::bitmap`
 --> src/lib.rs:6:10
  |
6 | use ndk::bitmap::{AndroidBitmap, AndroidBitmapInfo};
  |          ^^^^^^ could not find `bitmap` in `ndk`

I'm also using the following:

use jni::JNIEnv;
use jni::objects::{JClass, JObject, JString};
use skia_safe::{Borrows, Canvas, ColorSpace, ImageInfo, ISize, Rect, Surface};

Is this likely an issue with the crate or is it user error? Any help would be appreciated. Thanks.

dvc94ch commented 3 years ago

Well either it's because the module doesn't exist or because a feature wasn't enabled.

francesca64 commented 3 years ago

(Re-opening because the opener's situation hasn't been resolved yet)

Thanks for asking!

naïveté

I appreciate your use of the diaeresis and grave accent.

The bitmap module should exist, so as @dvc94ch mentioned, it's probably a matter of specifying the right feature flag in your Cargo.toml:

ndk = { version = "0.2.1", features = ["bitmap"] }

I apologize if this isn't documented clearly. Feature flag discovery is a common issue in the Rust ecosystem, unfortunately.

dvc94ch commented 3 years ago

@francesca64 closing due to inactivity