Java 当依赖项是aar而不是jar时,Android gradle不能依赖mavenLocal如何修复它?
我可以使用mavenLocal在Java 当依赖项是aar而不是jar时,Android gradle不能依赖mavenLocal如何修复它?,java,android,maven,android-studio,gradle,Java,Android,Maven,Android Studio,Gradle,我可以使用mavenLocal在~/.m2/存储库 我使用依赖项: implementation "com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:${versions.threatMetrixVersion}@aar" mavenCentral() jcenter() google() mavenLocal() 我声明
~/.m2/存储库
我使用依赖项:
implementation "com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:${versions.threatMetrixVersion}@aar"
mavenCentral()
jcenter()
google()
mavenLocal()
我声明在何处查找依赖项:
implementation "com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:${versions.threatMetrixVersion}@aar"
mavenCentral()
jcenter()
google()
mavenLocal()
真实:
预期:
Loading file:/Users/gongzelong/.m2/repository/com/threatmetrix/ThreatMetrixMobileSDK/TrustDefenderMobileForAndroid/6.0-139/TrustDefenderMobileForAndroid-6.0-139.aar
我使用mavenLocal并将依赖项放在~/.m2/存储库中
它无法加载该文件
该文件确实存在:
gongzelong:VMCP gongzelong$ ls -la /Users/gongzelong/.m2//repository/com/threatmetrix/ThreatMetrixMobileSDK/TrustDefenderMobileForAndroid/6.0-139/TrustDefenderMobileForAndroid-6.0-139.aar
-rw-r--r--@ 1 gongzelong staff 1203645 Nov 30 13:36 /Users/gongzelong/.m2//repository/com/threatmetrix/ThreatMetrixMobileSDK/TrustDefenderMobileForAndroid/6.0-139/TrustDefenderMobileForAndroid-6.0-139.aar
日志是:
2021-04-05T21:14:22.046+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Using androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0 from Maven repository 'Google'
2021-04-05T21:14:22.046+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139 using repositories [MavenRepo, BintrayJCenter, Google, MavenLocal, flatDir, maven, maven2, maven3]
2021-04-05T21:14:22.046+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'MavenRepo'
2021-04-05T21:14:22.046+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'BintrayJCenter'
2021-04-05T21:14:22.046+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'Google'
2021-04-05T21:14:22.046+0800 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver] Loading file:/Users/gongzelong/.m2/repository/com/threatmetrix/ThreatMetrixMobileSDK/TrustDefenderMobileForAndroid/6.0-139/TrustDefenderMobileForAndroid-6.0-139.pom
2021-04-05T21:14:22.048+0800 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver] Loading file:/Users/gongzelong/.m2/repository/com/threatmetrix/ThreatMetrixMobileSDK/TrustDefenderMobileForAndroid/6.0-139/TrustDefenderMobileForAndroid-6.0-139.jar
2021-04-05T21:14:22.048+0800 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver] POM file found for module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in repository 'MavenLocal' but no artifact found. Ignoring.
2021-04-05T21:14:22.048+0800 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in repository 'MavenLocal'.
2021-04-05T21:14:22.048+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.PersistentModuleMetadataCache] Recording absence of module descriptor in cache: com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139 [changing = false]
2021-04-05T21:14:22.048+0800 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver] Loading file:/Users/gongzelong/Visa/Code/deps/deps/TrustDefenderMobileForAndroid-6.0-139.aar
2021-04-05T21:14:22.048+0800 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver] Loading file:/Users/gongzelong/Visa/Code/deps/deps/TrustDefenderMobileForAndroid.aar
2021-04-05T21:14:22.048+0800 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in repository 'flatDir'.
2021-04-05T21:14:22.048+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.modulecache.PersistentModuleMetadataCache] Recording absence of module descriptor in cache: com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139 [changing = false]
我检查了gradle的源代码:
请注意:
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected matches [project :profiler configuration debugApiElements] from candidates [project :profiler configuration debugAndroidTestCompile, project :profiler configuration debugAndroidTestRuntime, project :profiler configuration debugApiElements, project :profiler configuration debugRuntime, project :profiler configuration debugRuntimeElements, project :profiler configuration debugUnitTestCompile, project :profiler configuration debugUnitTestRuntime, project :profiler configuration releaseApiElements, project :profiler configuration releaseRuntime, project :profiler configuration releaseRuntimeElements, project :profiler configuration releaseUnitTestCompile, project :profiler configuration releaseUnitTestRuntime] for {com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=androidJvm}
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139 using repositories [MavenRepo, BintrayJCenter, Google, MavenLocal, flatDir]
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'MavenRepo'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'BintrayJCenter'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'Google'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'MavenLocal'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'flatDir'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] No candidates for {com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=androidJvm}, selected matching fallback project :mVisaConsumerSDK-3.2.1 configuration default
2021-04-15T02:13:13.589+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder] Visiting configuration VMCP:app:unspecified(debugCompileClasspath).
2021-04-15T02:13:13.589+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.60 using repositories [MavenRepo, BintrayJCenter, Google, MavenLocal, flatDir]
我从public artifactory下载依赖项,然后将其从/gradle/cache
移动到mavenLocal(/m2/repository
)
更新1:
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected matches [project :profiler configuration debugApiElements] from candidates [project :profiler configuration debugAndroidTestCompile, project :profiler configuration debugAndroidTestRuntime, project :profiler configuration debugApiElements, project :profiler configuration debugRuntime, project :profiler configuration debugRuntimeElements, project :profiler configuration debugUnitTestCompile, project :profiler configuration debugUnitTestRuntime, project :profiler configuration releaseApiElements, project :profiler configuration releaseRuntime, project :profiler configuration releaseRuntimeElements, project :profiler configuration releaseUnitTestCompile, project :profiler configuration releaseUnitTestRuntime] for {com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=androidJvm}
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139 using repositories [MavenRepo, BintrayJCenter, Google, MavenLocal, flatDir]
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'MavenRepo'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'BintrayJCenter'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'Google'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'MavenLocal'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'flatDir'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] No candidates for {com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=androidJvm}, selected matching fallback project :mVisaConsumerSDK-3.2.1 configuration default
2021-04-15T02:13:13.589+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder] Visiting configuration VMCP:app:unspecified(debugCompileClasspath).
2021-04-15T02:13:13.589+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.60 using repositories [MavenRepo, BintrayJCenter, Google, MavenLocal, flatDir]
根据本文和代码,我们可以在mavanLocal中使用aar。但这不适合我的情况。出什么事了
更新2:
gradle似乎试图搜索jar而不是aar。为什么?
更新3:
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected matches [project :profiler configuration debugApiElements] from candidates [project :profiler configuration debugAndroidTestCompile, project :profiler configuration debugAndroidTestRuntime, project :profiler configuration debugApiElements, project :profiler configuration debugRuntime, project :profiler configuration debugRuntimeElements, project :profiler configuration debugUnitTestCompile, project :profiler configuration debugUnitTestRuntime, project :profiler configuration releaseApiElements, project :profiler configuration releaseRuntime, project :profiler configuration releaseRuntimeElements, project :profiler configuration releaseUnitTestCompile, project :profiler configuration releaseUnitTestRuntime] for {com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=androidJvm}
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139 using repositories [MavenRepo, BintrayJCenter, Google, MavenLocal, flatDir]
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'MavenRepo'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'BintrayJCenter'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'Google'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'MavenLocal'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'flatDir'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] No candidates for {com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=androidJvm}, selected matching fallback project :mVisaConsumerSDK-3.2.1 configuration default
2021-04-15T02:13:13.589+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder] Visiting configuration VMCP:app:unspecified(debugCompileClasspath).
2021-04-15T02:13:13.589+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.60 using repositories [MavenRepo, BintrayJCenter, Google, MavenLocal, flatDir]
相关渐变源代码:
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] Selected matches [project :profiler configuration debugApiElements] from candidates [project :profiler configuration debugAndroidTestCompile, project :profiler configuration debugAndroidTestRuntime, project :profiler configuration debugApiElements, project :profiler configuration debugRuntime, project :profiler configuration debugRuntimeElements, project :profiler configuration debugUnitTestCompile, project :profiler configuration debugUnitTestRuntime, project :profiler configuration releaseApiElements, project :profiler configuration releaseRuntime, project :profiler configuration releaseRuntimeElements, project :profiler configuration releaseUnitTestCompile, project :profiler configuration releaseUnitTestRuntime] for {com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=androidJvm}
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139 using repositories [MavenRepo, BintrayJCenter, Google, MavenLocal, flatDir]
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'MavenRepo'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'BintrayJCenter'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'Google'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'MavenLocal'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository] Detected non-existence of module 'com.threatmetrix.ThreatMetrixMobileSDK:TrustDefenderMobileForAndroid:6.0-139' in resolver cache 'flatDir'
2021-04-15T02:13:13.588+0800 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] No candidates for {com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=androidJvm}, selected matching fallback project :mVisaConsumerSDK-3.2.1 configuration default
2021-04-15T02:13:13.589+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder] Visiting configuration VMCP:app:unspecified(debugCompileClasspath).
2021-04-15T02:13:13.589+0800 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver] Attempting to resolve component for org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.60 using repositories [MavenRepo, BintrayJCenter, Google, MavenLocal, flatDir]