Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio gets error on fresh flutter app

When I try to run my flutter app from inside android studio I get the following output:

/home/jgilmore/src/dart-sdk/bin/dart --enable-asserts --enable-vm-service:34139 /home/jgilmore/src/fht_tool/lib/main.dart
Observatory listening on http://127.0.0.1:34139/

lib/main.dart:1: Warning: Interpreting this as package URI, 'package:fht_tool/main.dart'.
file:///home/jgilmore/src/flutter/packages/flutter/lib/src/material/animated_icons.dart:9:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show Paint, Path, Canvas;
       ^
file:///home/jgilmore/src/flutter/packages/flutter/lib/src/material/animated_icons.dart:10:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///home/jgilmore/src/flutter/packages/flutter/lib/src/material/arc.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///home/jgilmore/src/flutter/packages/flutter/lib/src/material/colors.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' show Color;
       ^
file:///home/jgilmore/src/flutter/packages/flutter/lib/src/material/dialog.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui';
       ^
file:///home/jgilmore/src/flutter/packages/flutter/lib/src/material/input_border.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///home/jgilmore/src/flutter/packages/flutter/lib/src/material/input_decorator.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///home/jgilmore/src/flutter/packages/flutter/lib/src/material/mergeable_material.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^
file:///home/jgilmore/src/flutter/packages/flutter/lib/src/material/shadows.dart:5:8: Error: Not found: 'dart:ui'
import 'dart:ui' show Color, Offset;
       ^
file:///home/jgilmore/src/flutter/packages/flutter/lib/src/material/slider_theme.dart:6:8: Error: Not found: 'dart:ui'
import 'dart:ui' show Path;
       ^

Process finished with exit code 254

Ok, so that doesn't work. But if I run "flutter run" from the command line, the app loads.

Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...                                       0.9s
Resolving dependencies...                                    8.9s
Gradle task 'assembleDebug'...                                   
Gradle task 'assembleDebug'... Done                         22.4s
Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk...                  0.2s
Error: ADB exited with exit code 255
[  0%] /data/local/tmp/app.apk
[...snip...]
[ 66%] /data/local/tmp/app.apk
adb: error: failed to copy '/home/jgilmore/src/fht_tool/build/app/outputs/apk/app.apk' to '/data/local/tmp/app.apk': remote No space left on device
/home/jgilmore/src/fht_tool/build/app/outputs/apk/app.apk: 0 files pushed. 110.9 MB/s (17561504 bytes in 0.151s)
Uninstalling old version..

I'm thinking the error complaining about "remote: no space left on device" may have something to do with it. I've certainly had no luck searching for the errors that android studio is throwing when it tries to build. But as far as I can tell, neither my computer's root drive, nor the android device, are out of space? And if that's the case, WHY DOES IT STILL WORK? And how do I get it to work inside android studio?

Since I've gone through all the trouble of installing the monstrosity that is android studio, I'd like it if it actually RAN.

Please note that this is a brand-new project. I've deleted comments, but not actually changed any of the dart code yet. Maybe I generated it wrong?

Edit: I fail to see how a compile-time error could be caused by the particular runtime environment, but it's a crazy world we live in. So I wiped and reset my emulated device anyway. Same error. Just for giggles, I shut it off, plugged in my physical phone, and tried to compile it for my phone. Same thing again.

like image 576
John Gilmore Avatar asked Dec 13 '18 22:12

John Gilmore


2 Answers

You've probably run the dart file with the dart icon instead of the Flutter icon.

The one on the bottom

You can access this menu from the Run dropdown menu in android studio's toolbar.

like image 148
Mr. N Avatar answered Oct 14 '22 07:10

Mr. N


Another way to solve this is to go to Edit Configuration in the Run tab, then add a new entry the ( + ) plus sign to add a new configuration, then tap flutter and select path to the package you're using in this case main.dart. Save and run this main.dart that you created.

like image 43
Edi Avatar answered Oct 14 '22 09:10

Edi