How to use the aar package in android studio for java development, such as libs/libyuv-release.aar
In Android Studio, you can add .aar
files to your project by following these steps:
-
Place
.aar
the file into the projectlibs
directory. If you don't have a directory in your projectlibs
, you can create one. -
In your project's root
build.gradle
file, make sure yourallprojects
section includeslibs
the directory as a repository:allprojects { repositories { ... flatDir { dirs 'libs' } } }
-
In your module's (usually
app
)build.gradle
file, add.aar
the file as a dependency:dependencies { ... implementation(name: 'libyuv-release', ext: 'aar') }
where
name
is the name of your.aar
file (not including.aar
the extension) andext
is the file extension. -
Sync your Gradle project. In Android Studio's toolbar, click the "Sync Project with Gradle Files" button, or select "File > Sync Project with Gradle Files" from the menu.
.aar
Now you should be able to use the classes in the file in your project . If you encounter "unable to resolve symbol" errors when using these classes, you may need to import these classes. In a Java file, you can use import
statements to import .aar
classes in the file. For example, if you want to use com.android.libyuv.Yuv2Rgb
classes, you can add the following import statement to your Java file:
import com.android.libyuv.Yuv2Rgb;
Then, you can use the class in your code Yuv2Rgb
.