Xamarin Android Binding Library
Creating and Releasing .aar file :
- Go to gradle at top right pane in android studio follow below steps.
2. Gradle->Dropdown library name -> tasks-> build-> assemble or assemble release
3. AAR will be generated in build/outputs/aar/
Binding Process :
Open visual studio and create new project with sample app and binding library.
1. Create a new project for Android app.
2. Create a new project for Android binding library Create a new project for Android binding library
3.Create a new Xamarin Binding Library project.
App Setup :
Add all the drawable, layout, activities, class files to Android app that is used to showcase the framework library.
Add .aar file :
- Add created .aar file under jars folder by right click on jar folders
2. Select Add option -> Existing Items.
3. Select xxx_release.aar file from where you have stored after generate from android studio. It will be added under jars folder in our binding library project.
4. Select aar file and set Build Action as LibraryProjectZip in properties tab.
5. Right click on binding library project and clean then rebuild.
6. Add dependency nuget package to the Class Library package.
Adding Reference :
- Sample app project -> References
2. Right click on References -> Add References
3. Select Project -> select the appropriate check box which project to be added as reference.
4. Do clean and rebuild the project.
5. We can access all the binding library features in our sample app now.
Installing Nuget and Setup :
Get Praveen Kumar KS’s stories in your inbox
Join Medium for free to get updates from this writer.
1. Download Nuget.exe file and install
2. Copy Nuget.exe file to the project drive(Ex: If your project folder contains in D:/ drive copy nuget.exe to D:/ drive).
3. Setup Environmental variable.
4. Computer -> Properties -> Advanced System Settings -> Environmental variable -> In path section add nuget.exe file path.
5. Double click on path and add the Nuget.exe file path.
6. Restart the pc.
Create Nuget Package :
- Create lib folder under our binding library root path(Mention Correct Project Path).
· Create a new lib folder inside (file path)
· In your project binding library, go to the lib folder (file path)
· Create a file with the name file_name.nuspec file into the first lib folder (File path\optiscanlibrary.nuspec)
· Edit the nuspec file with name, version and add details about dependencies need to be download from nuget package.
Create Specification File :
To Create. nuspec file cmd -> nuget spec project_filename.csproj (Ex: nuget spec file.csproj).
Add dependencies with version :
· Add below dependency within nuspec file under metadata tag.
<dependencies>
<dependency id=”Microsoft.AppCenter.Analytics” version=”4.3.0" />
<dependency id=”Microsoft.AppCenter.Crashes” version=”4.3.0" />
<dependency id=”Square.OkHttp3.LoggingInterceptor” version=”4.4.1" />
</dependencies>
1. Open Command Prompt.
2. Go to nuspec file path Run command -> nuget pack optiscanlibrary.nuspec (This will create the nupkg file, which will be uploaded to NuGet)
3. You will get success message like “Successfully created package”,
4. To add nuget package to application, need to create nuget package.
(Example: nuget add D:/Package/file.nupkg-Source D:/NugetPackage)
5. Add Nuget Package in Visual Studio with correct folder path, and install the nuget package.







