I am trying to use a custom aar in my android project. I found dozens of examples in StackOverflow and the Web. Many failed at build, none worked. The clearest was at
http://kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/
That came closest to working.
Here's what I did
Successfully created a very simple AAR (Ref.aar) from Ref.java
// Ref.java package com.ramrod.Ref; public class Ref { // Square an integer public static int square(int val) { return (val * val); } }
Created a test project (RefTest)
- Created folder 'libs' under RefTest/app
- Added Ref.aar to libs
- File->New->New Module->Import .JAR/.AAR Package.
- Selected Ref.jar as filename->Finish (appeared successful).
Modified build.gradle
// build.gradle (Module: app) apply plugin: 'com.android.application' android { compileSdkVersion 27 buildToolsVersion "27.0.3" defaultConfig { applicationId "com.ramrod.RefTest" minSdkVersion 11 targetSdkVersion 15 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } repositories { flatDir { dirs 'libs' } } dependencies { compile( name:'Ref', ext:'aar' ) } }
- Sync build.gradle (all)
Added reference to Ref.aar method (square) to onCreate in RefTest main activity.
int sq = Ref.square( 2 );
Build->Clean then Build->Rebuild.
This produced error: cannot find symbol variable Ref
I'm sure I'm doing something naive or just plain dumb, but I can't see it.
Any help appreciated.