Android Annotations + multiple paths to APT

隐身守侯 提交于 2019-12-23 05:48:14

问题


imagine some proyect like this one that use android-annotations and for this work i have to put this in build.gradle

apt {
    arguments {
        resourcePackageName "com.pandaos.smartconfig"
        androidManifestFile variant.outputs[0].processResources.manifestFile
    }
}

where: resourcePackageName "com.pandaos.smartconfig"

its the path where code its annotated... the config for plugin android-apt

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

I suppose, that plugin "invoke" some task to generate the code that android-annotations create under the hood, but...

Its possible define multiple "packages in the app"?


回答1:


The resourcePackageName comes from the configuration option for AndroidAnnotations as mentioned here:

By default, AndroidAnnotations try to find the R class by extracting application package from AndroidManifest.xml file. But in some cases you may want to specify a custom package to look for the R class. This is why we added resourcePackageName option.

There are two things to note:

  1. The option refers to the Android package name, which does not have to be the same as your java package name.

  2. The R package name can be different from the Android package name you set in AndroidManifest.xml if you use the applicationId option in the Gradle build file.

It's totally fine to have a different java package name in your code. AFAIK this will not influence AndroidAnnotations in any way.

The apt block is provided by the android-apt plugin and allows you to configure any parameter to annotation processors in your project. In this case it configures the parameters that AndroidAnnotations need to do its job. The android-apt plugin serves two purposes in this case: it configures the parameters for the AndroidAnnotations processor, and it will make sure you can reference the sources that are generated by AA in Android Studio.



来源:https://stackoverflow.com/questions/31536234/android-annotations-multiple-paths-to-apt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!