"flutter build apk" command fails after adding google_maps_flutter - android

I'm new to flutter and android development. I have a problem when building apk file with flutter build apk command and it shows error like this
C:\src\flutter_projects\beresin>flutter build apk
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#configu
e-abi-split
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':adhara_socket_io:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Wo
kers$ActionFacade
> Android resource linking failed
C:\Users\BERESIN\.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a84
18244d532fb7\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource
android:attr/fontVariationSettings not found.
C:\Users\BERESIN\.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a84
18244d532fb7\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 28s
Running Gradle task 'assembleRelease'... 29.7s
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 adhara_socket_io...
Running Gradle task 'assembleAarRelease'... 1.8s
√ Built build\app\outputs\repo.
Building plugin flutter_plugin_android_lifecycle...
Running Gradle task 'assembleAarRelease'... 1.3s
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\src\flutters\.pub-cache\hosted\pub.dartlang.org\flutter_plugin_a
droid_lifecycle-1.0.6\android\build.gradle' line: 22
* What went wrong:
A problem occurred evaluating root project 'flutter_plugin_android_lifecycle'.
> Failed to apply plugin [id 'com.android.library']
> Minimum supported Gradle version is 5.4.1. Current version is 4.10.2. If u
ing the gradle wrapper, try editing the distributionUrl in C:\src\flutters\.pub
cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecycle-1.0.6\android\gr
dle\wrapper\gradle-wrapper.properties to gradle-5.4.1-all.zip
* 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 1s
The plugin flutter_plugin_android_lifecycle could not be built due to the issue
above.
after a long time searching for solution on google, I've found an answer to solve that. I changed the gradle's distributionUrl on flutter_plugin_android_lifecycle package in .pub-cache folder to 5.4.1 as suggested, but it leads to another error like this.
C:\src\flutter_projects\beresin>flutter build apk
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#configur
e-abi-split
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':adhara_socket_io:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Wor
kers$ActionFacade
> Android resource linking failed
C:\Users\BERESIN\.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a843
18244d532fb7\core-1.0.0\res\values\values.xml:57:5-88:25: AAPT: error: resource
android:attr/fontVariationSettings not found.
C:\Users\BERESIN\.gradle\caches\transforms-2\files-2.1\0a271e99b6771ad4a843
18244d532fb7\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 15s
Running Gradle task 'assembleRelease'... 16.3s
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 adhara_socket_io...
Running Gradle task 'assembleAarRelease'... 1.6s
√ Built build\app\outputs\repo.
Building plugin flutter_plugin_android_lifecycle...
Running Gradle task 'assembleAarRelease'... 32.1s
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reus
ed, use --status for details
> Task :assembleAarRelease UP-TO-DATE
> Task :preBuild UP-TO-DATE
> Task :preReleaseBuild UP-TO-DATE
> Task :compileReleaseAidl NO-SOURCE
> Task :compileReleaseRenderscript NO-SOURCE
> Task :checkReleaseManifest
> Task :generateReleaseBuildConfig
> Task :generateReleaseResValues
> Task :generateReleaseResources
> Task :packageReleaseResources
> Task :mergeReleaseShaders
> Task :compileReleaseShaders
> Task :generateReleaseAssets
> Task :packageReleaseAssets
> Task :packageReleaseRenderscript NO-SOURCE
> Task :parseReleaseLibraryResources
> Task :processReleaseJavaRes NO-SOURCE
> Task :mergeReleaseJniLibFolders
> Task :processReleaseManifest
> Task :prepareLintJarForPublish
> Task :javaPreCompileRelease
> Task :mergeReleaseNativeLibs
> Task :stripReleaseDebugSymbols
> Task :transformNativeLibsWithSyncJniLibsForRelease
> Task :generateReleaseRFile
> Task :compileReleaseJavaWithJavac FAILED
17 actionable tasks: 17 executed
C:\src\flutters\.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecy
cle-1.0.6\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\Fl
utterLifecycleAdapter.java:8: error: package androidx.lifecycle does not exist
import androidx.lifecycle.Lifecycle;
^
C:\src\flutters\.pub-cache\hosted\pub.dartlang.org\flutter_plugin_android_lifecy
cle-1.0.6\android\src\main\java\io\flutter\embedding\engine\plugins\lifecycle\Fl
utterLifecycleAdapter.java:22: error: cannot find symbol
public static Lifecycle getActivityLifecycle(
^
symbol: class Lifecycle
location: class FlutterLifecycleAdapter
2 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
BUILD FAILED in 31s
The plugin flutter_plugin_android_lifecycle could not be built due to the issue
above.
in my pubspec.yaml file, I only installed 2 new packages in dependencies:
adhara_socket_io: ^0.4.1
google_maps_flutter: ^0.5.25+3
and here's my flutter doctor output
C:\src\flutter_projects\beresin>flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.7, on Microsoft Windows [Version
6.1.7601], locale en-US)
• Flutter version 1.12.13+hotfix.7 at C:\src\flutters
• Framework revision 9f5ff2306b (3 months ago), 2020-01-26 22:38:26 -0800
• Engine revision a67792536c
• Dart version 2.7.0
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\BERESIN\AppData\Local\Android\Sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-29, build-tools 28.0.3
• ANDROID_HOME = C:\Users\BERESIN\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b04)
[√] VS Code (version 1.44.1)
• VS Code at C:\Users\BERESIN\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.9.1
[√] Connected device (1 available)
• Mi A2 Lite • 04ab7a9f0405 • android-arm64 • Android 9 (API 28)
• No issues found!
any answer will be appreciated

