2016-10-19 6 views
2

AndroidプロジェクトでAutoValueが動作するように苦労しています。それは他の人のために働いているようですので、私は何かを逃しているに違いない。私はジャックコンパイラを有効にしようとしましたが、それは役に立たなかったようです。Androidプロジェクトで自動生成されたコンストラクタが見つかりません

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); 
    } 

} 
は、

ここに間違いがありますか?

+0

クラスは作成メソッドへのアクセスが生成されているので、public autovalueが動作する必要があります。 – Eoin

+0

私が試したすべてのこと(クラスとメンバー変数の可視性の変更を含む)の中で、私は明らかにそのことをやめました。しかし、実際それは動作します。あなたのコメントを回答に昇進させるなら、私はそれを受け入れます。私はまた、私は静的メソッドの可視性と私は手動でエラーを拾うか、エラーを修正するためにそれを作るために呼び出す必要がありますAndroidスタジオで注意する必要があります。これは、以前私からこの修正を隠していたかもしれませんが、私はそれに誓うことはできません。ありがとうございました! – user1978019

+0

私は助けてくれるとうれしいです。 Iveは前回同様の問題を抱えていました。 :) – Eoin

答えて

2

ここでクラスを生成しているので、メソッドへのアクセスは公開されている必要があり、自動割り当てが機能します。

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); 
    } 
関連する問題