Apparence-io / CamerAwesome

📸 Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
959 stars 247 forks source link

Play Services Location conflicts #233

Closed miguelflores1993 closed 1 year ago

miguelflores1993 commented 1 year ago

I'm with flutter 3.3.10 I use the latest version of cameraawesome 1.2.0 I'm trying to install the library in my project.

the example project of the library if it works well, this is the error that I get.

* What went wrong:
Execution failed for task ':camerawesome:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > 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

my build graddle, is the same latest version that is created in the flutter project

buildscript {
    ext {
        kotlin_version     = '1.6.21'
        compileSdkVersion   = 33
        targetSdkVersion    = 33
        appCompatVersion    = "1.4.2"
        playServicesLocationVersion = "20.0.0"
        removeBackgroundGeolocationDebugSoundsInRelease = true
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.1'
        classpath 'com.google.gms:google-services:4.3.14'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
apalala-dev commented 1 year ago

Can you try to upgrade kotlin_version to '1.7.10' please?

miguelflores1993 commented 1 year ago

Won't it affect my project in general? other packages?

apalala-dev commented 1 year ago

I don't know your dependencies so can't say for sure. You can probably try it and see if it compiles or not. 1.7.10 is a stable version from July 2022. I think it's safe to use and other dependencies might upgrade later as well.

miguelflores1993 commented 1 year ago

the application compiles, but closes... emulador

E/AndroidRuntime( 3313): FATAL EXCEPTION: main
E/AndroidRuntime( 3313): Process: com.deltaxlat.appdriver.dev, PID: 3313
E/AndroidRuntime( 3313): java.lang.IncompatibleClassChangeError: Found interface com.google.android.gms.location.ActivityRecognitionClient, but class was expected (declaration of 'com.google.android.gms.location.ActivityRecognitionClient' appears in /data/app/~~ormrqoBzvT3udWou-CEC2g==/com.deltaxlat.appdriver.dev-yP9rUuHd0egpa9ehAF8b0w==/base.apk!classes7.dex)
E/AndroidRuntime( 3313):    at com.transistorsoft.locationmanager.service.ActivityRecognitionService.start(Unknown Source:84)
E/AndroidRuntime( 3313):    at com.transistorsoft.locationmanager.adapter.BackgroundGeolocation$n0.a(Unknown Source:16)
E/AndroidRuntime( 3313):    at com.transistorsoft.locationmanager.adapter.TSConfig.b(Unknown Source:32)
E/AndroidRuntime( 3313):    at com.transistorsoft.locationmanager.adapter.TSConfig.b(Unknown Source:225)
E/AndroidRuntime( 3313):    at com.transistorsoft.locationmanager.adapter.TSConfig.b(Unknown Source:0)
E/AndroidRuntime( 3313):    at com.transistorsoft.locationmanager.adapter.TSConfig$Builder.commit(Unknown Source:10)
E/AndroidRuntime( 3313):    at com.transistorsoft.locationmanager.adapter.TSConfig$Builder.a(Unknown Source:144)
E/AndroidRuntime( 3313):    at com.transistorsoft.locationmanager.adapter.TSConfig$Builder.b(Unknown Source:0)
E/AndroidRuntime( 3313):    at com.transistorsoft.locationmanager.adapter.TSConfig.reset(Unknown Source:2)
E/AndroidRuntime( 3313):    at com.transistorsoft.locationmanager.adapter.TSConfig.reset(Unknown Source:1)
E/AndroidRuntime( 3313):    at com.transistorsoft.flutter.backgroundgeolocation.BackgroundGeolocationModule.ready(BackgroundGeolocationModule.java:365)
E/AndroidRuntime( 3313):    at com.transistorsoft.flutter.backgroundgeolocation.BackgroundGeolocationModule.onMethodCall(BackgroundGeolocationModule.java:222)
E/AndroidRuntime( 3313):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/AndroidRuntime( 3313):    at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/AndroidRuntime( 3313):    at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/AndroidRuntime( 3313):    at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/AndroidRuntime( 3313):    at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime( 3313):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 3313):    at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime( 3313):    at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime( 3313):    at android.app.ActivityThread.main(ActivityThread.java:7839)
E/AndroidRuntime( 3313):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 3313):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime( 3313):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
miguelflores1993 commented 1 year ago

I realized that if it is affecting a library... that is called flutter_background_geolocation I think I won't be able to use your library.

apalala-dev commented 1 year ago

I'll take a look at what we can do.

miguelflores1993 commented 1 year ago

@apalala-dev can this help you? https://github.com/transistorsoft/flutter_background_geolocation/issues/933

apalala-dev commented 1 year ago

Yes I think it's the cause of the problem. camerawesome uses Play Services v21+ (hard-coded) while flutter_background_geolocation uses v20. The author of flutter_background_geolocation said that he would release v4.9.0 with v21 as well next week. Can you wait for that release ? In the meantime, I'll try to implement gradle variables to let users tell which version they want to use.

apalala-dev commented 1 year ago

I made a PR to let you define which version of Play Services Location you want to use (instead of hard-coding it). Can you try it and tell me it works for you ?

I used the same name as flutter_background_geolocation, so we should use the same library version. You should already have the good configuration, but the important part is:

buildscript {
    // other stuff
    ext {
        // other stuff
        playServicesLocationVersion = "20.0.0"
    }
}

See #234

You can depend on the branch directly in your pubspec.yaml:

dependencies:   
     camerawesome:
       git:
         url: https://github.com/Apparence-io/CamerAwesome.git
         ref: play_services_location_version
miguelflores1993 commented 1 year ago

Thank you! I will notify you to implement it again, very kind and fast, the solution is appreciated.

apalala-dev commented 1 year ago

PR #234 which includes a gradle variable for Play Services Location has been merged and should fix this problem. It is available in 1.2.1. I'll close the issue, feel free to tell us if something is still wrong!