So, after some hours... I noticed the adhara_socket_io package causes the problem, then I decided to find other library to handle socket.io connections and tried every single package on pub.dev. there's a package that similar named socket_io_flutter but looks more up-to-date. So I tried to build it but I got the same error.
then I found a question with similar error here Execution failed for task ':flutter_twitter:verifyReleaseResources'
I changed the package's build.gradle file compileSdkVersion to 28, and changed the gradle classpath to classpath 'com.android.tools.build:gradle:3.5.3'
and it works. I learned that every library aren't using the same version of build tool, some of that are left unmaintained.
Correct me if I wrong. If there's better explanation please post it here, so beginners like me can learn more about this.

Related

How do I build Ionic cordova for android?

I am new to Ionic and I want to emulate Ionic in an Android platform rather than to run it in a browser. But I am stuck with this error during "ionic cordova build android" using VS CODE.
Please find the following details:
> cordova.cmd requirements android
Requirements check results for android:
Java JDK: installed 18.0.1
Android SDK: installed true
Android target: installed android-33,android-30
Gradle: installed C:\Gradle\gradle-7.4.2\bin\gradle.BAT
Actual Error:
> Task :app:processDebugMainManifest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module #5cb1c671
* 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 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 7s
17 actionable tasks: 17 executed
Command failed with exit code 1: E:\Ionic\Projects\NirogalayaFoundation\platforms\android\gradlew cdvBuildDebug -b E:\Ionic\Projects\NirogalayaFoundation\platforms\android\build.gradle
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
Please help me out.

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

Gradle assemble failing due to "Could not determine the dependencies of task ':app:lintVitalRelease'. "

I tried to make my ionic project into a .apk, following the below steps
$ ionic start
$ ionic build
$ ionic capacitor add android
$ ionic sync
$ cd android && ./gradlew assembleRelease
extra info
------------------------------------------------------------
Gradle 4.4.1
------------------------------------------------------------
Build time: 2012-12-21 00:00:00 UTC
Revision: none
Groovy: 2.4.16
Ant: Apache Ant(TM) version 1.10.5 compiled on August 27 2018
JVM: 10 ("Oracle Corporation" 10+44)
OS: Linux 5.4.119-14943-gff839c7fedcc amd64
after which I got the following error, how do I fix this?
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
Could not resolve androidx.appcompat:appcompat:1.2.0.
Required by:
project :app
> Could not resolve androidx.appcompat:appcompat:1.2.0.
> Could not get resource 'https://dl.google.com/dl/android/maven2/androidx/appcompat/appcompat/1.2.0/appcompat-1.2.0.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/androidx/appcompat/appcompat/1.2.0/appcompat-1.2.0.pom'.
> The server may not support the client's requested TLS protocol versions: (TLSv1.2). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.0/userguide/build_environment.html#gradle_system_properties
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
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 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 18s

Trouble compiling android build on Mac(Android Studio)

Flutter Version: 4.1.3
Android Studio: 4.2.1
Gradle version: 3.5.0
There is an issue compiling the flutter app on android device. The app is working fine on any of the iOS device.
FAILURE: Build failed with an exception.
Launching lib/main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:3.5.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:3.5.0.
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.pom'.
> Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.0/gradle-3.5.0.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
* 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 9s
Exception: Gradle task assembleDebug failed with exit code 1
Already answered here Android Gradle Issue - Flutter / Dart
Oftenly it is just corrupted Build Gradle. You need to reinstall or replace it with ver that you already have

Error while building sample application viewer located under skia/platform_tools/android directory

Steps to reproduce the problem?
bin/gn gen out/arm64 --args='ndk="/home/anurag/Android/android-ndk-r19" ndk_api=27 target_os="android" target_cpu="arm64" is_component_build=true is_debug=false'
ninja -C out/arm64
Output of this step is
platform_tools/android/bin/android_build_app -C out/arm64 viewer
Expected output?
Upon completion of the script the APK can be found at out_dir/viewer.apk as per documentation mentioned on https://skia.org/user/sample/viewer
Actual Output
Instead, an error is printed on the console as:
$ platform_tools/android/bin/android_build_app -C out/arm64 viewer
> Configure project :viewer
WARNING: The specified Android SDK Build Tools version (22.0.1) is ignored, as it is below the minimum supported version (28.0.2) for Android Gradle Plugin 3.2.0.
Android SDK Build Tools 28.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '22.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
> Task :viewer:arm64Debug_BuildSkiaLib FAILED
ninja: Entering directory `/disk2/workspace/android-studio-office/skia/out/arm64'
ninja: error: unknown target 'libviewer'
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':viewer:arm64Debug_BuildSkiaLib'.
> Process 'command '/disk2/workspace/android-studio-office/depot_tools/ninja'' finished with non-zero exit value 1
* 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 1s
16 actionable tasks: 1 executed, 15 up-to-date
Command '['./apps/gradlew', ':viewer:assemblearm64debug', '-papps/viewer', '-Parm64.out.dir=/disk2/workspace/android-studio-office/skia/out/arm64', '--daemon']' returned non-zero exit status 1
gradle build failed
I am using product version 74 as per https://skia.googlesource.com/skia/+/master/include/core/SkMilestone.h
Operating system version: Ubuntu 17.10

Categories

Resources