I built an SDK for a project that needs Gson to function in order to serialize and deserialize complicated requests and responses from the backend. When I add my library as an AAR file in a test application I get this error when it tries to run: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/Gson. It goes away if I add a Gson dependency to my test application. My library gradle file looks like:
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.gson:gson:2.8.0'
}
but it seems just putting the dependency there is insufficient. What do I need to do in my library to make it so other users of my sdk don't have to add that as an additional dependency?