Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception thrown in build by image_picker

I am wrestling problems with image_picker for two days now. It started yesterday noon when I tried to debug my application. It would debug fine before and as far as I remember I didn't change anything in that time. It throwed unexpected element <queries> found in <manifest>. error and just like the error log from today below it started Jetfier to solve the incompatibility. The error Jetfier throwed yesterday was something like SDK location not found. Define location in local.properties or with an ANDROID_SDK_ROOT environment variable. But SDK location was defined in local.properties and I also created the ANDROID_SDK_ROOT env. variable with the SDK location but the error stayed the same.

Today I cleared the flutter folder completely and I reinstalled it. After that I had some problems with device-info but eventually it was resolved. Now I am stuck here and I am making no progress whatsoever. If I remove <queries> in AndroidManifest.xml, it is put there again when try to run the program so that's not a solution.

I call it in pubspec.yaml as file_picker: ^2.0.10 under dependencies and I tried pub get, pub cache repair, pub clean in different orders. If I remove the file_picker and all it's uses in the project, rest of the application runs just fine. I tried file_picker in another project, something a lot more basic and it also threw the same exception there.

Below is the error code. If you need anymore details let me know.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\ASUS\AndroidStudioProjects\flutterdb\intern1\build\file_picker\intermediates\library_manifest\debug\AndroidManifest.xml:9:5-15:15: AAPT: error: unexpected element <queries> found in <manifest>.


* 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

BU�LD FAILED in 21s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin file_picker...
Running Gradle task 'assembleAarRelease'...

C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:10: error: cannot find symbol
import androidx.lifecycle.DefaultLifecycleObserver;
                         ^
  symbol:   class DefaultLifecycleObserver
  location: package androidx.lifecycle
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:20: error: cannot find symbol
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
                                                    ^
  symbol:   class FlutterLifecycleAdapter
  location: package io.flutter.embedding.engine.plugins.lifecycle
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:38: error: cannot find symbol
            implements Application.ActivityLifecycleCallbacks, DefaultLifecycleObserver {
                                                               ^
  symbol:   class DefaultLifecycleObserver
  location: class FilePickerPlugin
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:45: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:49: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:53: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:57: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:61: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:66: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:277: error: cannot find symbol
            this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
                             ^
  symbol:   variable FlutterLifecycleAdapter
  location: class FilePickerPlugin
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:278: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
            this.lifecycle.addObserver(this.observer);
                                           ^
C:\Users\ASUS\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\file_picker-2.0.10\android\src\main\java\com\mr\flutter\plugin\filepicker\FilePickerPlugin.java:286: error: incompatible types: FilePickerPlugin.LifeCycleObserver cannot be converted to LifecycleObserver
        this.lifecycle.removeObserver(this.observer);
                                          ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
12 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileReleaseJavaWithJavac'.
> 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

BUİLD FAILED in 3s

Exception: The plugin file_picker could not be built due to the issue above.
like image 482
One Bad Student Avatar asked Oct 23 '20 15:10

One Bad Student


Video Answer


1 Answers

For those who didn't know (including myself) there are two build.gradle files

  1. android/build.gradle
  2. android/app/build.gradle

step 1 inside android/build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        // classpath 'com.android.tools.build:gradle:3.5.0' before
        classpath 'com.android.tools.build:gradle:4.0.1' // after
    }
}

step 2 inside android/gradle/wrapper/gradle-wrapper.properties


distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

# BEFORE
# distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
# AFTER
distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip

step 3 rebuild project

it might take while because it will download new gradle

like image 109
sultanmyrza Avatar answered Nov 01 '22 00:11

sultanmyrza