AutoValue在Android项目中找不到生成的构造函数

我正在努力让AutoValue在Android项目中工作.它似乎正在为其他人工作,所以我必须丢失一些东西.我尝试启用jack编译器,似乎没有帮助.

Here一个演示项目,当我在本地构建它时失败.投诉发生在this class,在这里找不到Autovalue_Repo构造函数.

这是我的项目级别build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.1'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的模块级别build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 24
    buildToolsversion "24.0.2"
    defaultConfig {
        applicationId "org.cse390.githubhotness"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile filetree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    provided 'com.google.auto.value:auto-value:1.2-rc1'
    compile "com.google.auto.value:auto-value:1.2-rc1"
    apt "com.google.auto.value:auto-value:1.2-rc1"

    compile 'com.jakewharton:butterknife:8.4.0'
    apt 'com.jakewharton:butterknife-compiler:8.4.0'

    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'

    testCompile 'junit:junit:4.12'
}

这是没有自动赋值的类:

@Autovalue
public abstract class Repo {
  public abstract int id();
  public abstract String name();
  public abstract String fullName();
  public abstract String description();
  public abstract int numStars();
  public abstract String language();
  public abstract String htmlUrl();

  static Repo create(int id, String name, String fullName, String description,
                     int numStars, String language, String htmlUrl) {
    // See "How do I...?" below for nested classes.
    return new Autovalue_Repo(id, name, fullName, description, numStars,
        language, htmlUrl);
  }

}

这里有明显的错误吗?

解决方法:

因为我们在这里生成一个类,所以对该方法的访问必须是公共的,以便自动值可以工作.

  public static Repo create(int id, String name, String fullName, String description,
                 int numStars, String language, String htmlUrl) {
        // See "How do I...?" below for nested classes.
        return new Autovalue_Repo(id, name, fullName, description, numStars,
                    language, htmlUrl);
   }

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...