I am new. I am building my first app but there is a difficult error.
I created an animation and want to use it like a button. Tap on it and the animation starts.
I try to use rive but can not run the app when importing rive.dart
this is my code:
import 'dart:ffi';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:rive/rive.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({Key? key}) : super(key: key);
#override
State createState() => _Home();
}
class _Home extends State {
String bamboo_tube_animation = 'assets/animations/OngQue.svg';
#override
Widget build(BuildContext context) {
double device_width = MediaQuery.of(context).size.width;
double device_height = MediaQuery.of(context).size.height;
double bamboo_button_size = device_width * 0.9;
double icon_size = 60;
return Container(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: [
RiveAnimation.asset(bamboo_tube_animation);
Container(
height: 20,
),
],
),
);
}
}
I add rive to pubspec.yaml
dependencies:
flutter:
sdk: flutter
flutter_svg: ^1.1.6
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
flare_flutter: ^3.0.2
rive: ^0.10.1
And this is debug console:
Launching lib/main.dart on iPhone 13 Pro Max in debug mode...
Xcode build done. 6.7s
Failed to build iOS app
Error output from Xcode build:
↳
2023-01-26 21:51:46.183 xcodebuild[26922:202491] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2023-01-26 21:51:46.184 xcodebuild[26922:202491] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
BUILD FAILED
Xcode's output:
↳
Writing result bundle at path:
/var/folders/3w/nscscyx1109ckdn_r__40g7m0000gn/T/flutter_tools.XO1RoC/flutter_ios_build_temp_dirvZKZ6S/temporary_xcresult_bundle
: Error: Type 'Uint8List' not found.
Future<void> decode(Uint8List bytes) {
^^^^^^^^^
: Error: 'Uint8List' isn't a type.
Future<void> decode(Uint8List bytes) {
^^^^^^^^^
Failed to package /Users/manh.do/Documents/flutter_example/angicungduoc/angicungduoc.
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in dependency order
Result bundle written to path:
/var/folders/3w/nscscyx1109ckdn_r__40g7m0000gn/T/flutter_tools.XO1RoC/flutter_ios_build_temp_dirvZKZ6S/temporary_xcresult_bundle
Could not build the application for the simulator.
Error launching application on iPhone 13 Pro Max.
Exited
Any idea?
I just start my app, but it's hard to resolve this error
Related
I'm trying to run flutter app, before adding major features I tried to test the app after removing the counter and adding AppBar but it shows this error in the console:
Launching lib\main.dart on INE LX2 in debug mode...
Running Gradle task 'assembleDebug'...
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.zip.ZipFile.<init>(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:214)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:74)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Running Gradle task 'assembleDebug'...
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
Exception in thread "main" java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.zip.ZipFile.<init>(ZipFile.java:169)
at org.gradle.wrapper.Install.unzip(Install.java:214)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:74)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
Exception: Gradle task assembleDebug failed with exit code 1
I removed the gradle folder from my_project > android directory and tried to run again but same error appeared again
here is my code that I'm trying to run:
import 'package:flutter/material.dart';
import 'MainContent.dart';
void main() =>runApp(FFI());
class FFI extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark(),
debugShowCheckedModeBanner: true,
home: Scaffold(
body: Center(
child: MainContent(),
),
),
);
}
}
and here is the MainContent() class in different dart file :
class MainContent extends StatefulWidget {
#override
_MainContentState createState() => _MainContentState();
}
class _MainContentState extends State<MainContent> {
#override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: BottomNavigationBar(
items: const<BottomNavigationBarItem>[
BottomNavigationBarItem(
label: "one",
icon: Icon(Icons.qr_code_scanner_rounded,)),
BottomNavigationBarItem(
label: "two",
icon: Icon(Icons.home)),
BottomNavigationBarItem(
label: "three",
icon: Icon(Icons.home)),
],
),
);
}
}
Please help, thank you
EDIT:
I tried to run previous flutter projects and faced the same error although it used to work fine
This error usually happens on Android builds when you try to run an old Flutter project that you haven't touched for a while. What you can do here is update all the plugins that you're using and rebuild the Android build.
Run flutter pub upgrade to upgrade the plugins in the project. Then try running the project. If the issue persists, run flutter doctor to check for any errors.
If you'd like to regenerate the entire Android build, you can delete the /android folder, then run flutter create --platforms=android [PROJECT_PATH] - this should generate the Android project from the Flutter code.
When I try to let my flutter app show a picture(it's asset image),it throws the exception :
"Exception: Gradle task assembly debug failed with exit code 1".
What should I do in such a case ?
import 'package:flutter/material.dart';
void main()
{
runApp(Center(
child: Image(
image:AssetImage('images/mont.jpg'),
)
));
}
the pubspec.yaml file is :
flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- images/mont.jpg
- images/a_dot_ham.jpg
everything was working fine until last build, where it displays the following error:
[INFO] Running build...
[SEVERE] floor_generator:floor_generator on lib/db/app_database.dart:
There are no type converts defined even though the #TypeConverters annotation is used.
package:apoce/db/app_database.dart:24:16
╷
24 │ abstract class AppDatabase extends FloorDatabase {
│ ^^^^^^^^^^^
╵
[INFO] Running build completed, took 1.3s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 53ms
I'm not sure why it's showing this error, I googled for a while but it appears no one has got same at first glance.
My database class is:
import 'dart:async';
import 'package:apoce/db/FormFieldsDao.dart';
import 'package:apoce/db/FormsDao.dart';
import 'package:apoce/db/HashDao.dart';
import 'package:apoce/db_converters/list_choices.converter.dart';
import 'package:apoce/db_converters/list_fieldsets.converter.dart';
import 'package:apoce/db_converters/list_questions.converter.dart';
import 'package:apoce/db_converters/list_string.converter.dart';
import 'package:apoce/models/FormFields.dart';
import 'package:apoce/models/Forms.dart';
import 'package:apoce/models/Question.dart';
import 'package:apoce/models/choice.dart';
import 'package:apoce/models/hash.dart';
import 'package:floor/floor.dart';
import 'package:sqflite/sqflite.dart' as sqflite;
part 'app_database.g.dart'; // the generated code will be there
#TypeConverters([
StringListConverter,
FiledSetsListConverter,
QuestionsListConverter,
ChoicesListConverter,
])
#Database(version: 5, entities: [Forms, FormFields, Hashes, Question, Choice])
abstract class AppDatabase extends FloorDatabase {
//static Future<AppDatabase> openDatabase() async => _$open();
FormsDao get formsDao;
FormFieldsDao get formFieldsDao;
HashDao get hashDao;
}
My pubspec.yaml
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
floor: ^0.17.0
dio: ^3.0.10
freezed: ^0.12.2
flutter_bloc: ^6.1.1
dependency_overrides:
analyzer: '0.40.4'
Thank you.
https://flutter.dev/docs/cookbook/testing/unit/introduction
I am trying to run the unit test sample on the above page as is,
When I run it, I get an error.
flu_basic/
lib/
main.dart
test/
counter_test.dart
//main.dart
class Counter {
int value = 0;
void increment() => value++;
void decrement() => value--;
}
//counter_test.dart
import 'package:test/test.dart';
import 'package:flu_basic/main.dart';
void main() {
group('Counter🐭', () {
test('value should start at 0', () {
expect(Counter().value, 0);
});
test('value should be incremented♉️', () {
final counter = Counter();
counter.increment();
expect(counter.value, 1);
});
test('value should be decremented🐯', () {
final counter = Counter();
counter.decrement();
expect(counter.value, -1);
});
});
}
//part of dev_dependencies of pubspec.yaml file
dev_dependencies:
test: ^1.15.3
When I run the following in terminal
flutter test test/counter_test.dart
Running "flutter pub get" in flu_basic... 0.6s
00:00 +0: loading /Users/userno1/dev2/flu_basic/test/counter_test.dart
Error: cannot run without a dependency on "package:flutter_test". Ensure the following lines are present in your
pubspec.yaml:
dev_dependencies:
flutter_test:
sdk: flutter
00:00 +0 -1: loading /Users/userno1/dev2/flu_basic/test/counter_test.dart [E]
Failed to load "/Users/userno1/dev2/flu_basic/test/counter_test.dart":
Compilation failed
Test: /Users/userno1/dev2/flu_basic/test/counter_test.dart
Shell: /Users/userno1/dev2/flutter/bin/cache/artifacts/engine/darwin-x64/flutter_tester
00:00 +0 -1: Some tests failed.
I get the above error.
part of dev_dependencies of pubspec.yaml file like below↓
dev_dependencies:
#test: ^1.15.3 ←comment out
flutter_test:
sdk: flutter
00:00 +0: loading /Users/userno1/dev2/flu_basic/test/counter_test.dart Error: Could not resolve the package 'test' in 'package:test/test.dart'.
test/counter_test.dart:4:8: Error: Not found: 'package:test/test.dart'
import 'package:test/test.dart';
^
00:02 +0: loading /Users/userno1/dev2/flu_basic/test/counter_test.dart test/counter_test.dart:10:7: Error: Method not found: 'expect'.
expect(Counter().value, 0);
^^^^^^
test/counter_test.dart:9:5: Error: Method not found: 'test'.
test('value should start at 0', () {
^^^^
test/counter_test.dart:18:7: Error: Method not found: 'expect'.
expect(counter.value, 1);
^^^^^^
test/counter_test.dart:13:5: Error: Method not found: 'test'.
test('value should be incremented♉️', () {
^^^^
test/counter_test.dart:26:7: Error: Method not found: 'expect'.
expect(counter.value, -1);
^^^^^^
test/counter_test.dart:21:5: Error: Method not found: 'test'.
test('value should be decremented🐯', () {
^^^^
test/counter_test.dart:8:3: Error: Method not found: 'group'.
group('Counter🐭', () {
^^^^^
00:06 +0 -1: loading /Users/userno1/dev2/flu_basic/test/counter_test.dart [E]
Failed to load "/Users/userno1/dev2/flu_basic/test/counter_test.dart":
Compilation failed
Test: /Users/userno1/dev2/flu_basic/test/counter_test.dart
Shell: /Users/userno1/dev2/flutter/bin/cache/artifacts/engine/darwin-x64/flutter_tester
00:06 +0 -1: Some tests failed.
I get the above error.
Maybe on the page above
1.Add the test dependency
I think it's a problem with the part, but I don't know what to do.
What's wrong?
You should only use the test package If you’re working on a Dart package that does not depend on Flutter. From the look of it, your project requires flutter so rather than the dev dependencies you're using at the moment, you should use the following
dev_dependencies:
flutter_test:
sdk: flutter
and import the flutter_test package
import 'package:flutter_test/flutter_test.dart';
I got this flutter_SVG package
updated pubspec.yaml as below
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
flutter_svg: ^0.17.4
clicked the pub get button and done properly
I confirmed that my SVG file is properly put in under assets in the pubspec.yaml
then in Home.dart where I want, I imported the package normally, and below is the code where the svg should work as per package readme instructions
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
class HomeState extends State<Home> {
TextEditingController _foo = new TextEditingController();
Widget build(BuildContext context) {
const pyramidsYellowIcon = 'my_assets/icons/pyramids_yellow.svg';
const followIconOffIcon = 'my_assets/icons/follow_icon_off.svg';
return Stack(
children: <Widget>[
Container(
child: SvgPicture.asset(followIconOffIcon, semanticsLabel: 'follow',),
),
],
),
}
}
then a hot reload error shows DevFS synchronization failed
and below logcat shows
2020-07-02 12:43:21.375 3019-3019/? E/GmsClientSupervisor: Timeout waiting for ServiceConnection callback com.google.android.gms.clearcut.service.START
java.lang.Exception
at tlk.handleMessage(PG:6)
at android.os.Handler.dispatchMessage(Handler.java:98)
at tzg.a(PG:5)
at tzg.dispatchMessage(PG:4)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
any, of course, the emulator refuses to reload, when I delete all changes mentioned above, everything is fixed and normal
After you add a package or an asset the hot reload doesn't work. You have to restart the app.
In my case I got error message "Hot Restart Error DevFS synchronization failed".
I had to stop an application in Android Studio (Run > Stop) and then run again (Run > Run...). Also there was an error in code that I fixed.