安装构建应用程序输出 apk app.apk

当我跑步的时候:

$ flutter run

我的移动设备上出现了一个提示,询问我是否要在我的设备上安装这个应用程序。我答应了,然后什么都没发生!

卡在这里了:

Launching lib/main.dart on POCO F1 in debug mode...
Initializing gradle...                                           1.5s
Resolving dependencies...                                        9.2s
Gradle task 'assembleDebug'...                                  22.9s
Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk...                     14.9s

然后就没了。

86694 次浏览

I hit this problem when I commented all my bitmaps in launch_background.xml:

<!-- You can insert your own image assets here -->
<item>
<!--
<bitmap
android:gravity="center"
android:src="@mipmap/launch_320x480" />
<bitmap
android:gravity="center"
android:src="@mipmap/launch_480x320" />
<bitmap
android:gravity="center"
android:src="@mipmap/launch_480x800" />
<bitmap
android:gravity="center"
android:src="@mipmap/launch_800x480" />
<bitmap
android:gravity="center"
android:src="@mipmap/launch_720x1280" />
<bitmap
android:gravity="center"
android:src="@mipmap/launch_1280x720" />
<bitmap
android:gravity="center"
android:src="@mipmap/launch_1280x1920" />
<bitmap
android:gravity="center"
android:src="@mipmap/launch_1920x1280" />
-->
</item>

I uncommented the bitmaps to get the Flutter build to run. I'm on:

Flutter (Channel beta, v1.0.0, on Mac OS X 10.13.6 17G4015, locale en-US)

I solved this by manually installing the apk file generated in the builds folder. After that running flutter run runs the app on my phone.

For me, the error was due to my work android profile. I uninstalled the debug app in personal profile but it remained in the work profile, once I uninstalled it there and ran flutter run. It worked without any issues. So, First, ensure you deleted the App in both personal and work profile And then run

flutter run

Update:

By profiles I meant, android user profiles on your phone.

For anybody reading this, I solved this by doing the following:

  1. Open Android Studio->SDK Manager and install API 27 (By default Android Studio only installed the latest (API 28) as at the time of writing and there seem to be issues with using that right now).
  2. In cmd run flutter doctor --android-licenses and make sure you accept all the licenses.
  3. Open Android Studio->AVD Manager and create a new emulator using API 27
  4. Run your app on the new emulator and enjoy!

Hope this helps :).

I ran into this issue after changing my package name. Following the instructions on this post helped me: Flutter App is not working after changing package name

I had a problem with this when I uninstalled my app from a device, but unfortunately, I didn't uninstall it from all the users that are on my phone. Even Guest kept a version of my app in it, so I solve this issue with uninstalling all version of my app for all users. After that my app was installed without a problem. Sadly we don't get any error message that something is not right if this happens, so I hope this was a case for you guys and that I help you solve it! ;)

I removed debug application from Android menu, and then I ran into the same issue. I restarted my phone, but it wasn't very helpful. My solution was to remove the application completely and reinstall it by hand:

  1. Connect to the device with ADB

  2. Use adb uninstall com.example.application.name

  3. Use adb install C:\PathToYourProject\build\app\outputs\apk\app.apk

By the way, in such uneasy scenarios, flutter run --verbose could provide more detailed information what went wrong.

Running flutter clean solved this issue for me using an emulator.

I wiped the emulator data, deleted my emulator, and created a new one, none of that worked. flutter clean worked though.

Try this

  1. First Install App using flutter run from terminal
  2. When App is Installed. long press on app icon and go to app info.
  3. Force stop app.
  4. Remove cache and delete storage which is contained by app.
  5. Uninstall App.
  6. Install Again. it will work.

When I switched system image for the emulator from Q to Pie it solved it for me.

I got this issue when I uninstalled the flutter app from homescreen. I could not get it installed through android studio or through flutter install commands. What worked for me was to generate the release apk.

flutter build apk

And put the apk in the device and install it again manually through the device. After which there was no issues with installing through both android studio or flutter commands.

It is also happenning caused by flutter plugins that doesn't support android api 28.

In my case it caused by this plugin https://pub.dev/packages/connectivity

Installing build\app\outputs\apk\app.apk... is displayed in the Run tab and it doesn't give much information. Please have a look into the Logcat tab and here you can find detailed logs and you may find the reason why you are stuck. If Logcat tab is not visible, please refer this link: Android Studio not showing Logcat with Flutter

