Marcin Kunert
Marcin Kunert

Reputation: 6295

Gradle build with Error:Cause: tried to access method

I am getting following error when trying to build gradle android project.

Error:Cause: tried to access method com.android.build.gradle.internal.model.AaptOptionsImpl.create(Lcom/android/builder/model/AaptOptions;)Lcom/android/builder/model/AaptOptions; from class com.android.build.gradle.internal.model.ModelBuilder

My project structure looks as follows:

project
|- app
|-- build.gradle (#1)
|
|- module1
|-- build.gradle (#2)
|-- app_module_1
|--- build.gradle (#3)
|-- lib_module_1
|--- build.gradle (#4)
|
|- build.gradle (#5)
|- settings.gradle

The main app uses the lib_module_1 of the internal app. The internal app_module_1 can be build seperately using the module build.gradle (#2) settings.

When trying to build the main app defined in build.gradle (#1) i get the problem. Deleting the build.gradle (#2) fixes the problem, but then I can't build the app_module_1.

app_module_1 is not defined in the outer settings.gradle.

I am using build tools 23.0.2, gradle 2.9 and gradle build plugin 1.5.0

Upvotes: 0

Views: 333

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 365038

You have to change somenthing in your structure.

In your project/settings.gradle you have to include all modules.
If you need the app_module_1 you have to specify it in the settings.gradle.

If you want to build separately the module1 the only way is to add the tasks or the variables defined in the build.gradle (#2) also in the build.gradle (#5) or to use the command apply from inside the build.gradle (#3) and build.gradle (#4).

Upvotes: 1

Related Questions