Troubleshoot
Một số vấn đề phát sinh trong quá trình xây dựng, quản lý một project flutter
A. Flutter/ Dart/ Git
1. gitignore không hoạt động?
Nguyên nhân là do các file được lưu cache. Khắc phục bằng cách xoá cache git và set lại.
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
2. Cập nhật lại pub cache.
Việc xoá file pubspec.lock kèm với lệnh flutter clean
có thể vẫn ko xoá sạch cache của pub. Chạy câu lệnh dưới để update cache cho pub.
flutter pub cache repair
3. Update version package.
flutter pub upgrade --major-versions
4. Git ko track được thay đổi mà báo đổi nguyên file
git config --global core.autocrlf true
5. Precache SVG
Future.wait([
precachePicture(
ExactAssetPicture(SvgPicture.svgStringDecoder, 'assets/my_icon.svg'),
null,
),
precachePicture(
ExactAssetPicture(SvgPicture.svgStringDecoder, 'assets/my_asset.svg'),
null,
),
// other SVGs or images here
]);
6. Lỗi Project cũ run trên M1
Khi chạy project cũ trên macbook M1 sẽ gặp lỗi khi pod install. Làm theo lệnh dưới để fix
#1 Install ffi
sudo arch -x86_64 gem install ffi
#2 Re-install dependencies
arch -x86_64 pod install
#3 Update (if need)
arch -x86_64 pod install --repo-update
B. IOS
1. Building for iOS, but the linked and embedded framework 'App.framework' was built for iOS Simulator
rm -rf ios/Flutter/App.framework
2. Lỗi cached
rm -rf ~/Library/Developer/Xcode/DerivedData/
rm -rf ~/Library/Caches/CocoaPods/
pod deintegrate
pod update
C. Android
1. Khi cần bản release trên store để test.
Một số trường hợp xảy ra lỗi ở bản release tải từ cửa hàng. Lúc này quá trình đăng lên cửa hàng đợi duyệt và test sẽ tốn rất nhiều thời gian. Bên dưới là giải pháp giúp việc kiểm thử bản release một cách nhanh chóng nhất:
B1. Truy cập vào đây để đăng tải bản thử nghiệm. Sao chép liên kết để truy cập bằng điện thoại.

B2. Bật chế độ Internal app sharing trên điện thoại Android (CH Play đăng nhập bằng Email đăng nhập ở B1).

B3. Truy cập vào liên kết đã sao chép từ B1 để cài đặt lên thiết bị đã kích hoạt B2.

2. Task 'assembleAarRelease' not found
Lỗi thường gặp khi build release APK. Các bước để fix như sau:
Xóa thư mục .gradle trong thư mục android.
Trong build.gradle đổi thành 'com.android.tools.build:gradle:4.0.1'
Trong gradle-wrapper.properties đổi thành distributionUrl=https://services.gradle.org/distributions/gradle-6.3-bin.zip
Chạy lệnh ./gradlew clean build
3. Lấy keyhash android cho các mục tích hợp
Sử dụng key.jks release để lấy keyhash:
keytool -exportcert -alias <aliasName> -keystore <keystoreFilePath> | openssl sha1 -binary | openssl base64
Last updated
Was this helpful?