Ошибка при использовании image_picker во флаттере - PullRequest
0 голосов
/ 10 апреля 2020

Хи, я новичок в трепетании, и во время работы с приложением, которое использует image_picker для получения изображений из галереи, я столкнулся с этой ошибкой.

C:\Users\Hrishabh Mishra\Desktop\FDR\Flutter\course\08\mycameraapp>flutter run
Launching lib\main.dart on Redmi Note 5 Pro in debug mode...
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:15: error: package android.support.annotation does not exist
import android.support.annotation.VisibleForTesting;
                                 ^
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:16: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
                             ^
  symbol:   class ActivityCompat
  location: package android.support.v4.app
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:17: error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
                                 ^
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerFileProvider.java:3: error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
                                 ^
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerFileProvider.java:10: error: cannot find symbol
public class ImagePickerFileProvider extends FileProvider {}
                                             ^
  symbol: class FileProvider
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerPlugin.java:8: error: package android.support.annotation does not exist
import android.support.annotation.VisibleForTesting;
                                 ^
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:68: error: cannot find symbol
  @VisibleForTesting static final int REQUEST_CODE_CHOOSE_IMAGE_FROM_GALLERY = 2342;
   ^
  symbol:   class VisibleForTesting
  location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:69: error: cannot find symbol
  @VisibleForTesting static final int REQUEST_CODE_TAKE_IMAGE_WITH_CAMERA = 2343;
   ^
  symbol:   class VisibleForTesting
  location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:70: error: cannot find symbol
  @VisibleForTesting static final int REQUEST_EXTERNAL_IMAGE_STORAGE_PERMISSION = 2344;
   ^
  symbol:   class VisibleForTesting
  location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:71: error: cannot find symbol
  @VisibleForTesting static final int REQUEST_CAMERA_IMAGE_PERMISSION = 2345;
   ^
  symbol:   class VisibleForTesting
  location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:72: error: cannot find symbol
  @VisibleForTesting static final int REQUEST_CODE_CHOOSE_VIDEO_FROM_GALLERY = 2352;
   ^
  symbol:   class VisibleForTesting
  location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:73: error: cannot find symbol
  @VisibleForTesting static final int REQUEST_CODE_TAKE_VIDEO_WITH_CAMERA = 2353;
   ^
  symbol:   class VisibleForTesting
  location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:74: error: cannot find symbol
  @VisibleForTesting static final int REQUEST_EXTERNAL_VIDEO_STORAGE_PERMISSION = 2354;
   ^
  symbol:   class VisibleForTesting
  location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:75: error: cannot find symbol
  @VisibleForTesting static final int REQUEST_CAMERA_VIDEO_PERMISSION = 2355;
   ^
  symbol:   class VisibleForTesting
  location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:77: error: cannot find symbol
  @VisibleForTesting final String fileProviderName;
   ^
  symbol:   class VisibleForTesting
  location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:164: error: cannot find symbol
  @VisibleForTesting
   ^
  symbol:   class VisibleForTesting
  location: class ImagePickerDelegate
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerPlugin.java:40: error: cannot find symbol
  @VisibleForTesting
   ^
  symbol:   class VisibleForTesting
  location: class ImagePickerPlugin
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:122: error: cannot find symbol
            return ActivityCompat.checkSelfPermission(activity, permissionName)
                   ^
  symbol: variable ActivityCompat
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:128: error: cannot find symbol
            ActivityCompat.requestPermissions(activity, new String[] {permissionName}, requestCode);
            ^
  symbol: variable ActivityCompat
H:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.4.12+1\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java:140: error: cannot find symbol
            return FileProvider.getUriForFile(activity, fileProviderName, file);
                   ^
  symbol: variable FileProvider
20 errors

FAILURE: Build failed with an exception.
  • Что пошло не так:
Execution failed for task ':image_picker:compileDebugJavaWithJavac'.  
Compilation failed; see the compiler error output for details.
  • Попробуйте: Запустите с параметром --stacktrace, чтобы получить трассировку стека. Запустите с параметром --info или --debug, чтобы получить больше выходных данных журнала. Выполните команду --scan, чтобы получить полное представление.

  • Получите дополнительную помощь по https://help.gradle.org

BUILD FAILED in 28s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        32.5s
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 image_picker...
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done                   22.3s
WARNING: The option setting 'android.enableR8=true' is experimental and unsupported.
The current default is 'false'
Consider disabling R8 by removing 'android.enableR8=true' from your gradle.properties before publishing your app.


FAILURE: Build failed with an exception.
  • Что пошло не так:
A problem occurred configuring root project 'imagepicker'.   
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
  • Попробуйте: Запустите с опцией --stacktrace, чтобы получить трассировку стека. Запустите с параметром --info или --debug, чтобы получить больше выходных данных журнала. Выполните команду --scan, чтобы получить полное представление.

  • Получите дополнительную помощь по https://help.gradle.org

BUILD FAILED in 16s

Не удалось собрать плагин image_picker из-за проблемы, описанной выше.

1 Ответ

0 голосов
/ 10 апреля 2020
SDK location not found. Define location with sdk.dir in the local.properties file or 
with an ANDROID_HOME environment variable.

Сначала настройте Android SDK.

Метод 1:

  1. Go для настроек
  2. Расширение языка и рамок
  3. Выбрать флаттер
  4. Введите путь SDK флаттера в Путь SDK флаттера в текстовом поле
  5. Нажмите Ok

Метод 2:

Flutter предоставляет команду для обновления пути Android SDK:

Use flutter config --android-sdk <path-to-your-android-sdk-path>
...