Shot
Shot copied to clipboard
AGP 7.0 Cannot query the value of property 'applicationId'
With current release of AS Arctic Fox and Android Gradle Plugin 7 I tried updating our (library) project to that. Currently our build fails with
java.lang.IllegalStateException: Cannot query the value of property 'applicationId' because configuration of project ':sdk' has not completed yet.
where sdk
is our library module. Running ./gradlew build
with --stracktrace
shows it's coming from Shot:
Caused by: java.lang.IllegalStateException: Cannot query the value of property 'applicationId' because configuration of project ':sdk' has not completed yet.
at org.gradle.api.internal.provider.AbstractProperty$NonFinalizedValue.maybeFinalizeOnRead(AbstractProperty.java:368)
at org.gradle.api.internal.provider.AbstractProperty.beforeRead(AbstractProperty.java:229)
at org.gradle.api.internal.provider.AbstractProperty.calculateOwnValue(AbstractProperty.java:126)
at org.gradle.api.internal.provider.AbstractMinimalProvider.get(AbstractMinimalProvider.java:84)
at com.android.build.gradle.internal.api.BaseVariantImpl.getApplicationId(BaseVariantImpl.java:235)
at com.android.build.gradle.internal.api.LibraryVariantImpl_Decorated.getApplicationId(Unknown Source)
at com.karumi.shot.ShotPlugin.composeCompleteAppId(ShotPlugin.scala:105)
at com.karumi.shot.ShotPlugin.addTaskToVariant(ShotPlugin.scala:98)
at com.karumi.shot.ShotPlugin.$anonfun$addTasksToLibraryModule$1(ShotPlugin.scala:76)
at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:100)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction$1.run(DefaultCollectionCallbackActionDecorator.java:95)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:71)
at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction.execute(DefaultCollectionCallbackActionDecorator.java:92)
at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:163)
at com.karumi.shot.ShotPlugin.addTasksToLibraryModule(ShotPlugin.scala:75)
at com.karumi.shot.ShotPlugin.addTasks(ShotPlugin.scala:65)
at com.karumi.shot.ShotPlugin.$anonfun$apply$1(ShotPlugin.scala:51)
at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:100)
Removing Shot from the project makes it compile again, so I'm pretty certain it's coming from here. Problematic seems the plugin application to the module.
We're pretty much using the default configuration, just applying the plugin to our library module, setting the testInstrumentationRunner
and testApplicationId
.
I'm not sure if it's related, but we also get a warning
WARNING:API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'.
Version of the library
Shot 5.11.0 AGP 7.0.0 Gradle 7.1.1 Kotlin 1.5.21
Hey @Syex I've just merged a PR with a small fix in the plugin configuration that could fix the integration with the AGP. Could you please check once 5.11.1 version is available if it fixes your issue?
We'll need to rewrite using the new DSL, there will have to be a 4.x version and a 7.x version, they changed the ways variants and other things are now queried
Hey @Syex could you please share your Shot configuration? You can anonymize the data if you need it. I'm just wondering how you are configuring Shot.
@pedrovgs the AGP7.0 plugin fixes a bunch of tasks being created, tasks are now only configured when calling, so in the case now, applicationId is empty until test is called, the new API is actually a provider which gets updated.
I even tried with the new DSL and it's the same error, so we'll need to rewrite the way tasks are created to use providers instead - not difficult, just won't have time until later today at the earlist
it.onVariants {
it.androidTest!!.applicationId.get() // Same error
}
Hey @pedrovgs , I've the exactly same issue blocking me to upgrade to AGP 7.0.0.
It happens I've this open-source project that I think it might help us here 😄
Just raised this PR so you can use the target branch as a sample.
The stack trace is exposed on this CI run, for instance
Also I agree with @chrisjenx , it looks like a breaking change coming directly from the way that new APIs are implemented/exposed on AGP 7.x.y 😭
Same issue for us. I have created a sample app, maybe it will help to isolate the problem: https://github.com/boguszpawlowski/ShotAGPBug.
Quick update. I've tested it with different AGP versions and 7.1.0-alpha05 and seems to be working as expected. I'm trying to find a workaround, meanwhile you can downgrade your project to use alpha05.
I'm releasing a new version with the workaround. Could any of you please test it and provide some feedback about it? I had only half day to work on this fix and I did my best but I'm not sure if this will be the solution for all your scenarios.
I did a quick check in my simple project. Seems to work. Previously (AGP 7.0.0 Shot 5.11.1) even app:tasks
failed with
Cannot query the value of property 'applicationId' because configuration of project ':xyz' has not completed yet.
Now with AGP 7.0.0 Shot 5.11.2 I see the warning but it works.
Error found trying to get applicationId from library module. We will use the extension applicationId param as a workaround.
More information about this AGP7.0.1 bug can be found here: https://github.com/Karumi/Shot/issues/247
Extension applicationId value read =
Error found trying to get applicationId from library module. We will use the extension applicationId param as a workaround.
More information about this AGP7.0.1 bug can be found here: https://github.com/Karumi/Shot/issues/247
Extension applicationId value read =
Yeap that's the idea @MyDogTom 😃 Thank you so much. I'm going to keep this issue open until they release AGP 7.0.1 final version and we can decide how to properly fix this.
Remember @MyDogTom you'll need to configure the extension value if you want to use shot in your module!
Amazing work, thanks @pedrovgs!
Can the warning message be disabled? I mean, it's useless, if you use extension applicationId
property you already know you have to use it
Would be nice to make it quiet since it's popping up like 30 times on the project I am working on, making CI logs worse