Everyone. So I am trying to integrate Flutter module inside App(Android app).
So, I have followed this tutorial and everything worked correctly.
To build an aar file the command is
cd some/path/my_flutter
flutter build aar
As per my project requirement, I thought of creating different configuration to main.dart
file. Hence, I created main_dev_dog.dart
and main_dev_cat.dart
files.
The contents of this file is for Cat:
import 'package:flutter/material.dart';
import 'app_config.dart';
import 'my_app.dart';
void main() {
const configApp = AppConfig(
environment: Environment.DEV_CAT, appTitle: "Cat Dev", child: MyApp());
runApp(configApp);
}
For Dog:
import 'package:flutter/material.dart';
import 'app_config.dart';
import 'my_app.dart';
void main() {
const configApp = AppConfig(
environment: Environment.DEV_DOG, appTitle: "Dog Dev", child: MyApp());
runApp(configApp);
}
PS: I am not trying to create Flavors.
My intentions is to create aar files which will have different configuration. And I can use those libraries(aar) in Android Native app.
I am not sure if it is possible? But I know we can build different APK's using different main.dart
files.
For example:
flutter build apk -t lib/main_dev_dog.dart
or
flutter build apk -t lib/main_dev_cat.dart
So, I tried following command to create different AAR:
flutter build aar lib/main_dev_cat.dart
But it is not building and I am getting following error.
Could not transfer artifact com.akshay.first.my_flutter_module:flutter_debug:aar:1.0 from/to remote (file://./build/host/outputs/repo): Repository path /build/host/outputs/repo does not exist, and cannot be created.
Could not transfer artifact com.akshay.first.my_flutter_module:flutter_debug:pom:1.0 from/to remote (file://./build/host/outputs/repo): Specified destination directory cannot be created: /build/host/outputs/repo/com/akshay/first/my_flutter_module/flutter_debug/1.0
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter:uploadArchives'.
> Could not publish configuration 'archives'
> Failed to deploy artifacts: Could not transfer artifact com.akshay.first.my_flutter_module:flutter_debug:aar:1.0 from/to remote (file://./build/host/outputs/repo): Repository path /build/host/outputs/repo does not exist, and cannot be created.
* 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 2s
Please help.