Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails after upgrade to flutter 3.0 #330

Open
stingrayx opened this issue May 12, 2022 · 24 comments
Open

Build fails after upgrade to flutter 3.0 #330

stingrayx opened this issue May 12, 2022 · 24 comments

Comments

@stingrayx
Copy link

Hello,

just wanted to let you know that there seems an issue with the latest flutter release 3.0 and this plugin.

After upgrading my flutter the build of my app using background_locator 1.6.12 gives following errors:

background_locator\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (25, 1): Class 'BackgroundLocatorPlugin' is not abstract and does not implement abstract member public abstract fun onNewIntent(p0: Intent): Boolean defined in io.flutter.plugin.common.PluginRegistry.NewIntentListener

background_locator\android\src\main\kotlin\rekab\app\background_locator\pluggables\InitPluggable.kt: (22, 55): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected

Best regards
Thomas

@stingrayx
Copy link
Author

Just in case someone is experiencing the same issue. Seems that the fork here has already a fix for this problem!

@sterrana
Copy link

sterrana commented May 12, 2022

I just updated to 3.0 and this package raises a lot of errors.
With the fork above a big part of warnings are resolved, but in my case I had to manually activate MultiDex and remove ! from background_locator.dart (line 34).

@Yukams
Copy link

Yukams commented May 12, 2022

@caiobraga do you think you could fix your branch accordingly to @sterrana's comment ?

@eomer
Copy link

eomer commented May 15, 2022

arg. upgraded from dart 2.16.2 flutter 2.10.5 to dart 2.17.0 and flutter 3.0.0 get many error and build failed..

Dart SDK version: 2.17.0 (stable) (Mon May 9 10:36:47 2022 +0200) on "windows_x64"
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.0.0, on Microsoft Windows [version 10.0.19043.1706], locale fr-FR)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0)
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.67.1)
[√] Connected device (4 available)
[√] HTTP Host Availability
error compiling android

