Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – Why am i getting the default flutter example code every time i run my new flutter code on my phone?

Posted on November 11, 2022 By

Solution 1 :

I’m also facing the same issue. But I found what went wrong.

  • Problem:

I didn’t save the code after making changes in default example.

  • Solution:

Press CTRL+s to save each time any change is made in code.

  • Preferred solution:

Go to menu in Visual Studio Code, File -> Click ‘Auto save’. So that you don’t have to save changes each time, it will be auto-saved.

Solution 2 :

I tried many things and found out that if I run flutter clean on the terminal before going into debugging it solves the problem!

Problem :

I am using my android phone to run my flutter code. The problem is when i run any code(i.e. different from the auto generated flutter code that is created when i create a flutter project)it always shows me the output of the auto generated flutter code. I have to reload it after each run to get the output of my new code. Plus, after i detached my phone from my PC the app i get on my phone is still the auto generated one. I have used both android studio and VS code but the problem still persists. I have tried to create new project but still no luck.

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';


void main() => runApp(new MaterialApp(home: new KeyetWedetApp ())); //The runApp() function takes the given Widget and makes it the root of the widget tree.

class KeyetWedetApp extends StatefulWidget {
  @override
  _State createState() => new _State();
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.red,
      ),
      home: new KeyetWedetApp(),
      darkTheme: new ThemeData(accentColor: Colors.deepPurpleAccent),
    );
  }
}

class _State extends State<KeyetWedetApp> {
  static List _pageSelectorList = <Widget>[
    Image.asset('assets/images/balloon.jpeg'),
    Image.asset('assets/images/beach.jpeg'),
    Image.asset('assets/images/camp.jpeg'),
    Image.asset('assets/images/hello.png'),
    Image.asset('assets/images/mountain.jpeg')
    //TODO Insert our own images which describe what our application will do step by step.
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: new Container(
          child: new DefaultTabController(
            length: _pageSelectorList.length,
            child: Builder(
              builder: (BuildContext context) => Padding(
                padding: EdgeInsets.fromLTRB(10.0, 30.0, 10.0, 10.0),
                child: new Column(
                  children: <Widget>[
                    new TabPageSelector(selectedColor: Colors.blue),
                    new Expanded(
                        child: IconTheme(
                      data: IconThemeData(
                        size: 200.0,
                        color: Theme.of(context).accentColor,
                      ),
                      child: TabBarView(
                        children: _pageSelectorList,
                      ),
                    )),
                    new FlatButton(
                      onPressed: () {
                        Navigator.push(
                            context,
                            MaterialPageRoute(
                                builder: (context) => HomePage()));
                      },
                      child: new Text(
                        'Let's Get Started',
                        style: new TextStyle(fontSize: 20, color: Color(0xFF757575)),
                      ),
                    )
                  ],
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

When i run the this code, it compile and run normally without error or exceptions. It goes like this:

  • Launching libmain.dart on SM G950F in debug mode…
  • √ Built buildappoutputsapkdebugapp-debug.apk.
  • D/FlutterActivity( 9631): Using the launch theme as normal theme.
    D/FlutterActivityAndFragmentDelegate( 9631): Setting up FlutterEngine.
    D/FlutterActivityAndFragmentDelegate( 9631): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
    D/FlutterActivityAndFragmentDelegate( 9631): Attaching FlutterEngine to the Activity that owns this Fragment.
    D/FlutterView( 9631): Attaching to a FlutterEngine: [email protected]
    D/FlutterActivityAndFragmentDelegate( 9631): Executing Dart entrypoint: main, and sending initial route: /
    D/[email protected]: MSG_RESIZED_REPORT: frame=Rect(0, 0 – 1080, 2220) ci=Rect(0, 63 – 0, 0) vi=Rect(0, 63 – 0, 0) or=1
    D/InputTransport( 9631): Input channel constructed: fd=99
    D/InputMethodManager( 9631): prepareNavigationBarInfo() [email protected][MainActivity]
    D/InputMethodManager( 9631): getNavigationBarColor() -855310
    V/InputMethodManager( 9631): Starting input: tba=com.keyetwedet.keyet_wedet ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
    D/InputMethodManager( 9631): startInputInner – Id : 0
    E/AccessibilityBridge( 9631): VirtualView node must not be the root node.
READ  [FIXED] java.lang.IllegalArgumentException: Failed to find storage device at null Android
Powered by Inline Related Posts

And when it finally launches the code on my phone, no matter what code i wrote, it always show the flutter sample code output like this:

This is what i always get on the first run

So, in order to get my phone showing my code i have to “hot restart” it. Only then i will get the output of my code.

This is my code’s output which comes after i hot restarted it

But after i stopped the debugging and detached my phone from my PC, the app i get on my phone is still the output of the flutter sample code.

In summary my questions are the following:

  1. Why isn’t it showing my code’s output on the first run.
  2. Why isn’t it saving my code on my device so that when i open the app on my phone it could show me the output of my code.

Comments

Comment posted by Abdelbaki Boukerche

Can you post your

Comment posted by Simon Hutton

… and also maybe post the output from your run console. Are you getting messages saying “Launching… on…”, “Built…”, “Installing…” etc? did your code actually compile, or is your phone just rerunning the previously installed code (i.e. the default example app).

Comment posted by Harsh Mehta

Try this: – When you are able to run your code on the app, do not terminate your process or the app in your device. While your app is running, detach your phone without terminating the process. See if the app is still running your desired code. – If the app runs the desired code, then try terminating the app and then start it again and let me know if it shows the default starter app for flutter

READ  [FIXED] android - Firestore data retrieval of non-existing documents
Powered by Inline Related Posts

Comment posted by abene42

@Harsh_Mehta I tried it but is still shows the default starter app 🙁

Android Tags:android, flutter

Post navigation

Previous Post: [FIXED] android – Convert BMP image to PNG or JPG in Java without loading the entire image in memory
Next Post: [FIXED] xml – Android – prevent TextView to push out another element inside LinearLayout

Related Posts

[FIXED] java – How to compress downloaded images and decompress when needed in Android? Android
[FIXED] android – AlarmManager working on its own but not in JobSchedule Android
[FIXED] android – Populate RecyclerView from Firestore async call Android
[FIXED] android – How to get RecyclerView item count? Android
[FIXED] smsmanager – Unable to send SMS to a saved number in android studio Android
[FIXED] android – Draw arrow head in canvas using Angle Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is a good substitute for condensed milk?
  • ¿Como el cuerpo te avisa cuando te va a dar un infarto?
  • What is the luxury brand of Jaguar?
  • Who is Big poppa baseball player?
  • What material are foam runners?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme