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

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

Closed
1 task
deserwantus opened this issue Mar 12, 2019 · 15 comments

Comments

@deserwantus
Copy link

🐛 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:

  • 📱 iOS
  • [*] 🤖 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!

@aidooyaw1992
Copy link

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

@Muhammad-saafan
Copy link

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

@felpsio
Copy link

felpsio commented Mar 14, 2019

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

@mathshenry
Copy link

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!

@aidooyaw1992
Copy link

aidooyaw1992 commented Mar 18, 2019 via email

@Immortalin
Copy link

ref: Lyokone/flutterlocation#117

Looks similar.

@bytelyus
Copy link

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...

@Robouste
Copy link

Robouste commented Apr 12, 2019

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 ?

@mvanbeusekom
Copy link
Member

@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:

#196 (comment)

@saravananmnm
Copy link

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"
}
}
}
}

@saravananmnm
Copy link

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

@bishalceb
Copy link

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

@ffalpha
Copy link

ffalpha commented Sep 16, 2019

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"
}
}
}
}

@lkeepOn
Copy link

lkeepOn commented Nov 29, 2019

对我来说,我将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,然后按照我上面所说的做
解决了我的问题,谢谢大佬

@mawkor2
Copy link

mawkor2 commented Dec 1, 2019

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

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