Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xtend + Android support library = error: cannot access DrawerLayoutImpl #32

Closed
tobykurien opened this issue Aug 27, 2015 · 10 comments
Closed

Comments

@tobykurien
Copy link

This error happens the first time you build a project that uses the Android support library. To reproduce, try cloning WebApps (https://github.com/tobykurien/webapps) and building by running gradle assembleRelease:

:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:preReleaseBuild UP-TO-DATE
:prepareComAndroidSupportAppcompatV72221Library
:prepareComAndroidSupportSupportV42221Library
:prepareComGithubTobykurienXtendroid0121Library
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugBuildConfig
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets
:generateDebugResValues UP-TO-DATE
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
:compileDebugXtend
[snip - warnings]
:generateDebugSources
:processDebugJavaRes UP-TO-DATE
:compileDebugJava
/WebApps/src/com/tobykurien/webapps/activity/BaseWebAppActivity.java:35: error: cannot access DrawerLayoutImpl
public class BaseWebAppActivity extends AppCompatActivity {
...

The error only happens the first time (i.e. no build directory), thereafter it compiles fine. Unfortunately, this means that Travis CI builds fail. Happens with Gradle 2.2.1 and even Gradle 2.5.

One way to make this build pass the first time is to extract the JAR file containing the class (i.e. build/intermediates/exploded-aar/com.android.support/support-v4/22.2.1/jars/libs/internal_impl-22.2.1.jar and copy it into a libs folder and include that in the gradle dependencies. This is not ideal (and means my app isn't accepted by FDroid).

Also seems to affect Kotlin (https://devnet.jetbrains.com/message/5538844) and Groovy (groovy/groovy-android-gradle-plugin#31) and Maven (simpligility/android-maven-plugin#621) though there seem to be different work-arounds there.

Could you please look into why this might be happening? Any workarounds without including a binary jar file?

@oehme
Copy link
Member

oehme commented Aug 27, 2015

Does this happen in a pure Java Android project?

@tobykurien
Copy link
Author

No it does not.

@oehme
Copy link
Member

oehme commented Aug 27, 2015

Thanks for the example project, I'll look into it.

@tobykurien
Copy link
Author

Thank you!

FYI:

  • Easy way to reproduce is to simply delete the build folder and re-build.
  • I tried removing the xtend gradle plugin from the build.gradle file, and added xtend-gen to the source paths instead, and the build worked fine the first time around.

@tobykurien
Copy link
Author

Some more info: if you delete the build folder, then run this, it works:

gradle prepareReleaseDependencies
gradle assembleRelease

@oehme
Copy link
Member

oehme commented Sep 7, 2015

I think I know the reason for this. I'm on vacation for this week, but will get back to you when I return.

@oehme
Copy link
Member

oehme commented Oct 5, 2015

Hey Toby,

sorry for coming back so late, we are pretty busy with polishing 2.9 =)

This issue no longer happens in version 0.4.8 of the plugin. Your example uses 0.4.7

@oehme oehme closed this as completed Oct 5, 2015
@tobykurien
Copy link
Author

I tried using 0.4.8 and it still happens

@oehme oehme reopened this Oct 6, 2015
@oehme
Copy link
Member

oehme commented Oct 6, 2015

It is harder to reproduce than I thought. It works when I run "clean build", but not when I run "clean" and then "build".

I could solve the issue by pushing the classpath configuration even further down the lifecycle. Will be out as 0.4.9 soon.

@tobykurien
Copy link
Author

Thanks for the fix! It seems to work on that particular project now, using v0.4.9, but strangly, it still happens if you build this project from scratch: http://github.com/tobykurien/XtendApp (i.e. delete build and app/build directories before gradle assembleDebug)

Error:

app:compileDebugXtend

ERROR:  MainActivity.xtend - 
67: The method or field toolbar is undefined for the type MainActivity

ERROR:  MainActivity.xtend - 
43: The method or field drawerLayout is undefined for the type MainActivity

ERROR:  MainActivity.xtend - 
43: The method or field toolbar is undefined for the type MainActivity

ERROR:  MainActivity.xtend - 
44: The method or field drawerLayout is undefined for the type MainActivity

ERROR:  MainActivity.xtend - 
47: The method or field drawerLayout is undefined for the type MainActivity

ERROR:  MainActivity.xtend - 
61: The method or field drawerLayout is undefined for the type MainActivity

ERROR:  MainActivity.xtend - 
61: The method or field drawer is undefined for the type MainActivity
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants