2016-07-13 6 views
0

я ид в Project Structure -> Приложение> Dependencies-> добавить библиотечно-> аннотацийКак настроить AndroidAnnotations на студии Android?

И когда я ставлю @EActivity (R.layout.activity_main) по основной деятельности, что я могу сделать, это создать аннотации .. но он ничего не может сделать с (R.layout.activity_main).

Androud Студия 2.1.2

+0

Предполагаю, вы говорите об AndroidAnnotations. Просто взгляните на их документацию. У них есть довольно подробное руководство для Android Studio и Gradle: https://github.com/excilys/androidannotations/wiki/Configuration – peshkira

+1

Спасибо, действительно помог мне! :) – sshifty

ответ

2

Хороший способ, чтобы добавить аннотацию через Gradle. Затем вы можете импортировать и редактировать его.

Здесь у вас есть link для официальной документации AndroidAnnotation

И вот моя рабочая Gradle конфигурация: build.gradle (Projec: ProjectName)

buildscript { 
repositories { 
    mavenCentral() 
} 
dependencies { 
    // replace with the current version of the Android plugin 
    classpath 'com.android.tools.build:gradle:2.1.2' 
    // replace with the current version of the android-apt plugin 
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 
} 
} 

repositories { 
    mavenCentral() 
    mavenLocal() 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

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

build.gradle (модуль: приложение)

apply plugin: 'com.android.application' 
apply plugin: 'com.neenbedankt.android-apt' 
def AAVersion = '4.0.0' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "24.0.1" 

defaultConfig { 
    applicationId "example.project" 
    minSdkVersion 16 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 

    apt "org.androidannotations:androidannotations:$AAVersion" 
    compile "org.androidannotations:androidannotations-api:$AAVersion" 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.android.support:design:23.4.0' 
} 
0

Образец - просто build.gradle (app):

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

repositories { 
    mavenCentral() 
} 

apply plugin: 'com.android.application' 
apply plugin: 'android-apt' 
def AAVersion = '4.0.0' 

dependencies { 
    apt "org.androidannotations:androidannotations:$AAVersion" 
    compile "org.androidannotations:androidannotations:$AAVersion" 
    compile fileTree(dir: 'libs', include: '*.jar') 
    // other dependencies 
} 

apt { 
    arguments { 
    androidManifestFile variant.outputs[0].processResources.manifestFile 
    resourcePackageName 'myfull.packagename' 
    } 
} 

android { 
    compileSdkVersion 24 
    buildToolsVersion '24.0.0' 
    defaultConfig { 
    minSdkVersion 16 
    targetSdkVersion 24 
    versionCode 1 
    versionName '1' 
    multiDexEnabled true 
    } 
    sourceSets { 
    main { 
     manifest.srcFile 'src/main/AndroidManifest.xml' 
     java.srcDirs = ['src/main/java', 'build/generated/source/apt/${variant.dirName}'] 
     resources.srcDirs = ['src/main/res'] 
     res.srcDirs = ['src/main/res'] 
     assets.srcDirs = ['src/main/assets'] 
    } 
    } 
    packagingOptions { 
    exclude 'META-INF/DEPENDENCIES.txt' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/NOTICE.txt' 
    exclude 'META-INF/NOTICE' 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/notice.txt' 
    exclude 'META-INF/license.txt' 
    exclude 'META-INF/dependencies.txt' 
    exclude 'META-INF/LGPL2.1' 
    } 
    productFlavors {} 
    dexOptions { 
    javaMaxHeapSize "4g" 
    } 
}