Navaron Bracke
Committed by GitHub

Merge pull request #810 from navaronbracke/android_cleanups

feat: Update Android setup
@@ -6,3 +6,4 @@ @@ -6,3 +6,4 @@
6 .DS_Store 6 .DS_Store
7 /build 7 /build
8 /captures 8 /captures
  9 +.cxx
@@ -14,7 +14,7 @@ buildscript { @@ -14,7 +14,7 @@ buildscript {
14 } 14 }
15 } 15 }
16 16
17 -rootProject.allprojects { 17 +allprojects {
18 repositories { 18 repositories {
19 google() 19 google()
20 mavenCentral() 20 mavenCentral()
@@ -25,6 +25,10 @@ apply plugin: 'com.android.library' @@ -25,6 +25,10 @@ apply plugin: 'com.android.library'
25 apply plugin: 'kotlin-android' 25 apply plugin: 'kotlin-android'
26 26
27 android { 27 android {
  28 + if (project.android.hasProperty("namespace")) {
  29 + namespace 'dev.steenbakker.mobile_scanner'
  30 + }
  31 +
28 compileSdkVersion 33 32 compileSdkVersion 33
29 33
30 compileOptions { 34 compileOptions {
@@ -38,13 +42,24 @@ android { @@ -38,13 +42,24 @@ android {
38 42
39 sourceSets { 43 sourceSets {
40 main.java.srcDirs += 'src/main/kotlin' 44 main.java.srcDirs += 'src/main/kotlin'
  45 + test.java.srcDirs += 'src/test/kotlin'
41 } 46 }
42 47
43 defaultConfig { 48 defaultConfig {
44 minSdkVersion 21 49 minSdkVersion 21
45 } 50 }
46 51
47 - namespace 'dev.steenbakker.mobile_scanner' 52 + testOptions {
  53 + unitTests.all {
  54 + useJUnitPlatform()
  55 +
  56 + testLogging {
  57 + events "passed", "skipped", "failed", "standardOut", "standardError"
  58 + outputs.upToDateWhen {false}
  59 + showStandardStreams = true
  60 + }
  61 + }
  62 + }
48 } 63 }
49 64
50 dependencies { 65 dependencies {
@@ -62,4 +77,7 @@ dependencies { @@ -62,4 +77,7 @@ dependencies {
62 implementation 'androidx.camera:camera-camera2:1.2.3' 77 implementation 'androidx.camera:camera-camera2:1.2.3'
63 implementation 'androidx.camera:camera-lifecycle:1.2.3' 78 implementation 'androidx.camera:camera-lifecycle:1.2.3'
64 implementation 'androidx.camera:camera-camera2:1.2.3' 79 implementation 'androidx.camera:camera-camera2:1.2.3'
  80 +
  81 + testImplementation 'org.jetbrains.kotlin:kotlin-test'
  82 + testImplementation 'org.mockito:mockito-core:5.0.0'
65 } 83 }
1 -#Fri Jun 23 08:50:38 CEST 2017  
2 -distributionBase=GRADLE_USER_HOME  
3 -distributionPath=wrapper/dists  
4 -zipStoreBase=GRADLE_USER_HOME  
5 -zipStorePath=wrapper/dists  
6 -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip  
  1 +plugins {
  2 + id "com.android.application"
  3 + id "kotlin-android"
  4 + id "dev.flutter.flutter-gradle-plugin"
  5 +}
  6 +
1 def localProperties = new Properties() 7 def localProperties = new Properties()
2 def localPropertiesFile = rootProject.file('local.properties') 8 def localPropertiesFile = rootProject.file('local.properties')
3 if (localPropertiesFile.exists()) { 9 if (localPropertiesFile.exists()) {
@@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
6 } 12 }
7 } 13 }
8 14
9 -def flutterRoot = localProperties.getProperty('flutter.sdk')  
10 -if (flutterRoot == null) {  
11 - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")  
12 -}  
13 -  
14 def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 if (flutterVersionCode == null) { 16 if (flutterVersionCode == null) {
16 flutterVersionCode = '1' 17 flutterVersionCode = '1'
@@ -21,12 +22,10 @@ if (flutterVersionName == null) { @@ -21,12 +22,10 @@ if (flutterVersionName == null) {
21 flutterVersionName = '1.0' 22 flutterVersionName = '1.0'
22 } 23 }
23 24
24 -apply plugin: 'com.android.application'  
25 -apply plugin: 'kotlin-android'  
26 -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"  
27 -  
28 android { 25 android {
  26 + namespace "dev.steenbakker.mobile_scanner_example"
29 compileSdkVersion 33 27 compileSdkVersion 33
  28 + ndkVersion flutter.ndkVersion
30 29
31 compileOptions { 30 compileOptions {
32 sourceCompatibility JavaVersion.VERSION_1_8 31 sourceCompatibility JavaVersion.VERSION_1_8
@@ -57,7 +56,6 @@ android { @@ -57,7 +56,6 @@ android {
57 signingConfig signingConfigs.debug 56 signingConfig signingConfigs.debug
58 } 57 }
59 } 58 }
60 - namespace 'dev.steenbakker.mobile_scanner_example'  
61 } 59 }
62 60
63 flutter { 61 flutter {
1 <manifest xmlns:android="http://schemas.android.com/apk/res/android"> 1 <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2 - <!-- Flutter needs it to communicate with the running application 2 + <!-- The INTERNET permission is required for development. Specifically,
  3 + the Flutter tool needs it to communicate with the running application
3 to allow setting breakpoints, to provide hot reload, etc. 4 to allow setting breakpoints, to provide hot reload, etc.
4 --> 5 -->
5 <uses-permission android:name="android.permission.INTERNET"/> 6 <uses-permission android:name="android.permission.INTERNET"/>
1 -<manifest xmlns:android="http://schemas.android.com/apk/res/android"  
2 - package="dev.steenbakker.mobile_scanner_example">  
3 -  
4 - <application 1 +<manifest xmlns:android="http://schemas.android.com/apk/res/android">
  2 + <application
5 android:label="mobile_scanner_example" 3 android:label="mobile_scanner_example"
  4 + android:name="${applicationName}"
6 android:icon="@mipmap/ic_launcher"> 5 android:icon="@mipmap/ic_launcher">
7 <activity 6 <activity
8 android:name=".MainActivity" 7 android:name=".MainActivity"
1 package dev.steenbakker.mobile_scanner_example 1 package dev.steenbakker.mobile_scanner_example
2 2
3 -import io.flutter.embedding.android.FlutterFragmentActivity 3 +import io.flutter.embedding.android.FlutterActivity
4 4
5 -class MainActivity : FlutterFragmentActivity() { 5 +class MainActivity: FlutterActivity() {
6 } 6 }
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on --> 3 <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
4 <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar"> 4 <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
5 <!-- Show a splash screen on the activity. Automatically removed when 5 <!-- Show a splash screen on the activity. Automatically removed when
6 - Flutter draws its first frame --> 6 + the Flutter engine draws its first frame -->
7 <item name="android:windowBackground">@drawable/launch_background</item> 7 <item name="android:windowBackground">@drawable/launch_background</item>
8 </style> 8 </style>
9 <!-- Theme applied to the Android Window as soon as the process has started. 9 <!-- Theme applied to the Android Window as soon as the process has started.
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off --> 3 <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
4 <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar"> 4 <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
5 <!-- Show a splash screen on the activity. Automatically removed when 5 <!-- Show a splash screen on the activity. Automatically removed when
6 - Flutter draws its first frame --> 6 + the Flutter engine draws its first frame -->
7 <item name="android:windowBackground">@drawable/launch_background</item> 7 <item name="android:windowBackground">@drawable/launch_background</item>
8 </style> 8 </style>
9 <!-- Theme applied to the Android Window as soon as the process has started. 9 <!-- Theme applied to the Android Window as soon as the process has started.
1 <manifest xmlns:android="http://schemas.android.com/apk/res/android"> 1 <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2 - <!-- Flutter needs it to communicate with the running application 2 + <!-- The INTERNET permission is required for development. Specifically,
  3 + the Flutter tool needs it to communicate with the running application
3 to allow setting breakpoints, to provide hot reload, etc. 4 to allow setting breakpoints, to provide hot reload, etc.
4 --> 5 -->
5 <uses-permission android:name="android.permission.INTERNET"/> 6 <uses-permission android:name="android.permission.INTERNET"/>
1 -#Tue Jun 27 18:47:05 CEST 2023  
2 distributionBase=GRADLE_USER_HOME 1 distributionBase=GRADLE_USER_HOME
3 distributionPath=wrapper/dists 2 distributionPath=wrapper/dists
4 distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip 3 distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
1 -include ':app' 1 +pluginManagement {
  2 + def flutterSdkPath = {
  3 + def properties = new Properties()
  4 + file("local.properties").withInputStream { properties.load(it) }
  5 + def flutterSdkPath = properties.getProperty("flutter.sdk")
  6 + assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
  7 + return flutterSdkPath
  8 + }
  9 + settings.ext.flutterSdkPath = flutterSdkPath()
2 10
3 -def localPropertiesFile = new File(rootProject.projectDir, "local.properties")  
4 -def properties = new Properties() 11 + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
  12 +}
5 13
6 -assert localPropertiesFile.exists()  
7 -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 14 +include ":app"
8 15
9 -def flutterSdkPath = properties.getProperty("flutter.sdk")  
10 -assert flutterSdkPath != null, "flutter.sdk not set in local.properties"  
11 -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 16 +apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle"