After upgrade AS to next canary version receive er...
# gradle
i
After upgrade AS to next canary version receive error during gradle sync
Copy code
Please initialize at least one Kotlin target in
despite the fact all was good on previous version Now i’ve updated canary 14 to canary 15 (updated AGP plugin as well) Early i got this error when updated from 13 to 14 (that time it was resolved after reinstalling AS: downgrading to 13 and updating to 14 again). I can try to repeat this way, but it is strange ) Have anyone stucks with that error? Is it happens after each upgrade? How can i fix it?
j
if you run gradlew build, you get the same error?
i
Hm. There was message about upgrade gradle wrapper from 7.0-rc-1 to 7.0. After upgrade my functions from bulildSrc became unresolved( Strange thing is no errors in editor, only during build time
j
copy the error when you run gradlew build
in terminal
have you using version catalogs?
i
Copy code
user@MacBook-Pro-user rt-mlk-mobile-kmm % ./gradlew build       

> Configure project :features:dog
Kotlin Multiplatform Projects are an Alpha feature. See: <https://kotlinlang.org/docs/reference/evolution/components-stability.html>. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.

e: /Users/user/StudioProjects/_work/rt-mlk-mobile-kmm/features/dog/build.gradle.kts:13:5: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
public fun LibraryExtension.commonConfiguration(configurations: ConfigurationContainer, configure: LibraryExtension.() -> Unit = ...): Unit defined in ru.rt.buildsrc

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/user/StudioProjects/_work/rt-mlk-mobile-kmm/features/dog/build.gradle.kts' line: 13

* What went wrong:
Script compilation error:

  Line 13:     commonConfiguration(configurations)
               ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
                   public fun LibraryExtension.commonConfiguration(configurations: ConfigurationContainer, configure: LibraryExtension.() -> Unit = ...): Unit defined in ru.rt.buildsrc

1 error

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at <https://help.gradle.org>

BUILD FAILED in 1s
have you using version catalogs?
What do you mean?
Hmm, maybe my buildSrc code broken becuse of gradle update?
t
remove
buildSrc/build
and try to re-run
i
I’m getting the same error after buildSrc rebuilded
j
if you open those files, they are correct?
i
All seems ok. Let me to introduce. I take type from
android
fun receiver and use it in my own extension
But i’ve found funny thing. If i change signature from extension to usual (implicit receiver) i got type mismatch
Actual type from
android
lambda is not the same as expected
Looks like bug?
And if i try to extend inferred type
com.android.build.api.dsl.LibraryExtension
i get fail. Because it hardly parametrisd with 5 generic types
Copy code
package com.android.build.api.dsl

import com.android.build.api.variant.LibraryVariantBuilder
import com.android.build.api.variant.LibraryVariant
import org.gradle.api.Incubating
import org.gradle.api.NamedDomainObjectContainer

/**
 * Extension for the Android Library Gradle Plugin.
 *
 *
 * Only the Android Gradle Plugin should create instances of this interface.
 */
@Incubating
interface LibraryExtension<
        AndroidSourceSetT : AndroidSourceSet,
        BuildTypeT : LibraryBuildType<SigningConfigT>,
        DefaultConfigT : LibraryDefaultConfig<SigningConfigT>,
        ProductFlavorT : LibraryProductFlavor<SigningConfigT>,
        SigningConfigT : ApkSigningConfig> :
    CommonExtension<
        AndroidSourceSetT,
        LibraryBuildFeatures,
        BuildTypeT,
        DefaultConfigT,
        ProductFlavorT,
        SigningConfigT,
        LibraryVariantBuilder,
        LibraryVariant>,
    TestedExtension {
    // TODO(b/140406102)

    /** Aidl files to package in the aar. */
    val aidlPackagedList: MutableCollection<String>?

    /**
     * container of Prefab options
     */
    val prefab: NamedDomainObjectContainer<PrefabPackagingOptions>
}
Looks like this type should not be returned from lamda in
Project.'android'
fun
Fixed this way ¯\_(ツ)_/¯
j
I remember doing that some time ago, maybe I filed an issue for a similar problem 🤔
i
Now there are multiple problem in file, even after clean, relaunch etc… But project builds
All types from popup are parents of LibraryExtensions
j
Change the JDK
i
Hmmm. Cannot find this option in project settings, where it was before. How can i do it? And which version shouls i use?
message has been deleted
tried set JAVA_HOME to jdk 11 and 16 location, but have no positive result
j
It should be in project but maybe they moved to Gradle settings
i
You’re correct. But it doesn’t help
Looks like LibraryExtensions receiver type in lambda changed in AGP alpha15 (checked that with different AGP versions). And new
com.android.build.api.dsl
version of LibraryExtensions is burried somewhere in AGP-alpha15 dependencies (not transitive). Downgraded to alpha14 for the present. Want to check this in next version of AGP
j
There are a lot of problems with this AGP version, I think yesterday I saw a thread similar to this which points to an issue in google issue tracker