I'm new to flutter and I'm using Android Studio to create app so I created a BMI calculator for training and when I try to build apk but it shows me this:
C:\Users\welcome\AndroidStudioProjects\bmicalculator>flutter build apk
Running "flutter pub get" in bmicalculator... 1.6s
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'...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileReleaseKotlin'.
> Failed to find Build Tools revision 28.0.3
* 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
My main.dart file
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
theme: ThemeData(
primaryColor: Color(0xFF4d88ff)
),
home: MyApp(),
debugShowCheckedModeBanner: false,
)
);
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
double _height=170.0;
double _weight=300;
int _bmi=0;
String _condition= 'Select Data';
@override
Widget build(BuildContext context) {
Size size=MediaQuery.of(context).size;
return Scaffold(
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Container(height: size.height*0.40,
width: double.infinity,
decoration: new BoxDecoration(color: Color(0xFF4d88ff)),
padding: EdgeInsets.symmetric(vertical: 30.0,horizontal: 10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("BMI",style: TextStyle(color: Colors.pinkAccent,fontWeight: FontWeight.bold,fontSize: 60.0),),
Text("Calculator(BETA)",style: TextStyle(color: Colors.pink,fontSize: 40.0),),
SizedBox(
width: double.infinity,
child: Container(
child:Text("$_bmi",
style:TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
fontSize: 45.0
),textAlign: TextAlign.right,),
),
),
RichText(
text: TextSpan(
text: "Condition:",
style: TextStyle(
color: Colors.pink,
fontSize: 25.0
),
children: <TextSpan>[
TextSpan(
text: "$_condition",
style: TextStyle(
color: Colors.pink,
fontSize: 25.0,
fontWeight: FontWeight.bold,
),)
]
),
)
],
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 10.0,vertical: 10.0),
width: double.infinity,
child: Column(
children: <Widget>[
SizedBox(height: size.height*0.03,),
Text("Enter Data",style: TextStyle(color: Colors.pink, fontSize: 30.0, fontWeight: FontWeight.bold,),),
SizedBox(height: size.height*0.03,),
RichText(
text: TextSpan(
text: "Height :",
style: TextStyle(
color: Color(0xFF403f3d),
fontSize: 25.0
),
children: <TextSpan>[
TextSpan(
text: "$_height cm",
style: TextStyle(
color: Color(0xFF403f3d),
fontSize: 25.0,
fontWeight: FontWeight.bold,
),)
]
),
),
SizedBox(height: size.height*0.03,),
Slider(
value: _height,
min: 0,
max: 250,
onChanged: (height){
setState(() {
_height=height;
});
},
divisions: 250,
label: "$_height",
activeColor: Colors.pink,
inactiveColor: Colors.grey,
),
SizedBox(height: size.height*0.03,),
RichText(
text: TextSpan(
text: "Weight :",
style: TextStyle(
color: Color(0xFF403f3d),
fontSize: 25.0
),
children: <TextSpan>[
TextSpan(
text: "$_weight kg",
style: TextStyle(
color: Color(0xFF403f3d),
fontSize: 25.0,
fontWeight: FontWeight.bold,
),)
]
),
),
SizedBox(height: size.height*0.03,),
Slider(
value: _weight,
min: 0,
max: 300,
onChanged: (_weight){
setState(() {
_weight=_weight;
});
},
divisions: 300,
label: "$_weight",
activeColor: Colors.pink,
inactiveColor: Colors.grey,
),
SizedBox(height: size.height*0.03,),
Container(
width: size.width*0.8,
child: ClipRRect(
borderRadius: BorderRadius.circular(30.0),
child: FlatButton(
onPressed: (){
setState(() {
_bmi=(_weight/((-_height/100)*(_height/100))).round().toInt();
if(_bmi>=18.5 && _bmi<=25) {_condition=" Normal";}
else if(_bmi>25 && _bmi<=30) {_condition=" Overweight";}
else if(_bmi>30) {_condition=" Obesity";}
else {_condition=" Underweight";}
});
},
child: Text("Calculate",style: TextStyle(color: Colors.white,fontSize: 20.0),),
color:Colors.pink,
padding: EdgeInsets.symmetric(vertical: 15,horizontal: 40),
),
),
)
],
),
)
],
),
),
);
}
}