From 583017ec69477c9e2d896397a7cc8f6a36aad51f Mon Sep 17 00:00:00 2001 From: Gray Mackall <34871572+gmackall@users.noreply.github.com> Date: Wed, 21 Feb 2024 15:51:18 -0800 Subject: [PATCH] Make Android Studio be able to run android embedding unit tests out of the box (flutter/engine#50840) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is pretty rough, it largely copies the configuration from the `test_runner/build.gradle`. But it lets me click and run unit tests without having to rebuild anything, which is nice: example Screenshot 2024-02-21 at 2 44 19 PM [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../shell/platform/android/build.gradle | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/build.gradle b/engine/src/flutter/shell/platform/android/build.gradle index fe7fa18b11..5f76a937bd 100644 --- a/engine/src/flutter/shell/platform/android/build.gradle +++ b/engine/src/flutter/shell/platform/android/build.gradle @@ -8,7 +8,7 @@ buildscript { mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:7.0.4" + classpath "com.android.tools.build:gradle:7.4.2" } } @@ -20,17 +20,46 @@ repositories { apply plugin: "com.android.library" android { - compileSdk 34 + compileSdkVersion 34 + + defaultConfig { + minSdkVersion 19 + } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs './' java.include './io.flutter/**' + test { + java.srcDir './test' + java.include './test/io.flutter/**' + } } } + + testOptions { + unitTests { + includeAndroidResources = true + } + + } + + dependencies { + implementation fileTree(include: ["*.jar"], dir: "../../../../third_party/android_embedding_dependencies/lib/") + + // These dependencies should be kept in line with those in the ./test_runner/build.gradle + implementation "androidx.test:core:1.4.0" + implementation "com.google.android.play:core:1.8.0" + implementation "com.ibm.icu:icu4j:69.1" + implementation "org.robolectric:robolectric:4.11" + implementation "junit:junit:4.13.2" + implementation "androidx.test.ext:junit:1.1.4-alpha07" + + def mockitoVersion = "4.7.0" + implementation "org.mockito:mockito-core:$mockitoVersion" + implementation "org.mockito:mockito-inline:$mockitoVersion" + implementation "org.mockito:mockito-android:$mockitoVersion" + } } -dependencies { - implementation fileTree(include: ["*.jar"], dir: "../../../../third_party/android_embedding_dependencies/lib/") -}