Search in sources :

Example 1 with RClassNotFoundException

use of org.androidannotations.internal.exception.RClassNotFoundException in project androidannotations by androidannotations.

the class AndroidRClassFinder method find.

public IRClass find() throws RClassNotFoundException {
    Elements elementUtils = processingEnv.getElementUtils();
    TypeElement androidRType = elementUtils.getTypeElement("android.R");
    if (androidRType == null) {
        LOGGER.error("The android.R class cannot be found");
        throw new RClassNotFoundException("The android.R class cannot be found");
    }
    LOGGER.info("Found Android class: {}", androidRType.toString());
    return new RClass(androidRType);
}
Also used : RClassNotFoundException(org.androidannotations.internal.exception.RClassNotFoundException) TypeElement(javax.lang.model.element.TypeElement) IRClass(org.androidannotations.rclass.IRClass) Elements(javax.lang.model.util.Elements)

Example 2 with RClassNotFoundException

use of org.androidannotations.internal.exception.RClassNotFoundException in project androidannotations by androidannotations.

the class ProjectRClassFinder method find.

public IRClass find(AndroidManifest manifest) throws RClassNotFoundException {
    Elements elementUtils = environment.getProcessingEnvironment().getElementUtils();
    String rClass = getRClassPackageName(manifest) + ".R";
    TypeElement rType = elementUtils.getTypeElement(rClass);
    if (rType == null) {
        LOGGER.error("The generated {} class cannot be found", rClass);
        throw new RClassNotFoundException("The generated " + rClass + " class cannot be found");
    }
    LOGGER.info("Found project R class: {}", rType.toString());
    return new RClass(rType);
}
Also used : RClassNotFoundException(org.androidannotations.internal.exception.RClassNotFoundException) TypeElement(javax.lang.model.element.TypeElement) IRClass(org.androidannotations.rclass.IRClass) Elements(javax.lang.model.util.Elements)

Aggregations

TypeElement (javax.lang.model.element.TypeElement)2 Elements (javax.lang.model.util.Elements)2 RClassNotFoundException (org.androidannotations.internal.exception.RClassNotFoundException)2 IRClass (org.androidannotations.rclass.IRClass)2