Flutter app run stuck white screen on device - flutter

i've developed a an app on flutter, despite it worked 2 days ago, when i run the app on the device the application it does not start. It remains on the white screen and do not launch the app. I think that something happened when i synchronized the gradle.
My main.dart:
import 'package:my_firstapp/locator.dart';
import 'package:my_firstapp/models/user_model.dart';
import 'package:my_firstapp/screens/wrapper.dart';
import 'package:provider/provider.dart';
import 'package:my_firstapp/services/auth.dart';
import 'package:firebase_core/firebase_core.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
setupServices();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return StreamProvider<UserModel>.value(
value: AuthService().user,
child: MaterialApp(
theme: ThemeData(
primaryColor: Color(0xff5FA55A),
accentColor: Color(0xff5FA55A),
),
home: Wrapper(),
),
);
}
}
My manifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.my_firstapp">
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:allowBackup="true"
android:label="food_track"
android:icon="#drawable/launch_background">
<activity
android:name="com.example.my_firstapp.MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.aptreesoftware.barcodescan.BarcodeScannerActivity"/>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
I checked that everything is upgraded and it is. Do you have any ideas?

Open the terminal, cd to android folder of your flutter project and run:
$./gradlew build

Related

AndroidManifest.xml attribute is not allowed

I am trying to migrate the old flutter project but after following all the steps given in documentation I am getting several error in androidManifest.xml.
error that I am getting are
Attribute android:icon is not allowed here,
Unresolved class 'MainActivity',
Attribute android:launchMode is not allowed here,
Attribute android:theme is not allowed here,
Attribute android:configChanges is not allowed here,
Attribute android:hardwareAccelerated is not allowed here,
Attribute android:windowSoftInputMode is not allowed here,
<application
android:label="bitcoin_ticker"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in #style/LaunchTheme). -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>

requires your app to be migrated to the Android embedding v2. ......how to solve this problem? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
it keeps says me that
requires your app to be migrated to the Android embedding v2. Follow the steps on
https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
Note....its the same as following this steps
https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
but i made it easier for any one that cant follow the steps .....hope that helped.
After trying multiple ways to deal with the situation,
I ended up with a good enough solution
just open this files in your project and copy >> paste this lines of code and it will work .......make sure to delete all lines of code in your this files and replace it to this new ones.
1: MainActivity.java
package co.appbrewery.flash_chat;
import io.flutter.embedding.android.FlutterActivity;
public class MainActivity extends FlutterActivity {
}
2: styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="#android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">#drawable/launch_background</item>
</style>
</resources>
3: AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="co.appbrewery.flash_chat">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application android:label="flash_chat" android:icon="#mipmap/ic_launcher">
<activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="#style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in #style/LaunchTheme). -->
<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="#drawable/launch_background" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data android:name="flutterEmbedding" android:value="2" />
</application>
</manifest>
Follow the steps. Hopefully, your problem will be solved. https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

Image is not saving in android gallery. whereas It is work properly on emultor

i'm making qr code maker/scanner app where, i am using image_gallery_saver package. when i make qr and download qr, in emulator it is working properly but when i make apk file and install in android phone it is not downloading. anyone has any idea. below is my manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gamelien.qr_app">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:requestLegacyExternalStorage="true"
android:label="qr_app"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
and below is my image_gallery_saver method which is called on button press
void qrSaveToGallery() async {
final result =
await ImageGallerySaver.saveImage(_imageFile); // Save image to gallery
}

I am getting so many errors in AndroidManifest.xml. How can I solve them?

Following is my code:
the errors I'm getting are:
Unresolved class 'FlutterApplication'
Attribute android:icon is not allowed here
Unresolved class 'MainActivity'
Attribute android:launchMode is not allowed here
Attribute android:theme is not allowed here
Attribute android:configChanges is not allowed here
Attribute android:hardwareAccelerated is not allowed here
Attribute android:windowSoftInputMode is not allowed here
<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="BMI Calculator"
android:icon="#mipmap/bmi_calculator">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in #style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

Android cannot set screenOrientation,

I have read through every post I could find on this and other sites and followed the advice, but in the most simple implementation I cannot get the Note 5 to set to Portrait mode when it is physically in Landscape orientation.
I added the lines as recommended to the manifest file, rebuilt and the app starts in Landscape mode.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.twistlogic.miwidget">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I also tried doing this with code, which is my main purpose:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
nothing is produced that works.
I am trying to learn Android so I understand this may well be due to my limited knowledge. What I am trying to do is fix the orientation and lock it there, then allow it to change only when the user pushes a button. I did read that the screen size had to be set after API 13. But I am not certain how to do so. I am using a fragment template screen from the basic activities when the project was created.
Thanks for any help.
This can be set in the Main Activity I have not tried to set it in the Manifest here is a single line of code and a few lines to write a test Ok here is the Manifest code at the end
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
int orientation = getResources().getConfiguration().orientation;
if(orientation == Configuration.ORIENTATION_PORTRAIT){
}else if(orientation == Configuration.ORIENTATION_LANDSCAPE){}
In your manifest file after your main activity Paste below line.
android:screenOrientation="portrait"
I have not tested this code in a Manifest file