Error: cannot access DrawerLayoutImpl after apply plugin 'kotlin-android'


#1

I am trying to add kotlin to my project, but after i add kotlin-android plugin to build.gradle - assemble fails first time, if i clean project before.

./gradlew clean && ./gradlew assembleDebug
error: cannot access DrawerLayoutImpl
BUILD FAILED

Second time it builds successfully
./gradlew assembleDebug
BUILD SUCCESSFUL

So i try to add the kotlin plugin to android NavigationDrawer sample from googlesamples and see the same behavior.
I fork the sample and try next scenario:

git clone https://github.com/rusmonster/android-NavigationDrawer.git
cd android-NavigationDrawer
./gradlew clean && ./gradlew assembleDebug
BUILD SUCCESSFUL

git checkout add-kotlin-plugin
git diff master
diff --git a/Application/build.gradle b/Application/build.gradle
index 48783bd…1e54a8c 100644
— a/Application/build.gradle
+++ b/Application/build.gradle
@@ -5,10 +5,12 @@ buildscript {

  dependencies {
  classpath ‘com.android.tools.build:gradle:1.0.0’

  •    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:0.11.91.1"
    
      }
    }

apply plugin: ‘com.android.application’
+apply plugin: ‘kotlin-android’

repositories {
  jcenter()

./gradlew clean && ./gradlew assembleDebug
/NavigationDrawerActivity.java:89: error: cannot access DrawerLayoutImpl
BUILD FAILED

./gradlew assembleDebug
BUILD SUCCESSFUL

./gradlew clean && ./gradlew assembleDebug
/NavigationDrawerActivity.java:89: error: cannot access DrawerLayoutImpl
BUILD FAILED

Any ideas?

#2

I sometimes get this error while building with gradle in Android studio : e: The following classes have incomplete hierarchies:   android.support.v4.widget.DrawerLayout, unresolved: [DrawerLayoutImpl]

Usually, if I build again, it goes away…


#3

Yes, it happens only once each time, after cleaning the project. Second time after that it builds successfully. As result, this problem fully breaks the build on CI server.


#4

Could I see your build.gradle file?


#5

build.gradle file is here: https://github.com/rusmonster/android-NavigationDrawer/blob/add-kotlin-plugin/Application/build.gradle

I inverstigate the problem and was able to fix it.
So i post the bug: https://youtrack.jetbrains.com/issue/KT-7277
And send the pull request that fixes it: https://github.com/JetBrains/kotlin/pull/635


#6

have a look at this
.
https://github.com/Shekhar14o3/NavigationDrawer