Android Studio: Use AndroidAnnotations

后端 未结 6 762
梦毁少年i
梦毁少年i 2020-12-28 18:12

So I wanted to try the new Android Studio and imported my eclipse projects (I generated a gradle build file). Worked pretty good.

The only library which does not see

6条回答
  •  长情又很酷
    2020-12-28 18:44

    This is what works for me:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.5.+'
        }
    }
    
    apply plugin: 'android'
    
    configurations {
        apt
    }
    
    repositories {
        mavenRepo url: 'https://oss.sonatype.org/content/repositories/snapshots/'
    }
    
    ext.androidAnnotationsVersion = '3.0-SNAPSHOT';
    
    dependencies {
        compile 'com.android.support:support-v4:18.0.+'
    
        apt "org.androidannotations:androidannotations:$ext.androidAnnotationsVersion"
        compile "org.androidannotations:androidannotations-api:$ext.androidAnnotationsVersion"
    }
    
    android {
        compileSdkVersion 18
        buildToolsVersion "17.0.0"
    
        defaultConfig {
            minSdkVersion 7
            targetSdkVersion 18
        }
    }
    
    android.applicationVariants.all { variant ->
        ext.aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}")
        ext.aptOutput.mkdirs()
    
        variant.javaCompile.options.compilerArgs += [
                '-processorpath', configurations.apt.asPath,
                '-AandroidManifestFile=' + variant.processResources.manifestFile,
                '-s', ext.aptOutput
        ]
    }
    

    After that I need to mark build/sources/apt-generated/debug as source in Android Studio by right clicking it and selecting Mark Directory as > Source Root

提交回复
热议问题