将Android注释添加到Android studio的步骤

时间:2014-12-19 23:46:50

标签: gradle android-studio build.gradle android-annotations

我正在关注此链接,将Android Annotations添加到android studio:http://www.jayway.com/2014/12/19/androidannotations-setup-android-studio/

我不确定为什么我的新build.gradle(第一个代码)不起作用(抛出像R.android这样的大量错误 - 基本上没有找到资源)。这源于我对gradle脚本语言的理解不足

我的app文件夹中的当前build.grade如下:

apply plugin: 'android'

android {
    signingConfigs {
        debug {
        }
    }
    compileSdkVersion 19
    buildToolsVersion "19.1.0"
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
        debug {
            debuggable true
        }
    }
}

apply plugin: 'android-apt'
def AAVersion = '3.2'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
    }
}


apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        resourcePackageName 'com.earthmileslftr.earthmiles'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.apptentive:apptentive-android:1.6.+@aar'
    compile 'com.jakewharton:butterknife:6.0.0'
    compile 'com.github.talenguyen:prettysharedpreferences:1.0.1'
    compile 'com.squareup.picasso:picasso:2.4.0'
    compile 'com.pkmmte.view:circularimageview:1.1'
    compile 'com.github.lzyzsd:circleprogress:1.0.0@aar'
    compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
    compile 'com.android.support:support-v4:21.0.0'
    compile 'in.srain.cube:ultra-ptr:1.0.5@aar'
    compile project(':facebook')
    apt "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"
}

以前完美运行的build.gradle如下所示

apply plugin: 'android'

    android {
        signingConfigs {
            debug {
            }
        }
        compileSdkVersion 19
        buildToolsVersion "19.1.0"
        defaultConfig {
            minSdkVersion 14
            targetSdkVersion 19
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                runProguard false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
            debug {
                debuggable true
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.apptentive:apptentive-android:1.6.+@aar'
        compile 'com.jakewharton:butterknife:6.0.0'
        compile 'com.github.talenguyen:prettysharedpreferences:1.0.1'
        compile 'com.squareup.picasso:picasso:2.4.0'
        compile 'com.pkmmte.view:circularimageview:1.1'
        compile 'com.github.lzyzsd:circleprogress:1.0.0@aar'
        compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
        compile 'com.android.support:support-v4:21.0.0'
        compile 'in.srain.cube:ultra-ptr:1.0.5@aar'
        compile project(':facebook')
    }

我得到的错误如下

/Users/somghosh/volt-android/facebook/src/com/facebook/AuthorizationClient.java
Error:(29, 28) error: cannot find symbol class R
/Users/somghosh/volt-android/facebook/src/com/facebook/FacebookRequestError.java
Error:(19, 28) error: cannot find symbol class R
/Users/somghosh/volt-android/facebook/src/com/facebook/widget/WebDialog.java
Error:(40, 28) error: cannot find symbol class R
/Users/somghosh/volt-android/facebook/src/com/facebook/LoginActivity.java
Error:(24, 28) error: cannot find symbol class R
/Users/somghosh/volt-android/facebook/src/com/facebook/Settings.java
Error:(33, 28) error: cannot find symbol class BuildConfig
/Users/somghosh/volt-android/facebook/src/com/facebook/internal/ImageDownloader.java
Error:(25, 28) error: cannot find symbol class R
/Users/somghosh/volt-android/facebook/src/com/facebook/widget/FriendPickerFragment.java
Error:(29, 28) error: cannot find symbol class R
/Users/somghosh/volt-android/facebook/src/com/facebook/widget/GraphObjectAdapter.java
Error:(27, 28) error: cannot find symbol class R
/Users/somghosh/volt-android/facebook/src/com/facebook/widget/LikeView.java
Error:(35, 28) error: cannot find symbol class R
/Users/somghosh/volt-android/facebook/src/com/facebook/widget/PlacePickerFragment.java
Error:(36, 28) error: cannot find symbol class R
/Users/somghosh/volt-android/facebook/src/com/facebook/RequestBatch.java
Error:(175, 8) error: self-closing element not allowed
Error:(195, 8) error: self-closing element not allowed
/Users/somghosh/volt-android/facebook/src/com/facebook/internal/ImageRequest.java
Warning:(31, 12) no description for @param

1 个答案:

答案 0 :(得分:1)

在项目build.gradle文件中,您可以添加以下代码:

if (JavaVersion.current().isJava8Compatible()) {
    allprojects {
        tasks.withType(Javadoc) {
            options.addStringOption('Xdoclint:none', '-quiet')
        }
    }
}

这样,您将在Java8 JavaDoc工具中禁用新选项。

特别感谢来自博客的Stephen Colebourne: http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html