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

Plugins do not support AndroidX #23995

Closed
shinayser opened this issue Nov 6, 2018 · 30 comments
Closed

Plugins do not support AndroidX #23995

shinayser opened this issue Nov 6, 2018 · 30 comments
Assignees
Labels
c: crash Stack traces logged to the console p: camera The camera plugin package flutter/packages repository. See also p: labels. platform-android Android applications specifically

Comments

@shinayser
Copy link

shinayser commented Nov 6, 2018

I have a flutter project. Inside of its android folder I have a lot of android code, including background processing classes and some native UI. I updated this code to use the new androidX packages.

Now, some of the plugins stopped working. A example is the permission_handler plugin.

permissionhandler\PermissionHandlerPlugin.kt: (10, 31): Unresolved reference: ActivityCompat
permissionhandler\PermissionHandlerPlugin.kt: (11, 27): Unresolved reference: content
permissionhandler\PermissionHandlerPlugin.kt: (152, 37): Unresolved reference: ContextCompat
permissionhandler\PermissionHandlerPlugin.kt: (191, 20): Unresolved reference: ActivityCompat
permissionhandler\PermissionHandlerPlugin.kt: (235, 13): Unresolved reference: ActivityCompat`

I believe this is because the native Android part of my app is using the AndroidX packages, since those plugins are still using the old support library. In the current state, it is impossible to me to roll back to the support library.

Also, when I add the camera plugin I get the following error:

error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^

Is this a intended behavior? Can someone give me a light?

[√] Flutter (Channel beta, v0.9.4, on Microsoft Windows [versão 10.0.17134.376], locale pt-BR)
[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[√] Android Studio (version 3.2)
[√] IntelliJ IDEA Community Edition (version 2018.2)
[√] Connected devices (1 available)

• No issues found!`
@shinayser
Copy link
Author

shinayser commented Nov 6, 2018

Report: I could make my project compile with the camera plugin by editting its gradle code inside the .pub-cache/.../camera-0.2.4 folder. I converted it to androidx packages and now the project compiles.
But this is a awful workaround that will break everytime the camera plugin gets a new version...

Flutter needs to upgrade its packages to androidX as soon as it can, because the support 28.0.0 is the latest version of support libraries. Only androidx will receive new updates.

@zoechi zoechi added c: crash Stack traces logged to the console platform-android Android applications specifically plugin labels Nov 9, 2018
@zoechi zoechi added this to the Goals milestone Nov 9, 2018
@jiechic
Copy link

jiechic commented Dec 18, 2018

I also have this problem ,when i use flutter module for my android project,use flutter packages get,then flutter android source would be replace by default and it is use support library ,not the androidx library

@dnfield
Copy link
Contributor

dnfield commented Dec 20, 2018

related to #23586.

We're working on making it easier to update this stuff for the engine, but we'll have to think of plugins as well...

@zoechi zoechi added the p: camera The camera plugin label Jan 4, 2019
@amirh amirh modified the milestones: Goals, Near-term Goals Jan 10, 2019
@japborst
Copy link

Any updates on supporting for AndroidX?

@dnfield
Copy link
Contributor

dnfield commented Jan 25, 2019

This is done now for all first party plugins, but keep in mind this may be an issue for various third party plugins out there. If you find other issues with those, please open an issue in the appropriate repository for it.

@mklim
Copy link
Contributor

mklim commented Jan 25, 2019

I am still waiting to publish a few of the updated packages to pub. I'll reopen this and close it once it's published everywhere. /cc @kroikie

  • location_background
  • cloud_functions
  • firebase_dynamic_links
  • firebase_performance
  • firebase_remote_config

@mklim mklim reopened this Jan 25, 2019
@mklim mklim reopened this Jan 26, 2019
mklim pushed a commit to flutter/plugins that referenced this issue Jan 28, 2019
The AndroidX migration didn't increment the major version for plugins >=
1.0.0. This commit reverts the code changes in the affected plugins.

