Android AOSP quickly rebuild system.img only - android-source

For Android AOSP build system. is it possible rebuild system.img from out/target/prodcut/xx/ only?
I am studying Android AOSP, and build system. However the rebuild time is too long for me.
.for for example
mm <module>
Then the output should be like as out/target/product/<xxx>/<vendor/system>/...
Finally, I want to regenerate images from out/target/product/<xxx>/ only to save time.

You can use the following targets to only build the images (including the modules on which they are dependent).
systemimage for system.img
vendorimage for vendor.img
vbmetaimage for vbmeta.img
and many more
Example:
m systemimage
Note: This is only an incremental build and not a full rebuild. For a full rebuild you have to call m clean first.

Related

Could not create task ... this and base files have different roots

I've built an app with Android Studio and Flutter and wanted to generate a signed APK.
When I go to Tools->Flutter->Open Android module in Android Studio, it starts to build the project.
But after some time I get this Error and I don't know how to change the roots or what to do.
It seems like the problem are just two packages (url_launcher and shared preferences)
My Project is on my hard disk F:
and the flutter folder is on my hard disk C:
Error Message "Could not create task..."
Is this maybe because my project is on F: and the flutter folder with the packages in C: ?
How can I change the flutter folder to F: ?
I fixed mine by moving the project directory to the same drive. My project was stored in E:\ so, I moved it to C:.
My answer is almost the same as rvr93's answer but I did not add anything to the environment variables.
Create a directory in the same drive as your project and add PUB_CACHE environment variable. Run flutter pub get.
This worked for me.
I had your same issue, Gradle couldn't sync the android module, I solved it by deleting the android/ directory from the Flutter project, then recreate it using the command flutter create --platforms android .
Notice the "." at the end of the command it's part of it, it means create the Android project in the current directory.
As a workaround, you can do the following steps -
run flutter clean
do the Gradle sync without flutter pub get and make necessary changes to
native android code.
do pub get and run the app.
I have the same issue,
it seems the flutter project and the SDKs are in different prtitions of the hard disk
just go to the project root and run flutter clean
then go to the android folder and delete the .gradle folder
then back to the project root and run flutter pub get
and rebuild the app
As a workaround, you can do the following steps :
Open a terminal.
Run flutter clean.
Do the Gradle sync without flutter pub get and make necessary changes to native Android code or click on try again.
Do flutter pub get and run the app.
You will see that the SHA1 has been generated.
I faced the same issue in my android project after upgrading gradle.
My project was in my D drive, and I had set the destination folder for the generated apk in my desktop, which is in C drive. I changed the destination folder to a folder in D drive, and the issue got resolved.
I was facing the same issue all I did was to go build.gradle file in android folder and then change the following code as follows
dependencies {
//CHANGE THE Version in YOUR BUILD.GRADLE FILE
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
This is a temporary solution - track status here

How to delete then reinstall Flutter

Whenever I have a problem with Flutter I often find answers saying 'reinstall the Flutter SDK'.
However I cannot find any clear instructions on how to do this (please direct me to them if I am wrong).
General Questions
By 'clear' instructions, I mean ones that answer the following questions:
What folder(s) should be deleted to remove Flutter from my computer?
Do any files need to be copied and added to the new Flutter folder once I reinstall it?
Do I need to make any changes to my Flutter projects either before or after reinstalling Flutter?
Will I need to download the same channel (stable, beta, dev, master) as what I am currently on?
Will I need to make any changes to my PATH?
Are these the correct steps to reinstall?
Go to https://flutter.dev/docs/development/tools/sdk/releases?tab=macos
Download the zip of the release you want (safest to use latest stable version)
Open Flutter zip in SAME location as the previous Flutter folder was
Done - I should now be able to run Flutter projects without any further steps
Apologies if these seem like very basic questions but for someone fairly new it isn't obvious what the answers are.
I'm new to Flutter and had similar issues. I will outline what worked for me but meanwhile, to answer your questions:
What folder(s) should be deleted to remove Flutter from my computer?
The Flutter folder which you unzipped and, presumably added to $PATH. Although not deleting it isn't going to pose an issue. I have separate folders of different versions of Flutter on my computer and it's fine.
Do any files need to be copied and added to the new Flutter folder
once I reinstall it?
Try a fresh download of Flutter and unzip it? There is no need to copy or add any files to the Flutter folder once you've (re)installed it.
Do I need to make any changes to my Flutter projects either before or
after reinstalling Flutter?
Not exactly sure what you mean by make changes to your Flutter projects. If you ran flutter doctor and didn't get any errors, then it's good to go. When you create a new Flutter project either in Android Studio, VS Code or Terminal, it will automatically handle whatever file copying business.
Will I need to download the same channel (stable, beta, dev, master)
as what I am currently on?
No, you only need one. I suggest you download one from Stable unless you need web support, which would be Beta.
Will I need to make any changes to my PATH?
After you've unzipped your fresh copy of Flutter (note the folder destination), open Terminal and change the path to said folder destination but make sure it's the /bin folder you're mapping to.
Are these the correct steps to reinstall?
Go to
https://flutter.dev/docs/development/tools/sdk/releases?tab=macos
Download the zip of the release you want (safest to use latest stable
version) Open Flutter zip in SAME location as the previous Flutter
folder was Done - I should now be able to run Flutter projects without
any further steps
Yes and no. You're missing a number of steps. Please follow the full Flutter installation guide depending on your OS.
It took me about 10 hours over two days and a VPN to finally get it working in China with an old install from two years ago when I was in Montréal.

How to create/provide multiple example apps for a flutter plugin?

Flutter seems to have a very strict/rigid structure for plugins with example folder and all contents inside that folder.
I want to provide multiple examples with my plugin. Something like examples folder and then examples/demo1 and examples/demo2 as two different app examples.
I tried doing this but flutter run or pub get command breaks with this change. it's gets stuck with below error which wasn't thrown with exact same code in previous structure before change. Also my app actually follow embedding v2 code so this error is completely false too.
The plugin `<MY PLUGIN>` requires your app to be migrated to the Android embedding v2. Follow the steps on
https://flutter.dev/go/android-project-migration and re-run this command.
Somehow is it expecting that there should be only one example and that too with example folder only ?
Can someone help, and if possible point me to a plugin project where it's using multiple examples ?
After trying multiple ways to deal with the situation,
I ended up with a good enough solution.
I moved entire flutter repo inside an sdk directory, and then Introduced a samples folder at root level which can contain multiple sample applications.
sdk itself has a default sample app under example folder which I kept so sdk can ship with one example project.
Final structure look like below,
- Root
- sdk
- Flutter plugin project (like android/example/ios/lib directory etc.)
- samples
- sampleOne
- sampleTwo
I then mentioned relative path to sdk for sampleOne or sampleTwo inside their pubspec.yaml like path: ../../sdk/
When I want to open sampleOne in AndroidStudio, I import sampleOne directory and it works like charm. Make sure you don't import entire samples directory or sampleOne/Android.
For any regular Flutter commands for plugin, I run them inside sdk directory and everything works fine as expected. So I would run publish or pub get inside root/sdk directory

Flutter: How to backup flutter project without build directory?

I want to make a complete backup of the Flutter project, and I noticed the build folder is the biggest one.
Size Details:
Total App Size: 889.6 MB
Build Directory: 743 MB
Remaining directories, including ios, android, assets and lib: 146 MB
I think, zipping project excluding build directory would be considered full backup and it will contain everything needed to start again.
Q. Is that correct? (if I'm wrong then is there any way to reduce app size?)
Delete build folder.
Delete Pod folder from IOS Directory
.gradle folder from android Directory
& if you have release & build folder in Android then delete it
Run Command: Fluter Clean
Now Folder will be 1MB to 10MB, depending on assets folder size.
To start with i would suggest git versioning with an online (public or private) repository as a good way to back up your code. To answer your Question, There's absolutely no problem with leaving out the build folder, Actually almost by default git will ignore the build folder. Note that every time you compile the app, that build folder is refreshed, actually its always good to start by cleaning it
In IntelliJ idea base ides (like Android Studio), you can get a lightweight .zip backup from your code.
Just follow this path in the top menu:
File> Export> Project to Zip File

How to develop Flutter app and related package at same time in VS Code

I have a Flutter app and a package folder loaded in VS code at the same time within a workspace. What entry do I need to make to my app's pubspec.yaml file to ensure that changes I've made to the package are compiled and included whenever I hot reload or restart the app? What would be an alternate strategy if this is not possible?
If your pubspec.yaml refers to your package with a path then I would expect this to happen automatically. If not, I would consider it a bug. Please file an issue at https://github.com/Dart-Code/Dart-Code and include a log file generated by running the Dart: Capture Logs command and as much info about your project layout as possible (a clonable repo to repro would be perfect).