Generally, the Flutter is packaged as an AAR and integrated into the original project. However, for a pure Flutter project, when you need to use a third party package, you need to introduce the AAR package into the Project. The process is a bit bumpy, but it is easy to do once again.
1. Import process
1. Right-click the project -> Flutter -> Android Moudle in Android Studio
2, File > New > New Module
3. Select the AAR package you want
4. The imported packages are in the project and directory by default, and we need to move them to Android
5. Modify setting.gradle and app/build.gradle
At this point the package has been imported successfully. But there are a few caveats.
Two, matters needing attention
Android Moudle in Android Studio is not in the directory
This is shown below
Iml and android/
This file is usually automatically generated by the IDE, so the Gitignore configuration generally ignores it, which can cause problems when you open the project in another environment.
The solution is to create a new project with the same name, copy the two files and paste them into the project
This error occurs when you import the package directly from the directory
You must first open Android Moudle in Android Studio, and then follow the initial steps
3, the process is correct, but the prompt can not find the package
If you put the package in the Android directory, you will not find it in the Android /libs directory. If you put the package in the Android /libs directory, you will not find it.
If we put the package in the Android /libs directory, we can change it like this
// android/setting.gradle
include ':libs:HZCameraSDK'
// android/app/build.gradle
dependencies {
implementation project(':libs:HZCameraSDK')}Copy the code
The process is relatively simple, if you know it, it can be done in about 5 minutes, but for me, who is new to this, it took me a whole day. But it’s finally done.