Reputation: 25974
After upgrading Flutter(flutter upgrade) sometimes there is errors and a new clean project is needed.
Is there any list of native files(like Classes in a Plugin) you should copy to the new project?
Upvotes: 2
Views: 502
Reputation: 5780
UPDATE
It looks like nowadays you just have to upgrade
and then run create
at the project's folder.
flutter upgrade
cd yourproject
flutter create .
OLD ANSWER
Exactly!!
I've been facing this for quite a while (since I'm an early adopter), and I wondered how people managed these flutter upgrades. One day you upgrade flutter and your app does not build anymore.
Right from the beginning I created a script after_flutter_upgrade.sh
, that I keep in the main folder of the project and I run it when that happens. Every iteration requires a few extra steps, and I keep maintaining the script. As it is very project-dependent, and I don't think it will help posting it here.
It feels terribly wrong doing that, but it works, so I forgive myself.
What the script does is going to the parent folder and renaming the project's folder to something like old_<myproject>
. Then, it runs flutter create <myproject>
. So I remain with the original old_<myproject>
and the recently created blank <myproject>
.
And then the script start copying from the old to the new one:
/lib
/test
/assets # I keep an assets folder for logos, images and such
/.vscode # If you use it
/.git # Afterall I want to log everything which was changed
/.gitignore
/android/.gitignore
/analysis_options.yaml # if you defined it
/pubspec.yaml
/README.md
/android/key.properties # if you're using it that way
# icons
/android/app/src/main/res
/ios/Runner/Assets.xcassets/AppIcon.appiconset
# These two if you're using firebase
/android/app/google-services.json
/ios/Runner/GoogleService-Info.plist
THEN, you still need:
ios/Runner/Info.plist
for the CFBundleName
and CFBundleLocalizations
entries.android/app/src/main/AndroidManifest.xml
with your package
and android:label
.android/app/src/main/com/example/prokect/MainActivity.java
or android/app/src/main/kotlin/com/example/project/MainActivity.kt
with your package
and adjusting the folder name (/com/example
-> /com/mycompany
)android/app/build.gradle
: changing applicationId
with your packageandroid/app/build.gradle
: changing signingConfig
and signingConfigs
to the same ones you've been usingandroid/app/build.gradle
: adding apply plugin: 'com.google.gms.google-services'
if you're using firebaseandroid/build.gradle
: add google-services classpath
in dependencies
if you're using firebaseGoogleService-info.plist
to the iOS project. Run open -a Xcode ./ios
and just drag this file from Finder to Xcode's Runner folder, so that Xcode recognises it.ios/Runner.xcodeproj/project.pbxproj
: search for PRODUCT_BUNDLE_IDENTIFIER and adjust with your package nameios/Runner.xcodeproj/project.pbxproj
: search for ORGANIZATIONNAME and adjust with your package nameandroid/app/src/main/res/values/styles.xml
: add a new style:<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@android:color/white</item>
</style>
And at least with me, this works. Hope it saves some time for someone.
Of course in your project there might be additional steps.
When I started the script, it was just 5 steps, now it's 12 and in 2021 they may get to 20!! :)
Upvotes: 2