LoginSignup
0
0

More than 5 years have passed since last update.

DataBindingのGradle設定でちょっとハマったとこ

Last updated at Posted at 2016-12-08

ハマったとこ

DataBindingを使うためには、公式にも記述ある通り、Android Plugin for Gradle 1.5.0-alpha1以降が必要です。
しかし、それに気づかずバージョンが1.3.0のままになっていた為、GradleのSync時に下記エラーが出力されSyncが失敗...。

Error:(9, 0) Gradle DSL method not found: 'dataBinding()'
Possible causes:
The project 'KotlinTest' may be using a version of Gradle that does not contain the method.
The build file may be missing a Gradle plugin.

今回は下記のようにバージョンを2.2.0に変更してあげました。変更後、エラーが解消。

dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
}

警告が出た

また、サポートされている最小のGradleバージョンの指定が誤っていたため、下記のような警告が出ました。

Warning:Minimum supported Gradle version is 2.14.1. Current version is 2.4.

単純にgradle-wrapper.properties内のバージョンを2.4から2.14.1に書き換えてSyncすれば解消するのですが、
Gradleの設定が[Use local gradle distribution]になっている場合、gradle-wrapper.propertiesの内容が反映されないため、[Use default gradle wrapper(recommended)]へ変更。
変更後にSyncしてあげると解消されました。

・変更箇所
[Setting]→[Build,Execution,Deployment]→[Build Tool]→[Gradle]→[Use default gradle wrapper(recommended)]

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0