ハマった
ここ最近は、Realmもデータバインディングもそこそこよく使われているので、
class Message extends RealmObject {
@PrimaryKey public long id;
public String title;
public String body;
}
みたいなモデルがあって
<TextView
id="@+id/message_title"
text="@{message.title}"
みたいな感じでデータバインディングするケースはよくあると思います。
これに、最近あんまり使われてない気がしてるInstrumented Unit Test(androidTestビルド)が組み合わさると
:app:mergeDebugAndroidTestAssets
:app:transformClassesWithRealmTransformerForDebugAndroidTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithRealmTransformerForDebugAndroidTest'.
> javassist.CannotCompileException: [source error] realmGet$title() not found in xx.yy.zz.Message
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2 mins 43.678 secs
みたいなコンパイルエラーになります。
調べてもなぜかそれっぽい情報は出てこない?
https://github.com/realm/realm-java/issues/2936 が全く同じエラーっぽいなー
でも違うな―
よくわからん。
って感じでした。
getter/setterなら大丈夫!
class Message extends RealmObject {
@PrimaryKey public long id;
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String body;
}
みたいなモデルにして
<TextView
id="@+id/message_title"
text="@{message.getTitle()}"
ならコンパイル通った。なんで??