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

'android' or 'android-library' plugin is required #16

Closed
DylanSale opened this issue Sep 22, 2014 · 8 comments
Closed

'android' or 'android-library' plugin is required #16

DylanSale opened this issue Sep 22, 2014 · 8 comments

Comments

@DylanSale
Copy link

I have been using android-gradle-template for my project for a while. Since updating to Android Studio 0.8.9 I get this error after opening the AppUnitTests/build.gradle file and then running the test runner:

Error:(19, 0) Gradle: A problem occurred evaluating project ':AppUnitTests'.

The 'android' or 'android-library' plugin is required.

This happens after building the testClasses just before the tests start running. Do you know what could be causing it?

@nenick
Copy link
Owner

nenick commented Sep 22, 2014

I saw this message by a co worker. We could not explain why. There is a known issue but it didn't match. #4

Just close and reopen Android Studio helped.

@DylanSale
Copy link
Author

We found closing and re-opening worked sometimes, but not others. Deleting the .idea folder and iml files and re-importing the project worked consistently, but is a pain to do.

@DylanSale
Copy link
Author

EDIT: This is not correct

I think I figured out what it is. The first (ExampleProject below) element in the .idea/workspace.xml file is causing the problem:

              <ExternalProjectPojo>
                <option name="name" value="ExampleProject" />
                <option name="path" value="$PROJECT_DIR$" />
              </ExternalProjectPojo>
              <ExternalProjectPojo>
                <option name="name" value=":App" />
                <option name="path" value="$PROJECT_DIR$/App" />
              </ExternalProjectPojo>
              <ExternalProjectPojo>
                <option name="name" value=":AppComponentTests" />
                <option name="path" value="$PROJECT_DIR$/AppComponentTests" />
              </ExternalProjectPojo>
              <ExternalProjectPojo>
                <option name="name" value=":AppUnitTests" />
                <option name="path" value="$PROJECT_DIR$/AppUnitTests" />
              </ExternalProjectPojo>

I think this is a new value that was added in the update which makes the root folder a project in the build (I don't recall seeing this before). For some reason opening the build.gradle file re-orders this to be the first in that list, but that causes the error. Moving the <ExternalProjectPojo> element with the $PROJECT_DIR$ path to the last one in the list fixed the issue.

Why this is happening I can't say. Is this something the scripts could be updated to do automatically? I guess ultimately it would be good to understand why it causes the problem in the first place.

@nenick
Copy link
Owner

nenick commented Sep 23, 2014

Thanks for figure it out. I'm faced this issue too.

Yes it should be possible to edit this file automatically like it done for the robolectric support.

I'm thinking about to switch the basic plugin which enable robolectric tests. I got not much feedback from Novoda. And another plugin looks to be on a state where all stuff is supported which i like to have. Except the one thing, that i like to spilt two test kinds (unit tests and integration tests with robolectric).

So the https://github.com/JCAndKSolutions/android-unit-test/ plugin can not have the reported issues because it have all stuff in one module.

Maybe we should report this issue to google. This miss behaviour could occur when you have pur java library modules in your project.

@nenick
Copy link
Owner

nenick commented Sep 23, 2014

I'm not sure if this the real problem, after restart my Android Studio my Project works fine. In the workspace.xml is still a "wrong" order.

@nenick
Copy link
Owner

nenick commented Sep 24, 2014

again this error .. i reordered the workspace.xml entries and i still get this message. maybe I did something wrong.

This log line shows the wrong order
Information:Gradle: Executing tasks: [:AppComponentTests:assemble, :AppComponentTests:testClasses, :App:assembleDebug]

It should be like
Information:Gradle: Executing tasks: [:App:assembleDebug, :AppComponentTests:assemble, :AppComponentTests:testClasses]

sometimes it works fine with the workspace.xml order and sometimes this error occur. changing the workspace.xml looks not stable and force project reloads. Maybe this behaviour can reproduced with a simple app which use a pure java module as dependency. Then it should be a general bug at Android Studio and they should fix it ;)

@DylanSale
Copy link
Author

I believe you are correct that does not work. It was just a coincidence that it started working on our development machines after making that change I think.

I believe it is a bug with Android Studio messing around with the build order like you say.

@nenick
Copy link
Owner

nenick commented Oct 3, 2014

This behaviour comes only at Android Studio, i never saw it on command line. Looks like the error comes from the make commando. I removed the make commando its not necessary because we recompile tests with a custom gradle command. Its enough and should avoid this issue.

@nenick nenick closed this as completed Nov 15, 2014
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