I am trying to test drive an app. I keep getting a strange issue with this problem as app fail to debug/run. SDK version is 28 while the rest is below:
Flutter 1.13.9-pre.79 • channel master • https://github.com/flutter/flutter.git Framework • revision 9eb9ea0ffa (6 hours ago) • 2020-01-13 21:30:42 -0800 Engine • revision 0235a50843 Tools • Dart 2.8.0 (build 2.8.0-dev.0.0 28c335d5a2)
Gradle build failed to produce an .apk file. It's likely that this file was generated under C:\Development\\build, but the tool couldn't find it.
Is there a way to pass this issue or a configuration that can allow me to run by providing or giving the output path to Gradle? The .apk seems to generated as the error states.
UPDATE:
Android Studio -v 3.5.3 Gradle -v 3.4.2 Gradle Wrapper -v 5.1.1
The top-level build.gradle file, located in the root project directory, defines dependencies that apply to all modules in your project. By default, the top-level build file uses the plugins block to define the Gradle dependencies that are common to all modules in the project.
Both the top-level and module-level build. gradle files are the main script files for automating the tasks in an android project and are used by Gradle for generating the APK from the source files.
Gradle builds are used to define a project and its tasks. At least one Gradle build file is located in the root folder of the project. A task represents the work that a Gradle build has to perform, e.g., compiling the source code of the program. You can execute multiple tasks at a time under one build file.
The build system can run as an integrated tool from the Android Studio menu and independently from the command line. You can use the features of the build system to: Customize, configure, and extend the build process. Create multiple APKs for your app with different features using the same project and modules.
in my case I have a multi flavor app like this:
update 04/15/2021:
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "YOUR_PROJECT_NAME", "program": "lib/main.dart", "request": "launch", "type": "dart", "args": [ "--flavor", "ADD_YOUR_FLAVOR_NAME_HERE" //development or staging or production ] } ]
Another way:
android { ... buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } } flavorDimensions "flavor-type" productFlavors{ development{ dimension "flavor-type" } staging{ dimension "flavor-type" } production{ dimension "flavor-type" } } }
So if you want to run app you have to write the flavor name and then the class name that hold main() function
flutter run --flavor staging -t lib/main_staging.dart
and I solved my error and built the .apk
Added the flavor name in Build name
from Edit Configurations
and it worked!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With