I also have this problem because I changed a file (my_project\android\app\src\main\java\com\example\my_project\MainActivity.java). and I solved it like this:

package com.example.my_project; //your project name should be changed here.


import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;


public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}

You can use:

flutter build apk --release


flutter install

If this problem persists in your physical device follow the below operation

Select the app from the apps list in settings (You could see a "not installed for this user" sub along side it)

then Top right menu button "uninstall for all users"

This happened for me because there was a typo in gradle.properties. I assume it had something to do with the refactor tool in Android Studio. Two settings ended up on the same line like this:

android.enableJetifier = trueandroid.enableR8=true

When I fixed it, it worked again.

I closed my emulator and android studio and then restarted it.

I had this problem after I changed the package name. I fixed it by using this guide

In my case I did not have the java files as described in the article but did need to change the kotlin path similarly to the java path described.

I solved this issue but I would like mention few things. 1. My Fresh Installation was stuck at Installing APK... 2. Same issue on Device as well as in Emulator

I realized that this issue is not device-specific for me. that's why I started looking for solutions.

Solution I tried 1. Flutter Upgrade ( Using Fresh Copy from Flutter.dev) Didn't Solve my Issue 2. Android SDK (Using Fresh Android SDK) Didn't Solve my Issue

Luckily, I found an article that explained you need to keep a few directories out from realtime scanning. I was using FREE-Antivirus

I just tried to Uninstall that and Re-started my machine.

Guess What? Issue Solved :)

copy the Apk from build\app\outputs\apk\app.apk to your phone.

find the apk on phone and install it manually.

flutter run on will now work as expected.

Background: While the app was being installed by Android Studio, I manually deleted the app from the device. Thereafter I discovered that the app would not install.

This problem was resolved by going to Settings > Apps and noting that the app was disabled rather than uninstalled even though I did confirm the uninstall request. In any case, I tapped the app and performed an uninstall from the Settings > Apps screen.

In my case problem was with installation of apk. Manual installation of apk works in my case

I fixed it:

1. Power off & Close Android Emulator
2. Reopen Android Studio & go to Tools/ AVD Manager
3. In Virtual Devices List, click Dropdown icon > select 'Wipe Data'. Then click 'Launch this AVD...'
4. Waiting for VD open, then click Run in Android Studio


good luck

Check if you have Guest User in your Device ... Go to that user uninstall the application from guest and then switch to your account and then try running it works.

Firstly i removed app with package name on command line. If you do not know package name you can check applicationId in app/build.gradle .

adb uninstall packagename

After then it works.

Very easy solution, just uninstall the app using below command even you did not found app on your device or emulator. This is because sometimes even you uninstall app from device from setting, that app still remains there for other users (Multi user feature in devices). So to completely remove the app from device, use below command and then try to install the app again (Restart the android studio to terminate process if it is already running)

adb uninstall <package.name>

e.g.

adb uninstall com.example.myfirstflutterapp

For me, it was a package: admob_flutter

I'd compiled and updated dependencies but used wrong the package. I realize it by looking at the Log in View -> Tool Windows -> Logcat (ALT+6) in Android Studio.

Before the app running in AVD was crashing, but I didn't know why, not seen an error in the Run Terminal, but the Logcat helped me.

Hope it helps someone.

I happened with me more than once, and every time I restart my mobile and this problem goes away, I used this solution when I tried all the solutions and fails

try this :

  • delete "build" package
  • apply "flutter run" command

enter image description here

I encountered the same problem when I created my first project. My solution would most probably work on a Xiaomi phone only. You should go to the developer options and then check the option "USB debugging(Security Settings)" under the Debugging menu and then your problem should be resolved.

This problem can be solved by increasing the log buffer size in your Mobile Device or AVD. This option will be available in the Developer Options Menu in the Settings of Your AVD or Mobile Device.

For me, this error occurs when I add the google firebase in my project, I tried all of the above solutions but not solved the problem, At the end, I could solve this problem by installing the latest version of the Android API virtual device and google play services.

Lots of answers here! The one that worked for me -

replace contents of your <app>/android/gradle.properties with the following -

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true

If you don't want to enable R8

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
#android.enableR8=true

On your real Android Device GO to SETTINGS> APPS & NOTIFICATION(you can search it!) > APP INFO > chose the app of the current project > PRESS THE 3 dots > Uninstall for all user.

In my case I disabled play protect on simulator and it worked.

If you are running in the emulator, try Wipe Data in AVD Manager

