How to set up Android build on Visual Studio Team Services - android

I am fairly new to VSTS and the whole Microsoft Online Services Platform.
I am facing a problem when trying to initialise a build on our VSTS repository. I have selected the default Android build setting from the drop down menu, but it does not work. Every time I try to build, I reach the gradlew build stage and I get the error: Error: D:\a\1\s\gradlew.bat failed with return code: 1
I can build the code using the android Studio IDE, but I now need to use VSTS.
`
Any help would be much appreciated. Thank you!
EDIT: Here is the full log of the build
2018-07-28T19:23:31.6824618Z ##[section]Starting: gradlew build
2018-07-28T19:23:31.6830050Z ==============================================================================
2018-07-28T19:23:31.6830213Z Task : Gradle
2018-07-28T19:23:31.6830359Z Description : Build using a Gradle wrapper script
2018-07-28T19:23:31.6830487Z Version : 2.137.1
2018-07-28T19:23:31.6830608Z Author : Microsoft Corporation
2018-07-28T19:23:31.6830766Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613720)
2018-07-28T19:23:31.6830930Z ==============================================================================
2018-07-28T19:23:33.2899535Z SonarQube analysis is enabled.
2018-07-28T19:23:33.2900156Z Checkstyle analysis is enabled.
2018-07-28T19:23:33.2900406Z FindBugs analysis is enabled.
2018-07-28T19:23:33.2900654Z PMD analysis is enabled.
2018-07-28T19:23:33.2900905Z SYSTEMVSSCONNECTION exists true
2018-07-28T19:23:33.2901941Z [command]C:\Windows\system32\cmd.exe /D /S /C "D:\a\1\s\gradlew.bat build sonarqube -I D:\a\_tasks\Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4\2.137.1\node_modules\codeanalysis-common\checkstyle.gradle -I D:\a\_tasks\Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4\2.137.1\node_modules\codeanalysis-common\findbugs.gradle -I D:\a\_tasks\Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4\2.137.1\node_modules\codeanalysis-common\pmd.gradle"
2018-07-28T19:24:05.3436260Z Downloading https://services.gradle.org/distributions/gradle-4.6-all.zip
2018-07-28T19:24:29.2233239Z Unzipping C:\Users\VssAdministrator\.gradle\wrapper\dists\gradle-4.6-all\bcst21l2brirad8k2ben1letg\gradle-4.6-all.zip to C:\Users\VssAdministrator\.gradle\wrapper\dists\gradle-4.6-all\bcst21l2brirad8k2ben1letg
2018-07-28T19:25:41.8632779Z Starting a Gradle Daemon (subsequent builds will be faster)
{A series of downloads for the packages we use, omitted for character limit's sake}
2018-07-28T19:26:20.6092629Z Applying the Checkstyle plugin to project s
2018-07-28T19:26:20.6792218Z Applying the FindBugs plugin to project s
2018-07-28T19:26:20.6792841Z Applying the PMD plugin to all projects
2018-07-28T19:26:23.9485033Z Applying the Checkstyle plugin to project volve
2018-07-28T19:26:23.9621010Z Applying the FindBugs plugin to project volve
2018-07-28T19:26:23.9621425Z Applying the PMD plugin to all projects
2018-07-28T19:26:28.6406403Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6407012Z support library package not found: android.support.constraint.motion.
2018-07-28T19:26:28.6407656Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6407994Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6408285Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6408525Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6408784Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6409785Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6410031Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6410325Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6410567Z support library package not found: android.support.constraint.
2018-07-28T19:26:28.6410830Z support library package not found: android.support.constraint.
2018-07-28T19:26:39.5509667Z Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
2018-07-28T19:26:39.6403284Z registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
2018-07-28T19:26:39.7610924Z registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
2018-07-28T19:26:39.7830309Z Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
2018-07-28T19:26:39.7922748Z registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
2018-07-28T19:26:39.8933520Z registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
2018-07-28T19:26:39.9253837Z
2018-07-28T19:26:39.9254479Z FAILURE: Build failed with an exception.
2018-07-28T19:26:39.9254716Z
2018-07-28T19:26:39.9254905Z * What went wrong:
2018-07-28T19:26:39.9255123Z Task 'sonarqube' not found in root project 's'.
2018-07-28T19:26:39.9255269Z
2018-07-28T19:26:39.9255429Z * Try:
2018-07-28T19:26:39.9255675Z Run gradlew tasks to get a list of available tasks. 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.
2018-07-28T19:26:39.9255897Z
2018-07-28T19:26:39.9256078Z * Get more help at https://help.gradle.org
2018-07-28T19:26:39.9256222Z
2018-07-28T19:26:39.9256413Z BUILD FAILED in 2m 49s
2018-07-28T19:26:40.5195018Z Error: D:\a\1\s\gradlew.bat failed with return code: 1
2018-07-28T19:26:40.5195970Z at ChildProcess.<anonymous> (D:\a\_tasks\Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4\2.137.1\node_modules\vsts-task-lib\toolrunner.js:569:30)
2018-07-28T19:26:40.5196934Z at emitTwo (events.js:106:13)
2018-07-28T19:26:40.5197445Z at ChildProcess.emit (events.js:191:7)
2018-07-28T19:26:40.5198292Z at maybeClose (internal/child_process.js:886:16)
2018-07-28T19:26:40.5198771Z at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
2018-07-28T19:26:40.6483964Z ##[warning]No test result files matching D:\a\1\s\**\TEST-*.xml were found, so publishing JUnit test results is being skipped.
2018-07-28T19:26:40.6494902Z ##[error]Error: D:\a\1\s\gradlew.bat failed with return code: 1
2018-07-28T19:26:40.6541754Z ##[section]Finishing: gradlew build

You can use Android build template to build your android project in VSTS.
Detail configuration for Gradle task as below:
Gradle wrapper: relative path to gradlew file
Working directory: same directory where gradlew file exist. It use $(Build.SourcesDirectory) directory by default.
Tasks: build
Such as if the android project with the file structure as intro_android_demo (gradlew file in the root directory of the repo), then the Gradle task configuration should as below:

Related

Error And Failed When Try To Use expo run:android React Native Expo

Could anyone figure out why when I build using expo run:android I got failed ?
This the detail error :
> Configure project :expo-file-system
WARNING: Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'.
It will be removed in version 5.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.
> Configure project :expo-structured-headers
Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.
> Configure project :expo
Using expo modules
- expo-application (4.0.2)
- expo-constants (13.0.2)
- expo-crypto (10.1.2)
- expo-error-recovery (3.0.5)
- expo-file-system (13.1.4)
- expo-font (10.0.5)
- expo-json-utils (0.2.1)
- expo-keep-awake (10.0.2)
- expo-manifests (0.2.4)
- expo-modules-core (0.6.5)
- expo-screen-orientation (4.1.2)
- expo-sharing (10.1.1)
- expo-splash-screen (0.14.2)
- expo-sqlite (10.1.1)
- expo-structured-headers (2.1.1)
- expo-updates (0.11.6)
- expo-web-browser (10.1.1)
> Configure project :react-native-reanimated
AAR for react-native-reanimated has been found
E:\Application\daastradingapp\node_modules\react-native-reanimated\android\react-native-reanimated-64-jsc.aar
> Task :react-native-reanimated:replaceSoTaskDebug FAILED
FAILURE: Build failed with an exception.
* Where:
Build file 'E:\Application\daastradingapp\node_modules\react-native-reanimated\android\build.gradle' line: 122
* What went wrong:
Execution failed for task ':react-native-reanimated:replaceSoTaskDebug'.
> Warning: Could not find file E:\Application\daastradingapp\android\app\build\tmp\libSo\jni\x86\libfbjni.so to copy.
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 51s
569 actionable tasks: 6 executed, 563 up-to-date
E:\Application\daastradingapp\android\gradlew.bat exited with non-zero code: 1
Error: E:\Application\daastradingapp\android\gradlew.bat exited with non-zero code: 1
at ChildProcess.completionListener (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\spawn-async\src\spawnAsync.ts:65:13)
at Object.onceWrapper (events.js:520:26)
at ChildProcess.emit (events.js:400:28)
at ChildProcess.cp.emit (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\node_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (internal/child_process.js:1055:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
...
at spawnAsync (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\spawn-async\src\spawnAsync.ts:26:19)
at spawnGradleAsync (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\spawnGradleAsync.ts:83:18)
at assembleAsync (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\spawnGradleAsync.ts:57:16)
at actionAsync (C:\Users\Dennis_Liu\AppData\Roaming\npm\node_modules\expo-cli\src\commands\run\android\runAndroid.ts:143:9)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
Note:
I use expo bare worfklow
Finally solved the problem.
In Expo if with use a Native Module we cannot run in Expo Go.
If we want to publish to Expo Dashboard with Native Module
Use EAS Build.
Example :
Run eas build --platform android to build for Android.
Run eas build --platform ios to build for iOS.
Alternatively, you can run eas build --platform all to build for Android and iOS at the same time.
The complete documentation can be found in here :
EAS Documentation Expo

React Native run - Android producing strange error

I'd like to ask about the following error. So I've been developing a small BLE app a year ago and successfully managed to implement it. I did not push it to the Google Play store but instead installed it somehow on the Android via usb.
However, now I need to get it back up and running but am facing a plethora of errors.
PS C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard> npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1302 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
> Configure project :app
Installing unimodules:
unimodules-core#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\#unimodules\core
unimodules-react-native-adapter#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\#unimodules\react-native-adapter
expo-app-loader-provider#8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-app-loader-provider
expo-constants#8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-constants
expo-error-recovery#1.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-error-recovery
expo-file-system#8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-file-system
expo-font#8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-font
expo-keep-awake#8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-keep-awake
expo-linear-gradient#8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-linear-gradient
expo-location#8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-location
expo-permissions#8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-permissions
expo-sqlite#8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-sqlite
expo-web-browser#8.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\expo-web-browser
unimodules-barcode-scanner-interface#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-barcode-scanner-interface
unimodules-camera-interface#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-camera-interface
unimodules-constants-interface#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-constants-interface
unimodules-face-detector-interface#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-face-detector-interface
unimodules-file-system-interface#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-file-system-interface
unimodules-font-interface#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-font-interface
unimodules-image-loader-interface#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-image-loader-interface
unimodules-permissions-interface#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-permissions-interface
unimodules-sensors-interface#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-sensors-interface
unimodules-task-manager-interface#5.0.0 from C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard\node_modules\unimodules-task-manager-interface
The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build.
This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal.
Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects.
If the parent project does not need the plugin, add 'apply false' to the plugin line.
See: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl
The Kotlin plugin was loaded in the following projects: ':expo-error-recovery', ':expo-permissions'
> Task :#react-native-community_async-storage:compileDebugJavaWithJavac FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings
10 actionable tasks: 1 executed, 9 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':#react-native-community_async-storage:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files (x86)\Java\jre1.8.0_251 contains a valid JDK installation.
* 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 31s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
PS C:\Users\stefanec\Desktop\SOC\i_garden\i_garden\iGard>
Looks like you don't have JDK installed.
Use the command below to install it with brew if you're on a Mac or follow the docs to how to install on your specific machine
brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
Follow this guide to install on windows
See docs https://reactnative.dev/docs/_getting-started-macos-android#installing-dependencies

flutter plugin cloud_firestore could not be built because CloudFirestorePlugin.java uses unchecked or unsafe operations [flutter build apk]

I am building a flutter app that uses several firebase dependencies but the cloud_firestore dependency always returns errors when debugging and building the app.
Here is the Build Log
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...
Note: /flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.13.4+2/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Calling mockable JAR artifact transform to create file: /Users/user/.gradle/caches/transforms-2/files-2.1/323813f5a095cba9aa563dadb749a1cb/android.jar with input /Users/user/Library/Android/sdk/platforms/android-28/android.jar
Calling mockable JAR artifact transform to create file: /Users/user/.gradle/caches/transforms-2/files-2.1/ff23381473fa92d0c047c8663bfbe6a6/android.jar with input /Users/user/Library/Android/sdk/platforms/android-27/android.jar
Calling mockable JAR artifact transform to create file: /Users/user/.gradle/caches/transforms-2/files-2.1/43c9f60e6803ddaaef16828845e40f49/android.jar with input /Users/user/Library/Android/sdk/platforms/android-29/android.jar
Removed unused resources: Binary resource data reduced from 329KB to 261KB: Removed 20%
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':google_sign_in:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/Users/user/.gradle/caches/transforms-2/files-2.1/9dacf9516413cf5e5b34c6b4508340e4/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/user/.gradle/caches/transforms-2/files-2.1/9dacf9516413cf5e5b34c6b4508340e4/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
* 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 7m 10s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 441.0s (!)
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
✏️ Creating 'android/settings_aar.gradle'... 35ms
✓ 'android/settings_aar.gradle' created successfully.
Building plugin cloud_firestore...
The plugin cloud_firestore could not be built due to the issue above.
pubspec.yaml firebase dependencies used:
firebase_core: ^0.4.4+3
cloud_firestore: ^0.13.4+2
firebase_auth: ^0.15.5+2
Anyone with working firebase dependencies kindly share them below.
Seems that is a transient issue and some piece of the tools stack is not synchronized correctly.
My suggestion is to reload the dependencies and the tools involved since in the Issue Tracker things like Android Studio, or Gradle are restored by:
Removing folders: /.gradle and /.gradle
Trying to setup using local gradle distribution.
Hope this was useful!
To solve this problem, try two things:
In project/android/app/build.gradle
defaultConfig {
...
multiDexEnabled true
}
In terminal run flutter pub upgrade

Could not find method google() for arguments [] on repository container. (flutter)

cmd > flutter run
Launching lib\main.dart on Lenovo A6020a40 in debug mode...
Initializing gradle... 1.8s
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "C:\Users\Mantu Kumbhakar\Downloads\sytody-master\android\gradlew.bat" exited abnormally:
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\Mantu
Kumbhakar\AppData\Local\Android\sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
BUILD FAILED
Total time: 3.065 secs
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
FAILURE: Build failed with an exception.
Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 27
What went wrong:
A problem occurred evaluating script.
Could not find method google() for arguments [] on repository container.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Command: C:\Users\Mantu Kumbhakar\Downloads\sytody-master\android\gradlew.bat app:properties
This error is sometimes generated when you try to run a project created using an older version of Flutter than the one you're currently using.
The issue can also be found on the Flutter GitHub repository.
Until an official solution to this issue is provided, you can fix it by recreating the project with your newer version of Flutter, as suggested in the above GitHub issue too.
Above, when Abhijeet said: "This error is sometimes generated when you try to run a project created using an older version of Flutter than the one you're currently using." is correct.
Causes
When a project is created with flutter create foo several files in the ios/ and android/ sub-directories are created.
Newer Flutter versions might generate these files a bit differently and projects created with older Flutter versions might cause issues.
to fix:
Supposing that your project is in c:\root_of_your_project\name_of_your_project
Delete the ios/ and android/ directories and go to root directory of your project with CMD, and:
c:\root_of_your_project\flutter create -a kotlin name_of_your_project
and
c:\root_of_your_project\flutter create -i swift name_of_your_project

Gradle Build failing after adding image_picker plugin in flutter app

When I run the application without adding image picker as a dependency, it works fine. But when I add the plugin and run, it is giving me gradle build failed error.
Resolving dependencies... 5.0s
Gradle task 'assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
D8: Program type already present: android.support.v4.app.INotificationSideChannel
*********************************************************
WARNING: This version of image_picker will break your Android build if it or its dependencies aren't compatible with AndroidX.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\142.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\118.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\94.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\124.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\88.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\136.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\157.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\103.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\163.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\151.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\127.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\100.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\166.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\139.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\97.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\115.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\160.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\169.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\106.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\154.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\148.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\112.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\172.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\133.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\109.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\91.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\121.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\130.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\145.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\27.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\52.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\18.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\43.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\19.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\51.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\60.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\36.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\34.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\42.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\28.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\50.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\33.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\37.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\2.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\9.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\25.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\45.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\32.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\38.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\39.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\44.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\57.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\26.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\8.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\31.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\30.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\56.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\13.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\14.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\21.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\49.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\7.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\12.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\15.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\55.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\58.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\6.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\20.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\46.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\11.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\59.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\24.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\29.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\54.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\16.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\41.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\5.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\10.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\3.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\17.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\23.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\47.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\40.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\53.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\35.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\4.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\48.jar, D:\fluuter_projects\motor_app_demo\build\app\intermediates\transforms\dexBuilder\debug\22.jar
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 22s
Gradle task 'assembleDebug'... Done 23.7s
Gradle task assembleDebug failed with exit code 1
Due to Android X Support...
Simple Solution Avoiding AndroidX and rollback to older version
dependencies:
image_picker: 0.4.12+1
or
Migrate Flutter app to AndroidX
Import your Flutter app into Android Studio so that the IDE can parse the Android code following the steps in Editing Android code in Android Studio with full IDE support.
Follow the instructions for Migrating to AndroidX.
https://flutter.io/docs/development/packages-and-plugins/androidx-compatibility
https://developer.android.com/jetpack/androidx/migrate

Categories

Resources