diff --git a/DEPS b/DEPS index dcd6ebe819fb5..dd95421811e03 100644 --- a/DEPS +++ b/DEPS @@ -780,7 +780,7 @@ deps = { 'packages': [ { 'package': 'flutter/android/embedding_bundle', - 'version': 'last_updated:2024-06-18T12:13:41-0700' + 'version': 'last_updated:2024-09-10T16:32:16-0700' } ], 'condition': 'download_android_deps', diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 65797086ff0fe..6f062431cf747 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -394,6 +394,7 @@ embedding_dependencies_jars = [ "//flutter/third_party/android_embedding_dependencies/lib/viewpager-1.0.0.jar", "//flutter/third_party/android_embedding_dependencies/lib/window-1.2.0.jar", "//flutter/third_party/android_embedding_dependencies/lib/window-java-1.2.0.jar", + "//flutter/third_party/android_embedding_dependencies/lib/relinker-1.4.5.jar", ] action("check_imports") { diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java b/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java index 3c966d2f4fa98..389e866829f09 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java @@ -24,6 +24,7 @@ import androidx.annotation.Nullable; import androidx.annotation.UiThread; import androidx.annotation.VisibleForTesting; +import com.getkeepsafe.relinker.ReLinker; import io.flutter.Log; import io.flutter.embedding.engine.FlutterEngine.EngineLifecycleListener; import io.flutter.embedding.engine.dart.PlatformMessageHandler; @@ -139,12 +140,11 @@ public FlutterJNI provideFlutterJNI() { * *

This method should only be called once across all FlutterJNI instances. */ - public void loadLibrary() { + public void loadLibrary(Context context) { if (FlutterJNI.loadLibraryCalled) { Log.w(TAG, "FlutterJNI.loadLibrary called more than once"); } - - System.loadLibrary("flutter"); + ReLinker.loadLibrary(context, "flutter"); FlutterJNI.loadLibraryCalled = true; } diff --git a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java index 70302e7f42ae7..9416bf18ab5ed 100644 --- a/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java +++ b/shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java @@ -182,7 +182,7 @@ public InitResult call() { ResourceExtractor resourceExtractor = initResources(appContext); try { - flutterJNI.loadLibrary(); + flutterJNI.loadLibrary(appContext); } catch (UnsatisfiedLinkError unsatisfiedLinkError) { String couldntFindVersion = "couldn't find \"libflutter.so\""; String notFoundVersion = "dlopen failed: library \"libflutter.so\" not found"; diff --git a/shell/platform/android/test/io/flutter/embedding/engine/loader/FlutterLoaderTest.java b/shell/platform/android/test/io/flutter/embedding/engine/loader/FlutterLoaderTest.java index 98d60d4b78465..e403668887dd4 100644 --- a/shell/platform/android/test/io/flutter/embedding/engine/loader/FlutterLoaderTest.java +++ b/shell/platform/android/test/io/flutter/embedding/engine/loader/FlutterLoaderTest.java @@ -58,7 +58,7 @@ public void itReportsInitializedAfterInitializing() { flutterLoader.ensureInitializationComplete(ctx, null); shadowOf(getMainLooper()).idle(); assertTrue(flutterLoader.initialized()); - verify(mockFlutterJNI, times(1)).loadLibrary(); + verify(mockFlutterJNI, times(1)).loadLibrary(ctx); verify(mockFlutterJNI, times(1)).updateRefreshRate(); } @@ -70,7 +70,7 @@ public void unsatisfiedLinkErrorPathDoesNotExist() { Mockito.doThrow(new UnsatisfiedLinkError("couldn't find \"libflutter.so\"")) .when(mockFlutterJNI) - .loadLibrary(); + .loadLibrary(ctx); try { flutterLoader.startInitialization(ctx); } catch (UnsupportedOperationException e) { diff --git a/tools/androidx/README.md b/tools/androidx/README.md new file mode 100644 index 0000000000000..1471d12954b45 --- /dev/null +++ b/tools/androidx/README.md @@ -0,0 +1,3 @@ +Defines the additional Android build time dependencies downloaded by `engine/tools/cipd/android_embedding_bundle`, which then get uploaded to CIPD and pulled by `gclient sync` into `third_party/android_embedding_dependencies/lib/`. + +Despite the directory name, `files.json` actually includes one non-androidx dependency: [ReLinker](https://github.com/KeepSafe/ReLinker). \ No newline at end of file diff --git a/tools/androidx/files.json b/tools/androidx/files.json index 3150c04671713..a6a284a27410b 100644 --- a/tools/androidx/files.json +++ b/tools/androidx/files.json @@ -86,5 +86,11 @@ "out_file_name": "core-1.10.3.aar", "maven_dependency": "com.google.android.play:core:1.10.3", "provides": [] + }, + { + "url": "https://repo1.maven.org/maven2/com/getkeepsafe/relinker/relinker/1.4.5/relinker-1.4.5.aar", + "out_file_name": "relinker-1.4.5.aar", + "maven_dependency": "com.getkeepsafe.relinker:relinker:1.4.5", + "provides": ["com.getkeepsafe.relinker.ReLinker"] } ]