e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (25, 1): Class 'BackgroundLocatorPlugin' is not abstract and does not implement abstract member public abstract fun onNewIntent(p0: Intent): Boolean defined in io.flutter.plugin.common.PluginRegistry.NewIntentListener
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (215, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (215, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (224, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (224, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (243, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (243, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (266, 5): 'onNewIntent' overrides nothing
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (275, 35): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\IsolateHolderExtension.kt: (42, 27): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\IsolateHolderService.kt: (269, 35): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\pluggables\DisposePluggable.kt: (17, 51): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\pluggables\InitPluggable.kt: (22, 55): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected

FAILURE: Build failed with an exception.

no knowledge on kotlin..
any help welcome !!

@Alfaizkhan
Copy link

arg. upgraded from dart 2.16.2 flutter 2.10.5 to dart 2.17.0 and flutter 3.0.0 get many error and build failed..

Dart SDK version: 2.17.0 (stable) (Mon May 9 10:36:47 2022 +0200) on "windows_x64" flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.0.0, on Microsoft Windows [version 10.0.19043.1706], locale fr-FR) [√] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0) [√] Android Studio (version 2021.2) [√] VS Code (version 1.67.1) [√] Connected device (4 available) [√] HTTP Host Availability error compiling android

e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (25, 1): Class 'BackgroundLocatorPlugin' is not abstract and does not implement abstract member public abstract fun onNewIntent(p0: Intent): Boolean defined in io.flutter.plugin.common.PluginRegistry.NewIntentListener e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (215, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (215, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (224, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (224, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (243, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (243, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (266, 5): 'onNewIntent' overrides nothing e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\BackgroundLocatorPlugin.kt: (275, 35): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\IsolateHolderExtension.kt: (42, 27): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\IsolateHolderService.kt: (269, 35): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\pluggables\DisposePluggable.kt: (17, 51): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected e: C:\Users\chris\Documents\flutter.pub-cache\hosted\pub.dartlang.org\background_locator-1.6.12\android\src\main\kotlin\rekab\app\background_locator\pluggables\InitPluggable.kt: (22, 55): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected

FAILURE: Build failed with an exception.

no knowledge on kotlin.. any help welcome !!

Here is the fix for flutter 3.0

https://github.com/Alfaizkhan/background_locator

Check it out and try.

@kivocsa99
Copy link

@Alfaizkhan i can confirm that it is still not working and there is a lot of building error

@Alfaizkhan
Copy link

@Alfaizkhan i can confirm that it is still not working and there is a lot of building error

Can you please post a build logs here.

@kivocsa99
Copy link

@Alfaizkhan iam going to build now but long story short , it first asked me to upgrade my compile and target SDK versions to 31
then there is the whole ->

Execution failed for task ':background_location:compileDebugKotlin'.

@kivocsa99
Copy link

@Alfaizkhan i have not copied anything , i just ran your example in the git repo

@kivocsa99
Copy link

Launching lib/main.dart on FLA LX1 in debug mode...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../snap/flutter/common/flutter/packages/flutter/lib/src/widgets/binding.dart').
      WidgetsBinding.instance!.addObserver(AutoStopHandler());

                     ^
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (25, 1): Class 'BackgroundLocatorPlugin' is not abstract and does not implement abstract member public abstract fun onNewIntent(p0: Intent): Boolean defined in io.flutter.plugin.common.PluginRegistry.NewIntentListener
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (215, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (215, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (224, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (224, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (243, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (243, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (266, 5): 'onNewIntent' overrides nothing
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (275, 35): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderExtension.kt: (42, 27): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderService.kt: (269, 35): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt: (17, 51): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt: (22, 55): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':background_locator:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 5s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

@Alfaizkhan
Copy link

@Alfaizkhan i have not copied anything , i just ran your example in the git repo

Let me try again.

@Alfaizkhan
Copy link

Launching lib/main.dart on FLA LX1 in debug mode...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
: Warning: Operand of null-aware operation '!' has type 'WidgetsBinding' which excludes null.
- 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../snap/flutter/common/flutter/packages/flutter/lib/src/widgets/binding.dart').
      WidgetsBinding.instance!.addObserver(AutoStopHandler());

                     ^
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (25, 1): Class 'BackgroundLocatorPlugin' is not abstract and does not implement abstract member public abstract fun onNewIntent(p0: Intent): Boolean defined in io.flutter.plugin.common.PluginRegistry.NewIntentListener
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (215, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (215, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (224, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (224, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (243, 43): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (243, 48): Type mismatch: inferred type is Map<Any, Any>? but Map<Any, Any> was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (266, 5): 'onNewIntent' overrides nothing
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt: (275, 35): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderExtension.kt: (42, 27): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderService.kt: (269, 35): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt: (17, 51): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
e: /home/kivocsa99/background_locator/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt: (22, 55): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':background_locator:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 5s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

Change compileSdkVersion to 31 is working fine for me.

@kivocsa99
Copy link

@Alfaizkhan

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 31

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "rekab.app.background_locator_example"
        minSdkVersion 16
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}


@kivocsa99
Copy link

@Alfaizkhan here is the build gradle and it is not working

@kivocsa99
Copy link

@Alfaizkhan i've cloned it another time just to check if i did smth wrong but same thing even when upgrading the compileSDKversion

@kivocsa99
Copy link

@Alfaizkhan if you are not able to produce the problem you are more than welcome to get into my pc with teamviewer or anydesk

@imsamgarg
Copy link

https://github.com/imsamgarg/background_locator

try it, fixes all flutter 3 issues

@guistrutzki
Copy link

The @imsamgarg solution did it!

Added in pubspec.yaml

background_locator:
    git:
      url: https://github.com/imsamgarg/background_locator
      ref: master

@Yukams
Copy link

Yukams commented Jul 16, 2022

Hi @guistrutzki, you can also use the version 2 of the library if you want : https://pub.dev/packages/background_locator_2

@casva2022
Copy link

I'm getting this issue when I run it in the emulator:

Running Gradle task 'assembleDebug'...
e: D:\develop\flutter.pub-cache\git\background_locator-08beb61507f472de767fa918365fa2601c879c63\android\src\main\kotlin\rekab\app\background_locator\provider\LocationParserUtil.kt: (21, 20): Type mismatch: inferred type is String? but Any was expected

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':background_locator:compileDebugKotlin'.

Compilation error. See log for more details

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 17s
Exception: Gradle task assembleDebug failed with exit code 1

@Glauber26
Copy link

For anyone with this error:

background_locator/provider/LocationParserUtil.kt: (21, 20): Type mismatch: inferred type is String? but any was expected

just find the LocationParserUtil.kt file in your directory and replace it with the following code snippet:

package rekab.app.background_locator.provider

import android.location.Location
import android.os.Build
import com.google.android.gms.location.LocationResult
import rekab.app.background_locator.Keys
import java.util.HashMap

class LocationParserUtil {
     companion object {
         fun getLocationMapFromLocation(location: Location): HashMap<Any, Any> {
             var speedAccuracy = 0f
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                 speedAccuracy = location.speedAccuracyMetersPerSecond
             }
             var isMocked = false
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
                 isMocked = location.isFromMockProvider
             }

             return hashMapOf(
                 Keys.ARG_IS_MOCKED to isMocked as Any,
                 Keys.ARG_LATITUDE to location.latitude as Any,
                 Keys.ARG_LONGITUDE to location.longitude as Any,
                 Keys.ARG_ACCURACY to location.accuracy as Any,
                 Keys.ARG_ALTITUDE to location.altitude as Any,
                 Keys.ARG_SPEED to location.speed as Any,
                 Keys.ARG_SPEED_ACCURACY to speedAccuracy as Any,
                 Keys.ARG_HEADING to location.bearing as Any,
                 Keys.ARG_TIME to location.time.toDouble() as Any,
                 Keys.ARG_PROVIDER to location.provider as Any
             )
         }

         fun getLocationMapFromLocation(location: LocationResult?): HashMap<Any, Any>? {
             val firstLocation = location?.lastLocation ?: return null

             var speedAccuracy = 0f
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                 speedAccuracy = firstLocation.speedAccuracyMetersPerSecond
             }
             var isMocked = false
             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
                 isMocked = firstLocation.isFromMockProvider
             }

             return hashMapOf(
                 Keys.ARG_IS_MOCKED to isMocked as Any,
                 Keys.ARG_LATITUDE to firstLocation.latitude as Any,
                 Keys.ARG_LONGITUDE to firstLocation.longitude as Any,
                 Keys.ARG_ACCURACY to firstLocation.accuracy as Any,
                 Keys.ARG_ALTITUDE to firstLocation.altitude as Any,
                 Keys.ARG_SPEED to firstLocation.speed as Any,
                 Keys.ARG_SPEED_ACCURACY to speedAccuracy as Any,
                 Keys.ARG_HEADING to firstLocation.bearing as Any,
                 Keys.ARG_TIME to firstLocation.time.toDouble() as Any
             )
         }
     }
}

@OE-Ahmed
Copy link

OE-Ahmed commented Sep 1, 2023

yes, @Glauber26 I am still getting this issue. Can you please give me a solution?

@OE-Ahmed
Copy link

OE-Ahmed commented Sep 1, 2023

compileSdkVersion 33

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = '1.8'
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
    applicationId "Don't Know"
    minSdkVersion 22
    targetSdkVersion 33
    multiDexEnabled true
    versionCode 38
    versionName '8.0.30'
}

@OE-Ahmed
Copy link

OE-Ahmed commented Sep 1, 2023

compileSdkVersion 33

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = '1.8'
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
    applicationId "Don't Know"
    minSdkVersion 22
    targetSdkVersion 33
    multiDexEnabled true
    versionCode 38
    versionName '8.0.30'
}

Can anyone have any answer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests