Flutter-geolocator: Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath

Created on 12 Mar 2019  ·  15Comments  ·  Source: Baseflow/flutter-geolocator

🐛 Bug Report


Hi everybody,

Can't install this plugin, tried different versions this plugin (3.0.1, 3.0.0, 2.1.1, 2.1.0), but not one did not work. Has anyone encountered this problem already?

pubsec.yaml

name: flutter_app
description: A new Flutter application.

version: 1.1.0+1

environment:
sdk: ">=2.1.0 <3.0.0"

dependencies:
flutter:
sdk: flutter

cupertino_icons: ^0.1.2
geolocator: ^3.0.1
permission_handler: ^3.0.0
meta: ^1.1.6
google_api_availability: ^2.0.0

dev_dependencies:
flutter_test:
sdk: flutter

flutter_launcher_icons: ^0.6.1

flutter_icons:
image_path: "assets/img/location.png"
android: true

flutter:
uses-material-design: true
assets:
- assets/img/location.png
- assets/img/gps.png
- assets/img/no_gps.png

- assets/img/where.jpg

LocationPage.dart

import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';

class LocationPage extends StatefulWidget {
@override
LocationPageState createState() => LocationPageState();
}

class LocationPageState extends State{

initLocation()async{
Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
print(position);
}

initState() {
super.initState();
initLocation();
}

@override
Widget build(BuildContext context) {
return Scaffold(...);
}

}

CONSOLE OUTPUT:

Running "flutter packages get" in flutter_app... 0.6s
Launching lib/main.dart on MI 6 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:preDebugBuild'.

    Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath. You should manually set the same version via DependencyResolution

  • 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 4s


The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.


Finished with error: Gradle task assembleDebug failed with exit code 1

Reproduction steps

flutter run -d

Configuration

Version: 3.0.1

Platform:

  • [ ] :iphone: iOS
  • [*] :robot: Android

[✓] Flutter (Channel stable, v1.2.1, on Mac OS X 10.13.6 17G65, locale en-UA)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.3)
[✓] VS Code (version 1.31.1)
[✓] Connected device (1 available)

• No issues found!

Most helpful comment

for me , i added the android migration to the gradle properties file and then changed classpath 'com.android.tools.build:gradle:3.2.1' to classpath 'com.android.tools.build:gradle:3.3.1'. im using geolocator 3.0.1. follow this link https://www.youtube.com/watch?v=ZRl4t2KdEHQ and then do what i have said above

All 15 comments

for me , i added the android migration to the gradle properties file and then changed classpath 'com.android.tools.build:gradle:3.2.1' to classpath 'com.android.tools.build:gradle:3.3.1'. im using geolocator 3.0.1. follow this link https://www.youtube.com/watch?v=ZRl4t2KdEHQ and then do what i have said above

I

for me , i added the android migration to the gradle properties file and then changed classpath 'com.android.tools.build:gradle:3.2.1' to classpath 'com.android.tools.build:gradle:3.3.1'. im using geolocator 3.0.1. follow this link https://www.youtube.com/watch?v=ZRl4t2KdEHQ and then do what i have said above

when i added the (android.useAndroidX=true
android.enableJetifier=true)
to the gradle properties it worked thanks

Thanks @aidooyaw1992 , changing the classpath to 3.3.1 worked for me too :)

I

for me , i added the android migration to the gradle properties file and then changed classpath 'com.android.tools.build:gradle:3.2.1' to classpath 'com.android.tools.build:gradle:3.3.1'. im using geolocator 3.0.1. follow this link https://www.youtube.com/watch?v=ZRl4t2KdEHQ and then do what i have said above

when i added the (android.useAndroidX=true
android.enableJetifier=true)
to the gradle properties it worked thanks

I had these set and the same issue was happening.
What solved for me was the tip from @aidooyaw1992, changing the classpath to gradle:3.3.1.

Thanks, @aidooyaw1992!

My pleasure

On Mon, 18 Mar 2019, 17:17 Matheus Henrique de Oliveira, <
[email protected]> wrote:

I

for me , i added the android migration to the gradle properties file and
then changed classpath 'com.android.tools.build:gradle:3.2.1' to classpath
'com.android.tools.build:gradle:3.3.1'. im using geolocator 3.0.1. follow
this link https://www.youtube.com/watch?v=ZRl4t2KdEHQ and then do what i
have said above

when i added the (android.useAndroidX=true
android.enableJetifier=true)
to the gradle properties it worked thanks

I had these set and the same issue was happening.
What solved for me was the tip from @aidooyaw1992
https://github.com/aidooyaw1992, changing the classpath to gradle:3.3.1.

Thanks, @aidooyaw1992 https://github.com/aidooyaw1992!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/BaseflowIT/flutter-geolocator/issues/228#issuecomment-474014943,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIG4X9VG3JH5L3NctGCqQ0NzTDuWl3XGks5vX8obgaJpZM4brXKj
.

I there mates... Facing the same issue did solved it by changing the classpath from 3.2.1 to gradle:3.3.0 (not 3.3.1); and also did add the (android.useAndroidX=true
android.enableJetifier=true) to gradle.properties ....

Not sure wich one made it happend...

Thaks a lot, futter team...

Guys, that would be very nice if you could tell us in which files you made the changes. I did a search for com.android.tools.build:gradle:, found 1 match, but now I get another error :

Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

Edit:
classPath change is at root of Android folder, file build.gradle
The two boolean are also at the root of Android folder, file gradle.properties, just add the two lines

Now it works.

Isn't dangerous to randomly change properties ? Will it still be compatible with older Android version ?

@Robouste, the problem is that we have upgraded the Geolocator plugin to support AndroidX (as well as still be compatible with older Android versions). This means you will also have to upgrade you App which can be done following these instructions:

https://github.com/BaseflowIT/flutter-geolocator/issues/196#issuecomment-465460801

try to add script in app level

subprojects {
project.evaluationDependsOn(':app')
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "28.0.0"
}
}
}
}

if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx') ) {
details.useVersion "1.0.1"
}

Its working fine by adding android.enableJetifier=true and android.useAndroidX=true in build project and change the classpath to 3.3.1

Following solved my issue
(1)Adding Two lines to gradle properties
android.enableJetifier=true
android.useAndroidX=true

(2)Add following to root gradle

subprojects {
project.evaluationDependsOn(':app')
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "29.0.0"
}
}
}
}

对我来说,我将Android迁移添加到gradle属性文件中,然后将类路径'com.android.tools.build:gradle:3.2.1'更改为类路径'com.android.tools.build:gradle:3.3.1'。即时通讯使用geolocator 3.0.1。按照此链接https://www.youtube.com/watch?v=ZRl4t2KdEHQ,然后按照我上面所说的做
解决了我的问题,谢谢大佬

Thanks aidooyaw1992 that worked for me.
Another problem I had was that intl 0.16 is incompatible with flutter_localizations but you can declare

dependencies:
...
flutter_localizations:
sdk: flutter
intl: 0.15.8
...

and then override
dependency_overrides:
intl: ^0.16.0

and it works for dependencies on intl ^0.16.0

Was this page helpful?
0 / 5 - 0 ratings