gpt4 book ai didi

android - 无法解析变量 '${project.groupId}'

转载 作者:IT老高 更新时间:2023-10-28 22:09:26 28 4
gpt4 key购买 nike

我将项目迁移到 AndroidX,但在构建项目时出现以下错误:

[TAG] Failed to resolve variable '${project.groupId}'   
[TAG] Failed to resolve variable '${project.version}'
[TAG] Failed to resolve variable '${project.groupId}'
[TAG] Failed to resolve variable '${project.version}'
[TAG] Failed to resolve variable '${project.groupId}'
[TAG] Failed to resolve variable '${project.version}'

我已经尝试了几种可能的解决方案:

  • 清洁项目
  • 使缓存失效并重新启动
  • enableJetifier 设置为 false
  • 将选项 --refresh-dependencies 添加到编译器设置

这是我的项目 gradle 文件:

buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:4.0.0'
classpath 'io.fabric.tools:gradle:1.25.4'
}
}

allprojects {
repositories {
jcenter()
maven {
url 'https://jitpack.io'
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

这是我的应用程序 gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

dexOptions {
javaMaxHeapSize "4g"
}

signingConfigs {
//not showing this
}
compileSdkVersion 28
defaultConfig {
applicationId "my.app.package"
minSdkVersion 21
targetSdkVersion 28
versionCode 59
versionName "1.5.2"

vectorDrawables.useSupportLibrary = true
multiDexEnabled true

}
dataBinding {
enabled = true
}
// workaround for "duplicate files during packaging of APK" issue
// see https://groups.google.com/d/msg/adt-dev/bl5Rc4Szpzg/wC8cylTWuIEJ
packagingOptions {
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'

//Workaround to an issue due to google play-services 11.0.0 + rxJava
exclude 'META-INF/rxjava.properties'
}

buildTypes {
release {
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release_config

}
debug {
applicationIdSuffix ".debug"
versionNameSuffix " - debug"
debuggable true
}
}

flavorDimensions "public"

productFlavors {
//not useful to show this
}
}

ext {
supportLibVersion = '28.0.0'
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation project(path: ':security')

implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'

implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'
implementation 'com.google.guava:guava:22.0-android'
implementation 'com.google.android:flexbox:0.2.3'
implementation 'com.google.code.gson:gson:2.8.0'

implementation 'com.hannesdorfmann.fragmentargs:annotation:3.0.2'
annotationProcessor 'com.hannesdorfmann.fragmentargs:processor:3.0.2'

implementation 'com.f2prateek.dart:dart:2.0.0'
annotationProcessor 'com.f2prateek.dart:dart-processor:2.0.0'

implementation 'com.google.dagger:dagger:2.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.2'

implementation 'com.couchbase.lite:couchbase-lite-android:1.4.1'
implementation 'com.couchbase.lite:couchbase-lite-android-sqlcipher:1.4.1'

implementation 'com.squareup.retrofit2:retrofit:2.2.0'
implementation 'com.squareup.retrofit2:converter-gson:2.2.0'

implementation 'com.wang.avi:library:1.0.5'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.jaredrummler:twodscrollview:1.0.1'

implementation 'com.arasthel:asyncjob-library:1.0.3'
implementation('org.simpleframework:simple-xml:2.7.1') {
exclude group: 'xpp3', module: 'xpp3'
exclude group: 'stax', module: 'stax-api'
exclude group: 'stax', module: 'stax'
}

implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.1.6'

debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'

implementation 'com.github.daniel-stoneuk:material-about-library:2.2.1'
implementation 'org.apache.commons:commons-lang3:3.4'

implementation('com.github.hotchemi:permissionsdispatcher:3.0.1') {
exclude module: "support-v13"
}
annotationProcessor "com.github.hotchemi:permissionsdispatcher-processor:3.0.1"

implementation 'com.pascalwelsch.compositeandroid:activity:27.0.0'
implementation 'com.pascalwelsch.compositeandroid:fragment:27.0.0'

implementation 'commons-codec:commons-codec:1.10'

implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'


}

apply plugin: 'com.google.gms.google-services'

// https://stackoverflow.com/a/49981467/3520621
configurations {
cleanedAnnotations
compile.exclude group: 'org.jetbrains' , module:'annotations'
}

更新

我运行 gradlew assembleDebug --stacktrace --debug --info 这里有更多信息:

...
Caused by: org.gradle.api.artifacts.transform.ArtifactTransformException: Failed to transform file 'dagger-compiler-2.2.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
...
Caused by: java.lang.RuntimeException: Failed to transform 'C:\Users\me\.gradle\caches\modules-2\files-2.1\com.google.dagger\dagger-compiler\2.2\e411f732e5cd9697cdb291f6073b0d6ee2352023\dagger-compiler-2.2.jar' using Jetifier. Reason: The type does not support '.' as package separator! Received 'java.lang.Object;Ljava.lang.Class'.. (Run with --stacktrace for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.

所以看来 jetifierdagger 是原因,但 jetifier 是迁移到 AndroidX 所必需的,我不想移除 Dagger

如果我设置 android.enableJetifier=false 我有超过 50 个关于 DataBinding 的问题。


更新 2这是完整的异常(exception)情况

org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:devDebugAnnotationProcessorClasspath'.
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.rethrowFailure(DefaultConfiguration.java:944)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$1600(DefaultConfiguration.java:120)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:918)
at org.gradle.api.internal.file.AbstractFileCollection.iterator(AbstractFileCollection.java:68)
at org.gradle.api.internal.changedetection.state.AbstractFileCollectionSnapshotter$FileCollectionVisitorImpl.visitCollection(AbstractFileCollectionSnapshotter.java:72)
at org.gradle.api.internal.file.AbstractFileCollection.visitRootElents(AbstractFileCollection.java:234)
at org.gradle.api.internal.file.CompositeFileCollection.visitRootElents(CompositeFileCollection.java:185)
at org.gradle.api.internal.changedetection.state.AbstractFileCollectionSnapshotter.snapshot(AbstractFileCollectionSnapshotter.java:55)
at org.gradle.api.internal.changedetection.state.DefaultClasspathSnapshotter.snapshot(DefaultClasspathSnapshotter.java:42)
at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository.snapshotTaskFiles(CacheBackedTaskHistoryRepository.java:329)
at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository.createExecution(CacheBackedTaskHistoryRepository.java:151)
at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository.access$100(CacheBackedTaskHistoryRepository.java:61)
at org.gradle.api.internal.changedetection.state.CacheBackedTaskHistoryRepository$1.getCurrentExecution(CacheBackedTaskHistoryRepository.java:111)
at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.getStates(DefaultTaskArtifactStateRepository.java:208)
at org.gradle.api.internal.changedetection.changes.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.isUpToDate(DefaultTaskArtifactStateRepository.java:93)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:50)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:256)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:249)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:238)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:663)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:597)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.artifacts.transform.ArtifactTransforxception: Failed to transform file 'dagger-compiler-2.2.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
at org.gradle.api.internal.artifacts.transform.UserCodeBackedTransforr.transform(UserCodeBackedTransforr.java:89)
at org.gradle.api.internal.artifacts.transform.TransformArtifactOperation.run(TransformArtifactOperation.java:41)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.access$900(DefaultBuildOperationExecutor.java:63)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$ParentPreservingQueueWorker.execute(DefaultBuildOperationExecutor.java:378)
at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.runOperation(DefaultBuildOperationQueue.java:230)
at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.access$600(DefaultBuildOperationQueue.java:172)
at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable$1.call(DefaultBuildOperationQueue.java:209)
at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable$1.call(DefaultBuildOperationQueue.java:203)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152)
at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.runBatch(DefaultBuildOperationQueue.java:202)
at org.gradle.internal.operations.DefaultBuildOperationQueue$WorkerRunnable.run(DefaultBuildOperationQueue.java:177)
... 3 more
Caused by: java.lang.RuntiException: Failed to transform 'C:\Users\martin\.gradle\caches\modules-2\files-2.1\com.google.dagger\dagger-compiler\2.2\e411f732e5cd9697cdb291f6073b0d6ee2352023\dagger-compiler-2.2.jar' using Jetifier. Reason: The type does not supp
ort '.' as package separator! Received 'java.lang.Object;Ljava.lang.Class'.. (Run with --stacktrace for more details.) To disable Jetifier, set android.enableJetifier=false in your gradle.properties file.
at com.android.build.gradle.internal.dependency.JetifyTransform.transform(JetifyTransform.kt:204)
at org.gradle.api.internal.artifacts.transform.TransformArtifactsAction.apply(TransformArtifactsAction.java:44)
at org.gradle.api.internal.artifacts.transform.TransformArtifactsAction.apply(TransformArtifactsAction.java:29)
at org.gradle.api.internal.artifacts.transform.DefaultTransfordFileCache$TransformAction.execute(DefaultTransfordFileCache.java:224)
at org.gradle.api.internal.artifacts.transform.DefaultTransfordFileCache$TransformAction.execute(DefaultTransfordFileCache.java:211)
at org.gradle.internal.resource.local.DefaultPathKeyFileStore$1.execute(DefaultPathKeyFileStore.java:111)
at org.gradle.internal.resource.local.DefaultPathKeyFileStore$1.execute(DefaultPathKeyFileStore.java:107)
at org.gradle.internal.resource.local.DefaultPathKeyFileStore.doAdd(DefaultPathKeyFileStore.java:160)
at org.gradle.internal.resource.local.DefaultPathKeyFileStore.add(DefaultPathKeyFileStore.java:107)
at org.gradle.internal.resource.local.DefaultPathKeyFileStore.add(DefaultPathKeyFileStore.java:50)
at org.gradle.api.internal.artifacts.transform.DefaultTransfordFileCache$1$1.create(DefaultTransfordFileCache.java:143)
at org.gradle.api.internal.artifacts.transform.DefaultTransfordFileCache$1$1.create(DefaultTransfordFileCache.java:122)
at org.gradle.cache.internal.LockOnDemandCrossProcessCacheAccess.withFileLock(LockOnDemandCrossProcessCacheAccess.java:89)
at org.gradle.cache.internal.DefaultCacheAccess.withFileLock(DefaultCacheAccess.java:193)
at org.gradle.cache.internal.DefaultPersistentDirectoryStore.withFileLock(DefaultPersistentDirectoryStore.java:158)
at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.withFileLock(DefaultCacheFactory.java:187)
at org.gradle.api.internal.artifacts.transform.DefaultTransfordFileCache$1.create(DefaultTransfordFileCache.java:122)
at org.gradle.api.internal.artifacts.transform.DefaultTransfordFileCache$1.create(DefaultTransfordFileCache.java:115)
at org.gradle.cache.internal.ProducerGuard$AdaptiveProducerGuard.guardByKey(ProducerGuard.java:97)
at org.gradle.api.internal.artifacts.transform.DefaultTransfordFileCache.loadIntoCache(DefaultTransfordFileCache.java:115)
at org.gradle.api.internal.artifacts.transform.DefaultTransfordFileCache.getResult(DefaultTransfordFileCache.java:107)
at org.gradle.api.internal.artifacts.transform.UserCodeBackedTransforr.transform(UserCodeBackedTransforr.java:87)
... 16 more
Caused by: java.lang.IllegalArguntException: The type does not support '.' as package separator! Received 'java.lang.Object;Ljava.lang.Class'.
at com.android.tools.build.jetifier.core.type.JavaType.<init>(JavaType.kt:28)
at com.android.tools.build.jetifier.processor.transform.bytecode.asm.CustomRemapper.mapValue(CustomRemapper.kt:49)
at org.objectweb.asm.commons.thodRemapper.visitLdcInsn(thodRemapper.java:179)
at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1582)
at org.objectweb.asm.ClassReader.readthod(ClassReader.java:1126)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:698)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
at com.android.tools.build.jetifier.processor.transform.bytecode.ByteCodeTransforr.runTransform(ByteCodeTransforr.kt:39)
at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:328)
at com.android.tools.build.jetifier.processor.archive.ArchiveFile.accept(ArchiveFile.kt:41)
at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:316)
at com.android.tools.build.jetifier.processor.archive.Archive.accept(Archive.kt:66)
at com.android.tools.build.jetifier.processor.Processor.transformLibrary(Processor.kt:312)
at com.android.tools.build.jetifier.processor.Processor.transform(Processor.kt:175)
at com.android.build.gradle.internal.dependency.JetifyTransform.transform(JetifyTransform.kt:199)
... 37 more

最佳答案

我一直有同样的问题,只需在 Gradle 中添加一些内容并再次同步,问题就解决了,我认为是 Android Studio 的一个错误

关于android - 无法解析变量 '${project.groupId}',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52816022/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com