It's critical that the forward roll PR is published with this so that clients
that have previously migrated aren't broken by the revert. I'm not planning
on merging this into master until the forward roll (#1128) is
also LGTMed and ready to merge.

flutter/flutter#27128
flutter/flutter#23995
@telthemweb
Copy link

this error is killing me

@lhcdims
Copy link

lhcdims commented Feb 13, 2019

Following Error appears SUDDENLY with no code changes, after Flutter Packages Upgrade, I believe it's the new camera plugin bugs.

Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\2.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\3.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\4.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\5.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\6.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\7.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\8.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\9.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\10.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\11.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\12.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\13.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\14.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\15.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\16.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\17.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\18.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\19.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\20.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\21.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\22.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\23.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\24.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\25.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\26.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\27.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\28.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\29.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\30.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\31.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\32.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\33.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\34.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\35.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\36.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\37.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\38.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\39.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\40.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\41.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\42.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\43.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\44.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\45.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\46.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\47.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\48.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\49.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\50.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\51.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\52.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\53.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\54.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\55.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\56.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\57.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\58.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\59.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\60.jar, D:\flutter\mms01\build\app\intermediates\transforms\dexBuilder\debug\61.jar
         *********************************************************
WARNING: This version of camera will break your Android build if it or its dependencies aren't compatible with AndroidX.
         See https://goo.gl/CP92wY for more information on the problem and how to fix it.
         This warning prints for all Android build failures. The real root cause of the error may be unrelated.
         *********************************************************
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: android.support.v4.app.INotificationSideChannel

* 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 24s
Finished with error: Gradle task assembleDebug failed with exit code 1

@zoechi
Copy link
Contributor

zoechi commented Feb 13, 2019

You need either limit the version of the camera dependency in pubspec.yaml or follow the instructions to migrate to AndroidX.

0.2.9+1 is the last version that does not depend on AndroidX (https://pub.dartlang.org/packages/camera#030) so

dependencies:
  camera: ^0.2.9

and running flutter packages get should fix it.
You might get similar errors for other plugins if you didn't apply such constraints.

@mklim
Copy link
Contributor

mklim commented Feb 14, 2019

The plugins have all been updated to AndroidX, so I'm going to close this as fixed.

The official guide for migrating apps and plugins to work with AndroidX is up on our website. Please feel empowered to file new issues if you're still running into crashes after following the guide, or if the guide is unclear.

@mklim mklim closed this as completed Feb 14, 2019
andreidiaconu pushed a commit to andreidiaconu/plugins that referenced this issue Feb 17, 2019
The original Android support libraries have been deprecated in favor of
AndroidX. This migration shouldn't affect behavior in a user noticeable
way, but does require plugin users to also migrate their app. See
[migrating to AndroidX](https://developer.android.com/jetpack/androidx/migrate).

Fixes flutter/flutter#23995.
andreidiaconu pushed a commit to andreidiaconu/plugins that referenced this issue Feb 17, 2019
The AndroidX migration didn't increment the major version for plugins >=
1.0.0. This commit reverts the code changes in the affected plugins.

It's critical that the forward roll PR is published with this so that clients
that have previously migrated aren't broken by the revert. I'm not planning
on merging this into master until the forward roll (flutter#1128) is
also LGTMed and ready to merge.

flutter/flutter#27128
flutter/flutter#23995
andreidiaconu pushed a commit to andreidiaconu/plugins that referenced this issue Feb 17, 2019
This PR forward rolls the earlier breaking changes with a proper semantic version upgrade.

flutter/flutter#27128
flutter/flutter#23995
@saravananmnm
Copy link

saravananmnm commented Mar 5, 2019

geolocator:
-after adding this dependency, am getting following error from androidx
-Android studio 3.3.1

Launching lib\main.dart on E6553 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
E:\Flutter\flutter.pub-cache\hosted\pub.dartlang.org\geolocator-2.1.1\android\src\main\java\com\baseflow\flutter\plugin\geolocator\tasks\LastKnownLocationUsingLocationServicesTask.java:4: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
E:\Flutter\flutter.pub-cache\hosted\pub.dartlang.org\geolocator-2.1.1\android\src\main\java\com\baseflow\flutter\plugin\geolocator\tasks\LocationUpdatesUsingLocationServicesTask.java:5: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
^
E:\Flutter\flutter.pub-cache\hosted\pub.dartlang.org\geolocator-2.1.1\android\src\main\java\com\baseflow\flutter\plugin\geolocator\tasks\LastKnownLocationUsingLocationServicesTask.java:40: error: cannot find symbol
public void onFailure(@nonnull Exception e) {
^
symbol: class NonNull
E:\Flutter\flutter.pub-cache\hosted\pub.dartlang.org\geolocator-2.1.1\android\src\main\java\com\baseflow\flutter\plugin\geolocator\tasks\LocationUpdatesUsingLocationServicesTask.java:62: error: cannot find symbol
public void onComplete(@nonnull Task task) {
^
symbol: class NonNull
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':geolocator:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for 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 44s


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

@gitkarumuga
Copy link

gitkarumuga commented Apr 1, 2019

Faced the same issue. In my case, it's because of the "Firebase_auth" package used in a target Android SDK 28. As per the official documentation, the right version is 0.7.0 and NOT THE LATEST VERSION.

You can refer to the all packages which have conflict here

@Karlheinzniebuhr
Copy link

Same issues here

Launching lib\main.dart on SM G930F in debug mode...
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:14: error: package android.support.annotation does not exist
import android.support.annotation.MainThread;
                                 ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:15: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                                 ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:16: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:17: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
                             ^
  symbol:   class ActivityCompat
  location: package android.support.v4.app
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:18: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;
                                 ^
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:193: error: cannot find symbol
        int permissionState = ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION);
                              ^
  symbol:   variable ActivityCompat
  location: class LocationPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:198: error: cannot find symbol
        ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
        ^
  symbol:   variable ActivityCompat
  location: class LocationPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:203: error: cannot find symbol
        return ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_FINE_LOCATION);
               ^
  symbol:   variable ActivityCompat
  location: class LocationPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:296: error: cannot find symbol
            public void onFailure(@NonNull Exception e) {

  symbol:   variable ActivityCompat
  location: class LocationPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\location-1.4.1\android\src\main\java\com\lyokone\location\LocationPlugin.java:296: error: cannot find symbol
            public void onFailure(@NonNull Exception e) {
                                   ^
  symbol: class NonNull
9 errors
3 warnings

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':location:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for 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 14s
*******************************************************************************************
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.
*******************************************************************************************
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

collinjackson pushed a commit to collinjackson/flutterfire-old2 that referenced this issue Jun 24, 2019
The original Android support libraries have been deprecated in favor of
AndroidX. This migration shouldn't affect behavior in a user noticeable
way, but does require plugin users to also migrate their app. See
[migrating to AndroidX](https://developer.android.com/jetpack/androidx/migrate).

Fixes flutter/flutter#23995.
collinjackson pushed a commit to collinjackson/flutterfire-old2 that referenced this issue Jun 24, 2019
The AndroidX migration didn't increment the major version for plugins >=
1.0.0. This commit reverts the code changes in the affected plugins.

It's critical that the forward roll PR is published with this so that clients
that have previously migrated aren't broken by the revert. I'm not planning
on merging this into master until the forward roll (flutter/plugins#1128) is
also LGTMed and ready to merge.

flutter/flutter#27128
flutter/flutter#23995
collinjackson pushed a commit to collinjackson/flutterfire-old2 that referenced this issue Jun 24, 2019
This PR forward rolls the earlier breaking changes with a proper semantic version upgrade.

flutter/flutter#27128
flutter/flutter#23995
@pkonx
Copy link

pkonx commented Jul 10, 2019

how do i start projects with Android X support. the migrating instructions are not working

collinjackson pushed a commit to firebase/flutterfire that referenced this issue Aug 14, 2019
The original Android support libraries have been deprecated in favor of
AndroidX. This migration shouldn't affect behavior in a user noticeable
way, but does require plugin users to also migrate their app. See
[migrating to AndroidX](https://developer.android.com/jetpack/androidx/migrate).

Fixes flutter/flutter#23995.
collinjackson pushed a commit to firebase/flutterfire that referenced this issue Aug 14, 2019
The AndroidX migration didn't increment the major version for plugins >=
1.0.0. This commit reverts the code changes in the affected plugins.

It's critical that the forward roll PR is published with this so that clients
that have previously migrated aren't broken by the revert. I'm not planning
on merging this into master until the forward roll (flutter/plugins#1128) is
also LGTMed and ready to merge.

flutter/flutter#27128
flutter/flutter#23995
collinjackson pushed a commit to firebase/flutterfire that referenced this issue Aug 14, 2019
This PR forward rolls the earlier breaking changes with a proper semantic version upgrade.

flutter/flutter#27128
flutter/flutter#23995
@SunLongbri
Copy link

I also have this problem ,when i use flutter module for my android project,use flutter packages get,then flutter android source would be replace by default and it is use support library ,not the androidx library

Did you solved this problem?

@robsondon
Copy link

same issues here, someone fix it?

@pkonx
Copy link

pkonx commented Dec 4, 2019 via email

nksteven pushed a commit to nksteven/ntf-firebase_messaging that referenced this issue Apr 8, 2020
The original Android support libraries have been deprecated in favor of
AndroidX. This migration shouldn't affect behavior in a user noticeable
way, but does require plugin users to also migrate their app. See
[migrating to AndroidX](https://developer.android.com/jetpack/androidx/migrate).

Fixes flutter/flutter#23995.
nksteven pushed a commit to nksteven/ntf-firebase_messaging that referenced this issue Apr 8, 2020
The AndroidX migration didn't increment the major version for plugins >=
1.0.0. This commit reverts the code changes in the affected plugins.

It's critical that the forward roll PR is published with this so that clients
that have previously migrated aren't broken by the revert. I'm not planning
on merging this into master until the forward roll (flutter/plugins#1128) is
also LGTMed and ready to merge.

flutter/flutter#27128
flutter/flutter#23995
nksteven pushed a commit to nksteven/ntf-firebase_messaging that referenced this issue Apr 8, 2020
This PR forward rolls the earlier breaking changes with a proper semantic version upgrade.

flutter/flutter#27128
flutter/flutter#23995
@LuodiJackShen
Copy link

same issues here,someone fix it ?

@erperejildo
Copy link

erperejildo commented Mar 4, 2021

almost 1 year later same error

@github-actions
Copy link

github-actions bot commented Aug 5, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2021
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console p: camera The camera plugin package flutter/packages repository. See also p: labels. platform-android Android applications specifically
Projects
None yet
Development

No branches or pull requests