Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Error Extension not initialized yet, couldn't access compileSdkVersion. Android Studio

> Task :prepareKotlinBuildScriptModel UP-TO-DATE
<ij_msg_gr>Gradle import errors<ij_msg_gr><ij_nav>D:\Important_Docs\Projects\Backup\RLPHYC\android-utils\build.gradle<ij_nav><i><b>project ':android-utils': Unable to build Kotlin project configuration</b><eol>Details: org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':android-utils:generateLintModuleInfo'.<eol>Caused by: java.lang.IllegalStateException: Extension not initialized yet, couldn't access compileSdkVersion.</i>
<ij_msg_gr>Gradle import errors<ij_msg_gr><ij_nav>D:\Important_Docs\Projects\Backup\RLPHYC\app\build.gradle<ij_nav><i><b>project ':app': Unable to build Kotlin project configuration</b><eol>Details: org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':app:generateLintModuleInfo'.<eol>Caused by: java.lang.IllegalStateException: Extension not initialized yet, couldn't access compileSdkVersion.</i>
Extension not initialized yet, couldn't access compileSdkVersion.

Tried to invalidate cache restart also used ext in top-level Gradle and also deleted Gradle folder Still error continues

No problem with the Gradle version tried the same with different Gradle versions

like image 472
Adarsh Sahu Avatar asked Aug 17 '20 13:08

Adarsh Sahu


3 Answers

like @Vacexe said, this is dexcount plugin's bug.

You can resovle this problem by update dexcount plugin version to 2.0.0:

classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:2.0.0'
like image 146
penkzhou Avatar answered Oct 28 '22 07:10

penkzhou


I have the same issue in our project after uplift gradle plugin to 4.1.0 version and it has been solved by removing this plugin

apply plugin: 'com.getkeepsafe.dexcount'
  • Firstly check what a plugin in use in your project
  • Secondly try to recompile without it to find a tricky one
like image 1
Vacxe Avatar answered Oct 28 '22 07:10

Vacxe


They removed some deprecated methods from the DSL. So not-up-to-date plugins will crash miserably on this update. In fact, issue can come from any gradle plugin that uses deprecated methods from the gradle Android DSL. Just run

$ ./gradlew clean assemble --stacktrace

to understand what plugin calls a deprecated (removed) method, and in general this plugin has a more recent version that no longer uses the deprecated DSL method. In my case, this was junit5, but one has to do the per-case verification.

like image 1
AlexG Avatar answered Oct 28 '22 05:10

AlexG