Physical Device : I had the same issue when I uninstalled the app from app drawer.

As already answered, one way to fix this is using ADB to cleanly remove it from your phone, but if you don't have ADB installed, try :

  1. Run flutter clean from the project root folder

  2. Switch to the guest profile on your phone (You must have multiple users enabled, if not enable it in Settings by searching for 'users')

  3. Delete the guest profile. (This can be done by swiping down the notification shade when you are in the guest profile --> clicking on the 'guest icon' next to the settings icon --> delete guest

  4. run main.dart

Should be fixed

Check your AndroidManifest.xml and check that the android:name was properly set with your package name. It worked for me while importing native code.

This worked for me
Step 1: Run flutter clean (this will delete your build directory)
Step 2: Run/Debug the application on Emulator/Physical Device

If you're using MI phone and have turned on second space, i needed to delete the second space (of course i had no data there) to successfully install the apk again. Found this solution here

I tried all the solutions above didn't work

I tried running the app from the main.dart file it worked for me

On the Android physical device:

  1. Unplug the USB cable.
  2. Uninstall the app (from both personal and work profiles) / uninstall for all users (some devices only have this option).
  3. Cleaned up (using an utility app) (optional).
  4. Searched manually by the app name and delete them on the file explorer.
  5. Restart.
  6. Verify developer options are unable correctly. (After enabling as a developer,) check following developer options are enabled:
    • Developer options.
    • USB debugging.
    • Install via USB.
    • USB debugging(Security settings).
    • Select USB configuration: MTP(Media Transfer Protocol).

On the IDE:

  1. Run flutter clean.
  2. Restart the IDE (optional).
  3. Plug the physical device and check the device is connected as debugging device.
  4. Run flutter pub get and make sure no errors (optional).
  5. Run in debug mode.

According to me this error is caused by some kind of memory leak or something else.So if you are using a physical device, Restarting the physical device and re-installing the app afterwards worked for me.

The simplest solution, COLD BOOT !! (must try before any complex processes)

In my case, I noticed the problem is with my emulator. Even without running any project, the emulator was stuck. Hence same error occurred when I tried to run other projects also. In case you are unable to do Cold boot for your AVD, follow below 2 steps and try again

  1. Stop running your project(main.dart) and
  2. delete the lock file at C:\Users\your_name.android\avd\Nexus_6P_API_30.avd\

I use ADB to debug the app and sometimes it gets stuck on installing. I tried reinstalling VS Code and Flutter but found out the issue was with ADB. So, whenever I face this issue I stop the ADB server by:

adb kill-server

and then connect to the device again and the issue is fixed.

Settings>>Accounts and sync>>delete work profile, it will work!!!!

I just faced this too and I found that the problem was I accidentally deleted kotlin/MainActivity. So I created a folder with package name, copied the MainActiviy from another project and put in it. This fixed my problem.

Answer enable Developer options?

  1. Enter Settings -> More settings -> About phone (Version);
  2. Click seven times on Software version;
  3. Developer options will appear in Settings -> More settings.

If you have changed the app's package name and if you think you did eveything right. Don't forget to change folder name under

\android\app\src\main\kotlin\com\

and also don't fotget to change package name inside MainActivity.kt

  1. open cmd in windows

  2. goto this location in cmd C:\Users\[user]\AppData\Local\Android\sdk\platform-tools

  3. type this command :- adb uninstall com.example.application.name(Package name)

  4. if u see command success

  5. then run flutter project again.

For me, I uninstalled the app from all android profiles but this did not work, even after restarting the phone and clearing all cache.

What work I changed the package name, here you can see how to change the package name https://stackoverflow.com/a/51550358/1901574

This was issue for me. On the device, open Settings > Apps > Find your app & select it > Click on ... at top right > Delete for all users. Once complete, run again and it should install

If it's still showing Installing build\app\outputs\apk\app.apk... in the console after this, go to the emulator and click your app icon, it should open.

In my case actually, I noticed that the app was installed on my device but not launched automatically. I manually opened the app and then ran it again then that time it was reflected.

For me, this is usually as simple as restarting the emulator using a Cold Boot.

First of all you need to check if any space shortage is happened in emulator / device.It may happens when you have shortage of space.

If everything is fine ,then do as follow:

flutter clean

This will clean deletes build-cache which is in the /build folder. Then run,

flutter pub get

For me this helped to resolve this issue.Hope it will help you too