当前位置: 首页 > 知识库问答 >
问题:

Gradle Robobind与AspectJ Lombok不兼容

方昊
2023-03-14

我想在Gradle上的Android项目中集成以下库:

  • 隆坡
  • 使用AspectJ进行机器人绑定
  • 匕首

为了将RoboBinding与AspectJ和android工具1.1结合使用。0我使用此修复程序编译了aspectj插件。

所有库都使用一些编译时注释处理。我发现Lombok与AspectJ不兼容。我注意到Robobind的注释处理器使用的是apt,而lombok只在提供的情况下工作(Dagger两者都可以)。

我还为Maven找到了Lombok和ASHOJ workaurond,但我不知道这是否也可以与Gradle一起使用(如果是的话,我不知道如何使用)。

没有龙目山,项目正在编译和运行。您能帮助将Lombok和AspectJ与Gradle集成吗?

错误:

Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
:app:compileDebugAspectJ
warning You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
Lombok supports: sun/apple javac 1.6, ECJ
error at model.setOutput(model.getInput());

D:\Projects\BinderExample\app\src\main\java\foo\binderexample\MainActivity.java:32:0::0 The method getInput() is undefined for the type BinderModel
Error:Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
error at model.setOutput(model.getInput());

D:\Projects\BinderExample\app\src\main\foo\binderexample\MainActivity.java:32:0::0 The method getInput() is undefined for the type BinderModel
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugAspectJ'.
> The method getInput() is undefined for the type BinderModel

模块:

@Module(injects = MainActivity.class)
public class BinderModule {

    @Provides
    @Singleton
    BinderModel provideBinderModel() {
        return new BinderModel();
    }
}

型号:

@Data
@PresentationModel
public class BinderModel implements HasPresentationModelChangeSupport {

    private final PresentationModelChangeSupport changeSupport = new PresentationModelChangeSupport(this);

    private String input;
    private String output;

    @Override
    public PresentationModelChangeSupport getPresentationModelChangeSupport() {
        return changeSupport;
    }
}

活动:

public class MainActivity extends Activity {

    @Inject
    BinderModel model;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ObjectGraph.create(new BinderModule()).inject(this);
        View view = Binders.inflateAndBind(this, R.layout.activity_main, model);
        setContentView(view);
        ButterKnife.inject(this);
    }

    @OnClick(R.id.button)
    void onButtonClick() {
        model.setOutput(model.getInput());
    }
}

布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:bind="http://robobinding.org/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">

    <EditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:inputType="text"
        bind:text="${input}"/>

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/button"/>

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:textAppearance="?android:attr/textAppearanceLarge"
        bind:text="{output}"/>

</LinearLayout>

渐变脚本:

buildscript {
    repositories {
        jcenter()
        mavenLocal()
    }

    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
        classpath 'org.robobinding:aspectj-plugin:0.8.3-fix'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'org.robobinding.android-aspectj'
apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "foo.binderexample"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.0.0'

    compile 'com.jakewharton:butterknife:6.1.0'

    //dagger
    compile 'com.squareup.dagger:dagger:1.2.2'
    apt 'com.squareup.dagger:dagger-compiler:1.2.2'

    //lombok
    provided 'org.projectlombok:lombok:1.16.2'
    apt 'org.projectlombok:lombok:1.16.2'

    //robobinding
    compile('org.robobinding:robobinding:0.8.9:with-aop-and-dependencies') {
        exclude group: 'com.google.guava', module: 'guava'
    }
    aspectPath('org.robobinding:robobinding:0.8.9:with-aop-and-dependencies') {
        exclude group: 'com.google.guava', module: 'guava'
    }
    apt 'org.robobinding:codegen:0.8.9'
}

共有1个答案

锺离晗昱
2023-03-14

如果你想了解更多关于龙目岛的情况,请阅读我的另一个答案,并点击那里的链接。

 类似资料:
  • 问题内容: 我正在使用来自AJAX发布请求的回调来导航到新页面,但是在Internet Explorer上不起作用。我的代码如下: 这在FF / Safari / Chrome上正常运行,但是当我在IE上对其进行测试时,它不起作用。是否有更好的方法重定向到新页面?我正在使用,因为如果我不使用回调,则数据不会加载到Chrome / Safari上,因为在请求完成之前页面只会更改。 问题答案: 是括号

  • 我有一个关于JavaAPI中Akka 2.0.1的问题。我有以下情况: 参与者A:从UI接收请求。然后它将执行以下操作。 等待来自UI的消息 发送msg到Actor B,以检索数据 成为一个演员,当从演员B那里得到答案时,处理它。 演员B: 等待演员A的消息 检索数据 调用; 这不起作用,演员甲也不会得到答案。然而,如果Actor B在系统中使用全局actorRef到Actor A,在我的情况下z

  • 问题内容: Websphere v8.5.5开箱即用地支持JPA 2.0 。 我正在尝试将WAR部署到Websphere v8.5.5应用程序服务器。我的persistence.xml指定为JPA提供程序。 我还设置了JPA属性: 如本PDF演示文稿和本IBM主题中所述 我的应用程序设置为“ Parent Last”类加载策略,并且在WEB-INF / lib目录中包含以下JAR: hiberna

  • 在IntelliJ 202.2的最后更新后,我得到错误: 插件“Lombok”不兼容(直到build 201.SNAPSHOT) 我一直在寻找这个问题,但似乎我是唯一一个有这个IntelliJ版本问题的人。

  • 我刚在winforms应用程序中获取的内容 我的应用程序对web Api服务进行http调用,如下所示 没什么特别的,只要你安装了Newtonsoft。通过nuget的Json(V6.0.3) 突然,我在HttpResponseMessage代码行上出现了stackOverflow错误。移除Newtonsoft,问题就解决了。 问题是我是使用库序列化/反序列化数据在其他地方在我的窗体 我的解决方法

  • 在我的pc上安装Java 9之后,只需运行一个示例Scala SBT项目,我就遇到了这个例外。我已经尝试了一些解决方案,但什么都没有找到。 Java9和Scala之间是否存在不兼容? Scala版本:2.12。3. Java版本:Java版本“9” IDE: IntelliJ 提前谢谢。 我试过了,但没有成功。