summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-08-28 10:36:15 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-08-31 11:20:22 -0700
commitae226be5201c559dbc7f8ba741c52847015870be (patch)
treefb4c04a9c88e888edfbb2a727031356893b5797f
parent169b9fb9819618fa886768d04b1f5d8a3806c0f8 (diff)
downloadqtlocation-mapboxgl-upstream/jni-binary-size.tar.gz
[android] jni.hpp 4.0.0-rc10upstream/jni-binary-size
-rw-r--r--cmake/mason-dependencies.cmake2
-rw-r--r--platform/android/src/file_source.cpp7
-rw-r--r--platform/android/src/jni/generic_global_ref_deleter.hpp45
-rw-r--r--platform/android/src/map_renderer.cpp6
-rw-r--r--platform/android/src/map_renderer.hpp4
-rwxr-xr-xplatform/android/src/native_map_view.cpp6
-rwxr-xr-xplatform/android/src/native_map_view.hpp2
-rw-r--r--platform/android/src/offline/offline_manager.cpp28
-rw-r--r--platform/android/src/offline/offline_region.cpp26
-rw-r--r--platform/android/src/snapshotter/map_snapshotter.cpp6
-rw-r--r--platform/android/src/snapshotter/map_snapshotter.hpp3
-rw-r--r--platform/android/src/style/sources/custom_geometry_source.cpp1
-rw-r--r--platform/android/src/style/sources/geojson_source.cpp7
-rw-r--r--platform/android/src/style/sources/source.cpp1
14 files changed, 51 insertions, 93 deletions
diff --git a/cmake/mason-dependencies.cmake b/cmake/mason-dependencies.cmake
index c4ffacba0c..cbea48878d 100644
--- a/cmake/mason-dependencies.cmake
+++ b/cmake/mason-dependencies.cmake
@@ -19,7 +19,7 @@ mason_use(cheap-ruler VERSION 2.5.3 HEADER_ONLY)
mason_use(vector-tile VERSION 1.0.2 HEADER_ONLY)
if(MBGL_PLATFORM STREQUAL "android")
- mason_use(jni.hpp VERSION 4.0.0-rc9 HEADER_ONLY)
+ mason_use(jni.hpp VERSION 4.0.0-rc10 HEADER_ONLY)
mason_use(sqlite VERSION 3.24.0-min-size)
mason_use(icu VERSION 58.1-min-size)
elseif(MBGL_PLATFORM STREQUAL "ios")
diff --git a/platform/android/src/file_source.cpp b/platform/android/src/file_source.cpp
index 32c304b909..0af9d5c40c 100644
--- a/platform/android/src/file_source.cpp
+++ b/platform/android/src/file_source.cpp
@@ -1,4 +1,5 @@
#include "file_source.hpp"
+#include "attach_env.hpp"
#include <mbgl/actor/actor.hpp>
#include <mbgl/actor/scheduler.hpp>
@@ -6,7 +7,6 @@
#include <mbgl/util/logging.hpp>
#include "asset_manager_file_source.hpp"
-#include "jni/generic_global_ref_deleter.hpp"
namespace mbgl {
namespace android {
@@ -45,16 +45,17 @@ void FileSource::setAPIBaseUrl(jni::JNIEnv& env, jni::String url) {
void FileSource::setResourceTransform(jni::JNIEnv& env, jni::Object<FileSource::ResourceTransformCallback> transformCallback) {
if (transformCallback) {
+ auto global = transformCallback.NewGlobalRef<jni::EnvAttachingDeleter>(env);
resourceTransform = std::make_unique<Actor<ResourceTransform>>(*Scheduler::GetCurrent(),
// Capture the ResourceTransformCallback object as a managed global into
// the lambda. It is released automatically when we're setting a new ResourceTransform in
// a subsequent call.
// Note: we're converting it to shared_ptr because this lambda is converted to a std::function,
// which requires copyability of its captured variables.
- [callback = std::shared_ptr<jni::jobject>(transformCallback.NewGlobalRef(env).release().Get(), GenericGlobalRefDeleter())]
+ [callback = std::make_shared<decltype(global)>(std::move(global))]
(mbgl::Resource::Kind kind, const std::string&& url_) {
android::UniqueEnv _env = android::AttachEnv();
- return FileSource::ResourceTransformCallback::onURL(*_env, jni::Object<FileSource::ResourceTransformCallback>(*callback), int(kind), url_);
+ return FileSource::ResourceTransformCallback::onURL(*_env, **callback, int(kind), url_);
});
fileSource->setResourceTransform(resourceTransform->self());
} else {
diff --git a/platform/android/src/jni/generic_global_ref_deleter.hpp b/platform/android/src/jni/generic_global_ref_deleter.hpp
deleted file mode 100644
index b865ee9f8b..0000000000
--- a/platform/android/src/jni/generic_global_ref_deleter.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#pragma once
-
-#include <jni/jni.hpp>
-
-#include "../attach_env.hpp"
-
-namespace mbgl {
-namespace android {
-
-// A deleter that doesn't retain an JNIEnv handle but instead tries to attach the JVM. This means
-// it can be used on any thread to delete a global ref.
-struct GenericGlobalRefDeleter {
- void operator()(jni::jobject* p) const {
- if (p) {
- AttachEnv()->DeleteGlobalRef(jni::Unwrap(p));
- }
- }
-};
-
-struct GenericWeakGlobalRefDeleter {
- void operator()(jni::jobject* p) const {
- if (p) {
- AttachEnv()->DeleteWeakGlobalRef(jni::Unwrap(p));
- }
- }
-};
-
-template < class T >
-using GenericGlobal = jni::UniquePointerlike< T, GenericGlobalRefDeleter >;
-
-template < class T >
-using GenericWeak = jni::UniquePointerlike< T, GenericWeakGlobalRefDeleter >;
-
-template < class T >
-GenericGlobal<T> SeizeGenericGlobal(T&& t) {
- return GenericGlobal<T>(std::move(t), GenericGlobalRefDeleter());
-};
-
-template < class T >
-GenericWeak<T> SeizeGenericWeak(T&& t) {
- return GenericWeak<T>(std::move(t), GenericWeakGlobalRefDeleter());
-};
-
-} // namespace android
-} // namespace mbgl
diff --git a/platform/android/src/map_renderer.cpp b/platform/android/src/map_renderer.cpp
index 1f8c82ac05..12ca57fbc1 100644
--- a/platform/android/src/map_renderer.cpp
+++ b/platform/android/src/map_renderer.cpp
@@ -18,7 +18,7 @@ MapRenderer::MapRenderer(jni::JNIEnv& _env, jni::Object<MapRenderer> obj,
jni::Object<FileSource> _fileSource, jni::jfloat pixelRatio_,
jni::String programCacheDir_,
jni::String localIdeographFontFamily_)
- : javaPeer(SeizeGenericWeak(obj.NewWeakGlobalRef(_env).release()))
+ : javaPeer(_env, obj)
, pixelRatio(pixelRatio_)
, fileSource(FileSource::getDefaultFileSource(_env, _fileSource))
, programCacheDir(jni::Make<std::string>(_env, programCacheDir_))
@@ -56,7 +56,7 @@ void MapRenderer::schedule(std::weak_ptr<Mailbox> scheduled) {
static auto javaClass = jni::Class<MapRenderer>::Singleton(*_env);
static auto queueEvent = javaClass.GetMethod<void(
jni::Object<MapRendererRunnable>)>(*_env, "queueEvent");
- javaPeer->Call(*_env, queueEvent, *peer);
+ javaPeer.get(*_env)->Call(*_env, queueEvent, *peer);
// Release the c++ peer as it will be destroyed on GC of the Java Peer
runnable.release();
@@ -66,7 +66,7 @@ void MapRenderer::requestRender() {
android::UniqueEnv _env = android::AttachEnv();
static auto javaClass = jni::Class<MapRenderer>::Singleton(*_env);
static auto onInvalidate = javaClass.GetMethod<void()>(*_env, "requestRender");
- javaPeer->Call(*_env, onInvalidate);
+ javaPeer.get(*_env)->Call(*_env, onInvalidate);
}
void MapRenderer::update(std::shared_ptr<UpdateParameters> params) {
diff --git a/platform/android/src/map_renderer.hpp b/platform/android/src/map_renderer.hpp
index 6fcf2fee71..4612d01b6b 100644
--- a/platform/android/src/map_renderer.hpp
+++ b/platform/android/src/map_renderer.hpp
@@ -9,8 +9,6 @@
#include <jni/jni.hpp>
#include <mbgl/storage/default_file_source.hpp>
-#include "jni/generic_global_ref_deleter.hpp"
-
namespace mbgl {
template <class>
@@ -97,7 +95,7 @@ private:
void onSurfaceChanged(JNIEnv&, jint width, jint height);
private:
- GenericWeak<jni::Object<MapRenderer>> javaPeer;
+ jni::WeakReference<jni::Object<MapRenderer>, jni::EnvAttachingDeleter> javaPeer;
float pixelRatio;
DefaultFileSource& fileSource;
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index d396e00b47..33269b4046 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -61,7 +61,7 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env,
jni::Object<FileSource> jFileSource,
jni::Object<MapRenderer> jMapRenderer,
jni::jfloat _pixelRatio)
- : javaPeer(_obj.NewWeakGlobalRef(_env))
+ : javaPeer(_env, _obj)
, mapRenderer(MapRenderer::getNativePeer(_env, jMapRenderer))
, pixelRatio(_pixelRatio)
, threadPool(sharedThreadPool()) {
@@ -105,7 +105,7 @@ void NativeMapView::notifyMapChange(mbgl::MapChange change) {
android::UniqueEnv _env = android::AttachEnv();
static auto javaClass = jni::Class<NativeMapView>::Singleton(*_env);
static auto onMapChanged = javaClass.GetMethod<void (int)>(*_env, "onMapChanged");
- javaPeer->Call(*_env, onMapChanged, (int) change);
+ javaPeer.get(*_env)->Call(*_env, onMapChanged, (int) change);
}
void NativeMapView::onCameraWillChange(MapObserver::CameraChangeMode mode) {
@@ -410,7 +410,7 @@ void NativeMapView::scheduleSnapshot(jni::JNIEnv&) {
// invoke Mapview#OnSnapshotReady
static auto javaClass = jni::Class<NativeMapView>::Singleton(*_env);
static auto onSnapshotReady = javaClass.GetMethod<void (jni::Object<Bitmap>)>(*_env, "onSnapshotReady");
- javaPeer->Call(*_env, onSnapshotReady, bitmap);
+ javaPeer.get(*_env)->Call(*_env, onSnapshotReady, bitmap);
});
}
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index d398b39bf7..563def534e 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -252,7 +252,7 @@ private:
std::unique_ptr<AndroidRendererFrontend> rendererFrontend;
JavaVM *vm = nullptr;
- jni::Weak<jni::Object<NativeMapView>> javaPeer;
+ jni::WeakReference<jni::Object<NativeMapView>> javaPeer;
MapRenderer& mapRenderer;
diff --git a/platform/android/src/offline/offline_manager.cpp b/platform/android/src/offline/offline_manager.cpp
index 263f7b9d8b..9c31f04e38 100644
--- a/platform/android/src/offline/offline_manager.cpp
+++ b/platform/android/src/offline/offline_manager.cpp
@@ -3,7 +3,6 @@
#include <mbgl/util/string.hpp>
#include "../attach_env.hpp"
-#include "../jni/generic_global_ref_deleter.hpp"
namespace mbgl {
namespace android {
@@ -21,11 +20,13 @@ void OfflineManager::setOfflineMapboxTileCountLimit(jni::JNIEnv&, jni::jlong lim
}
void OfflineManager::listOfflineRegions(jni::JNIEnv& env_, jni::Object<FileSource> jFileSource_, jni::Object<ListOfflineRegionsCallback> callback_) {
- // list regions
+ auto globalCallback = callback_.NewGlobalRef<jni::EnvAttachingDeleter>(env_);
+ auto globalFilesource = jFileSource_.NewGlobalRef<jni::EnvAttachingDeleter>(env_);
+
fileSource.listOfflineRegions([
//Keep a shared ptr to a global reference of the callback and file source so they are not GC'd in the meanwhile
- callback = std::shared_ptr<jni::jobject>(callback_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter()),
- jFileSource = std::shared_ptr<jni::jobject>(jFileSource_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter())
+ callback = std::make_shared<decltype(globalCallback)>(std::move(globalCallback)),
+ jFileSource = std::make_shared<decltype(globalFilesource)>(std::move(globalFilesource))
](mbgl::expected<mbgl::OfflineRegions, std::exception_ptr> regions) mutable {
// Reattach, the callback comes from a different thread
@@ -33,11 +34,10 @@ void OfflineManager::listOfflineRegions(jni::JNIEnv& env_, jni::Object<FileSourc
if (regions) {
OfflineManager::ListOfflineRegionsCallback::onList(
- *env, jni::Object<FileSource>(*jFileSource),
- jni::Object<ListOfflineRegionsCallback>(*callback), std::move(*regions));
+ *env, **jFileSource, **callback, std::move(*regions));
} else {
OfflineManager::ListOfflineRegionsCallback::onError(
- *env, jni::Object<ListOfflineRegionsCallback>(*callback), regions.error());
+ *env, **callback, regions.error());
}
});
}
@@ -55,11 +55,14 @@ void OfflineManager::createOfflineRegion(jni::JNIEnv& env_,
metadata = OfflineRegion::metadata(env_, metadata_);
}
+ auto globalCallback = callback_.NewGlobalRef<jni::EnvAttachingDeleter>(env_);
+ auto globalFilesource = jFileSource_.NewGlobalRef<jni::EnvAttachingDeleter>(env_);
+
// Create region
fileSource.createOfflineRegion(definition, metadata, [
//Keep a shared ptr to a global reference of the callback and file source so they are not GC'd in the meanwhile
- callback = std::shared_ptr<jni::jobject>(callback_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter()),
- jFileSource = std::shared_ptr<jni::jobject>(jFileSource_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter())
+ callback = std::make_shared<decltype(globalCallback)>(std::move(globalCallback)),
+ jFileSource = std::make_shared<decltype(globalFilesource)>(std::move(globalFilesource))
](mbgl::expected<mbgl::OfflineRegion, std::exception_ptr> region) mutable {
// Reattach, the callback comes from a different thread
@@ -67,12 +70,11 @@ void OfflineManager::createOfflineRegion(jni::JNIEnv& env_,
if (region) {
OfflineManager::CreateOfflineRegionCallback::onCreate(
- *env,
- jni::Object<FileSource>(*jFileSource),
- jni::Object<CreateOfflineRegionCallback>(*callback), std::move(*region)
+ *env, **jFileSource, **callback, std::move(*region)
);
} else {
- OfflineManager::CreateOfflineRegionCallback::onError(*env, jni::Object<CreateOfflineRegionCallback>(*callback), region.error());
+ OfflineManager::CreateOfflineRegionCallback::onError(
+ *env, **callback, region.error());
}
});
}
diff --git a/platform/android/src/offline/offline_region.cpp b/platform/android/src/offline/offline_region.cpp
index 949377e221..93a6647bba 100644
--- a/platform/android/src/offline/offline_region.cpp
+++ b/platform/android/src/offline/offline_region.cpp
@@ -7,7 +7,6 @@
#include "offline_region_error.hpp"
#include "offline_region_status.hpp"
#include "../attach_env.hpp"
-#include "../jni/generic_global_ref_deleter.hpp"
namespace mbgl {
namespace android {
@@ -93,55 +92,56 @@ void OfflineRegion::setOfflineRegionDownloadState(jni::JNIEnv&, jni::jint jState
}
void OfflineRegion::getOfflineRegionStatus(jni::JNIEnv& env_, jni::Object<OfflineRegionStatusCallback> callback_) {
+ auto globalCallback = callback_.NewGlobalRef<jni::EnvAttachingDeleter>(env_);
fileSource.getOfflineRegionStatus(*region, [
//Ensure the object is not gc'd in the meanwhile
- callback = std::shared_ptr<jni::jobject>(callback_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter())
+ callback = std::make_shared<decltype(globalCallback)>(std::move(globalCallback))
](mbgl::expected<mbgl::OfflineRegionStatus, std::exception_ptr> status) mutable {
// Reattach, the callback comes from a different thread
android::UniqueEnv env = android::AttachEnv();
if (status) {
- OfflineRegionStatusCallback::onStatus(*env, jni::Object<OfflineRegionStatusCallback>(*callback), std::move(*status));
+ OfflineRegionStatusCallback::onStatus(*env, **callback, std::move(*status));
} else {
- OfflineRegionStatusCallback::onError(*env, jni::Object<OfflineRegionStatusCallback>(*callback), status.error());
+ OfflineRegionStatusCallback::onError(*env, **callback, status.error());
}
});
}
void OfflineRegion::deleteOfflineRegion(jni::JNIEnv& env_, jni::Object<OfflineRegionDeleteCallback> callback_) {
- // Delete
+ auto globalCallback = callback_.NewGlobalRef<jni::EnvAttachingDeleter>(env_);
+
fileSource.deleteOfflineRegion(std::move(*region), [
//Ensure the object is not gc'd in the meanwhile
- callback = std::shared_ptr<jni::jobject>(callback_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter())
+ callback = std::make_shared<decltype(globalCallback)>(std::move(globalCallback))
](std::exception_ptr error) mutable {
// Reattach, the callback comes from a different thread
android::UniqueEnv env = android::AttachEnv();
if (error) {
- OfflineRegionDeleteCallback::onError(*env, jni::Object<OfflineRegionDeleteCallback>(*callback), error);
+ OfflineRegionDeleteCallback::onError(*env, **callback, error);
} else {
- OfflineRegionDeleteCallback::onDelete(*env, jni::Object<OfflineRegionDeleteCallback>(*callback));
+ OfflineRegionDeleteCallback::onDelete(*env, **callback);
}
});
}
void OfflineRegion::updateOfflineRegionMetadata(jni::JNIEnv& env_, jni::Array<jni::jbyte> jMetadata, jni::Object<OfflineRegionUpdateMetadataCallback> callback_) {
-
- // Convert
auto metadata = OfflineRegion::metadata(env_, jMetadata);
+ auto globalCallback = callback_.NewGlobalRef<jni::EnvAttachingDeleter>(env_);
fileSource.updateOfflineMetadata(region->getID(), metadata, [
//Ensure the object is not gc'd in the meanwhile
- callback = std::shared_ptr<jni::jobject>(callback_.NewGlobalRef(env_).release().Get(), GenericGlobalRefDeleter())
+ callback = std::make_shared<decltype(globalCallback)>(std::move(globalCallback))
](mbgl::expected<mbgl::OfflineRegionMetadata, std::exception_ptr> data) mutable {
// Reattach, the callback comes from a different thread
android::UniqueEnv env = android::AttachEnv();
if (data) {
- OfflineRegionUpdateMetadataCallback::onUpdate(*env, jni::Object<OfflineRegionUpdateMetadataCallback>(*callback), std::move(*data));
+ OfflineRegionUpdateMetadataCallback::onUpdate(*env, **callback, std::move(*data));
} else {
- OfflineRegionUpdateMetadataCallback::onError(*env, jni::Object<OfflineRegionUpdateMetadataCallback>(*callback), data.error());
+ OfflineRegionUpdateMetadataCallback::onError(*env, **callback, data.error());
}
});
}
diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp
index 4df0749aa0..d4251bd872 100644
--- a/platform/android/src/snapshotter/map_snapshotter.cpp
+++ b/platform/android/src/snapshotter/map_snapshotter.cpp
@@ -25,7 +25,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
jni::Object<CameraPosition> position,
jni::jboolean _showLogo,
jni::String _programCacheDir)
- : javaPeer(SeizeGenericWeak(_obj.NewWeakGlobalRef(_env).release()))
+ : javaPeer(_env, _obj)
, pixelRatio(_pixelRatio)
, threadPool(sharedThreadPool()) {
@@ -85,7 +85,7 @@ void MapSnapshotter::start(JNIEnv& env) {
if (err) {
// error handler callback
static auto onSnapshotFailed = javaClass.GetMethod<void (jni::String)>(*_env, "onSnapshotFailed");
- javaPeer->Call(*_env, onSnapshotFailed,
+ javaPeer.get(*_env)->Call(*_env, onSnapshotFailed,
*jni::SeizeLocal(*_env, jni::Make<jni::String>(*_env, util::toString(err))));
} else {
// Create the wrapper
@@ -93,7 +93,7 @@ void MapSnapshotter::start(JNIEnv& env) {
// invoke callback
static auto onSnapshotReady = javaClass.GetMethod<void (jni::Object<MapSnapshot>)>(*_env, "onSnapshotReady");
- javaPeer->Call(*_env, onSnapshotReady, mapSnapshot);
+ javaPeer.get(*_env)->Call(*_env, onSnapshotReady, mapSnapshot);
}
deactivateFilesource(*_env);
diff --git a/platform/android/src/snapshotter/map_snapshotter.hpp b/platform/android/src/snapshotter/map_snapshotter.hpp
index 05a27256aa..bfe073a0a1 100644
--- a/platform/android/src/snapshotter/map_snapshotter.hpp
+++ b/platform/android/src/snapshotter/map_snapshotter.hpp
@@ -9,7 +9,6 @@
#include "../map/camera_position.hpp"
#include <jni/jni.hpp>
-#include "../jni/generic_global_ref_deleter.hpp"
#include <memory>
@@ -58,7 +57,7 @@ private:
MBGL_STORE_THREAD(tid);
JavaVM *vm = nullptr;
- GenericWeak<jni::Object<MapSnapshotter>> javaPeer;
+ jni::WeakReference<jni::Object<MapSnapshotter>, jni::EnvAttachingDeleter> javaPeer;
float pixelRatio;
bool showLogo;
diff --git a/platform/android/src/style/sources/custom_geometry_source.cpp b/platform/android/src/style/sources/custom_geometry_source.cpp
index 9012948b0b..40c0a29a56 100644
--- a/platform/android/src/style/sources/custom_geometry_source.cpp
+++ b/platform/android/src/style/sources/custom_geometry_source.cpp
@@ -1,4 +1,5 @@
#include "custom_geometry_source.hpp"
+#include "../../attach_env.hpp"
#include <mbgl/renderer/query.hpp>
diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp
index 5d26965ae5..259d208459 100644
--- a/platform/android/src/style/sources/geojson_source.cpp
+++ b/platform/android/src/style/sources/geojson_source.cpp
@@ -1,4 +1,5 @@
#include "geojson_source.hpp"
+#include "../../attach_env.hpp"
#include <mbgl/renderer/query.hpp>
@@ -113,11 +114,11 @@ namespace android {
template <class JNIType>
void GeoJSONSource::setCollectionAsync(jni::JNIEnv& env, jni::Object<JNIType> jObject) {
-
- std::shared_ptr<jni::jobject> object = std::shared_ptr<jni::jobject>(jObject.NewGlobalRef(env).release().Get(), GenericGlobalRefDeleter());
+ auto global = jObject.template NewGlobalRef<jni::EnvAttachingDeleter>(env);
+ auto object = std::make_shared<decltype(global)>(std::move(global));
Update::Converter converterFn = [this, object](ActorRef<Callback> _callback) {
- converter->self().invoke(&FeatureConverter::convertObject<JNIType>, jni::Object<JNIType>(*object), _callback);
+ converter->self().invoke(&FeatureConverter::convertObject<JNIType>, **object, _callback);
};
setAsync(converterFn);
diff --git a/platform/android/src/style/sources/source.cpp b/platform/android/src/style/sources/source.cpp
index c7968786ec..5eda8e0fd4 100644
--- a/platform/android/src/style/sources/source.cpp
+++ b/platform/android/src/style/sources/source.cpp
@@ -1,5 +1,6 @@
#include "source.hpp"
#include "../android_conversion.hpp"
+#include "../../attach_env.hpp"
#include <jni/jni.hpp>