Я разрабатываю библиотеку для Android для внутреннего использования в нашей компании, эта библиотека имеет зависимости от третьей части и хранится в нашем собственном репозитории Artifactory.
Проблема в том, что, поскольку мы обновились до Gradle 3, у нас нет видимости зависимостей библиотеки в различных проектах, в которых мы используем библиотеку.
Я что-то упустил, это мой файл библиотеки build.gradle:
apply plugin: 'com.android.library'
//Skitude Plugins
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
repositories {
maven { url "https://jitpack.io" }
mavenCentral()
}
//Artifactory ID
def libraryGroupId = 'com.company.companylibrary'
def libraryArtifactId = 'library'
def libraryVersion = '0.0.6'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 17
targetSdkVersion 27
versionCode 6
versionName "0.0.6"
vectorDrawables.useSupportLibrary= true
}
buildTypes {
defaultConfig {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//Dependencies ANDROID
api 'com.android.support:appcompat-v7:27.1.1'
api 'com.android.support:support-v13:27.1.1'
api 'com.android.support:support-annotations:27.1.1'
api 'com.android.support:support-vector-drawable:27.1.1'
api 'com.android.support.constraint:constraint-layout:1.1.0'
api 'com.android.support:design:27.1.1'
api 'com.android.support:cardview-v7:27.1.1'
api 'com.android.support:recyclerview-v7:27.1.1'
api 'com.android.support:customtabs:27.1.1'
api 'com.android.volley:volley:1.0.0'
...
}
publishing {
publications {
aar(MavenPublication) {
groupId libraryGroupId
version libraryVersion
artifactId libraryArtifactId
artifact("$buildDir/outputs/aar/${artifactId}-release.aar")
pom.withXml {
def dependencies = asNode().appendNode('dependencies')
configurations.compile.allDependencies.each {
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.moduleGroup)
dependency.appendNode('artifactId', it.moduleName)
dependency.appendNode('version', it.moduleVersion)
}
}
}
}
}
artifactory {
contextUrl = 'http://artifactory.company.com/artifactory/'
publish {
repository {
repoKey = 'library-core-release-local'
username = artifactory_username
password = artifactory_password
}
defaults {
publications('aar')
publishArtifacts = true
properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
publishPom = true
}
}
}
Например, когда моя библиотека хочет получить доступ к библиотеке залпа из моего приложения без повторного импорта зависимости, поэтому она уже импортирована в мою библиотеку, я получаю следующее:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.skitude.Valdesqui, PID: 28489
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/android/volley/toolbox/DiskBasedCache;
at com.blabsolutions.skitudelibrary.Helpers.ProfileHelper.setupVolley(ProfileHelper.java:81)
at com.blabsolutions.skitudelibrary.SkitudeApplication.onCreate(SkitudeApplication.java:132)
at com.skitude.Valdesqui.CoorpApplication.onCreate(CoorpApplication.java:32)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1032)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5885)
at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1703)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.android.volley.toolbox.DiskBasedCache" on path: DexPathList[[zip file "/data/app/com.skitude.Valdesqui-1/base.apk", zip file "/data/app/com.skitude.Valdesqui-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.skitude.Valdesqui-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.skitude.Valdesqui-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.skitude.Valdesqui-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.skitude.Valdesqui-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.skitude.Valdesqui-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.skitude.Valdesqui-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.skitude.Valdesqui-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.skitude.Valdesqui-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.skitude.Valdesqui-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.skitude.Valdesqui-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.skitude.Valdesqui-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.blabsolutions.skitudelibrary.Helpers.ProfileHelper.setupVolley(ProfileHelper.java:81)
at com.blabsolutions.skitudelibrary.SkitudeApplication.onCreate(SkitudeApplication.java:132)
at com.skitude.Valdesqui.CoorpApplication.onCreate(CoorpApplication.java:32)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1032)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5885)
at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1703)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Suppressed: java.io.IOException: No original dex files found for dex location (arm64) /data/app/com.skitude.Valdesqui-1/split_lib_slice_6_apk.apk ()
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:373)
at dalvik.system.DexFile.<init>(DexFile.java:113)
at dalvik.system.DexFile.<init>(DexFile.java:78)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:359)
at dalvik.system.DexPathList.makeElements(DexPathList.java:323)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:263)
at dalvik.system.DexPathList.<init>(DexPathList.java:126)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:58)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:535)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:568)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2046)
at android.app.LoadedApk.getResources(LoadedApk.java:787)
at android.app.ContextImpl.<init>(ContextImpl.java:2261)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2201)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5776)
... 8 more
То, что я пробовал:
- Upgarde от Gradle 3.1.0 до Gradle 4.4
- Отключить Proguard по умолчанию
Спасибо