3

This is my build.gradle

apply plugin: 'com.android.library'
apply plugin: 'android-apt'
def AAVersion = '4.2.0'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        debug {
            minifyEnabled false
            buildConfigField "String", "API_BASE_URL", '"http://artemis.apolotechnologies.com:8080"'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "String", "API_BASE_URL", '"http://artemis.apolotechnologies.com:8080"'
        }
    }
    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'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:recyclerview-v7:25.1.0'
    testCompile 'junit:junit:4.12'

    compile 'com.squareup.retrofit2:retrofit:2.2.0-SNAPSHOT'
    compile 'io.reactivex.rxjava2:rxjava:2.0.4'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'com.squareup.retrofit2:converter-jackson:2.2.0-SNAPSHOT'
    compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0-SNAPSHOT'
    compile 'com.squareup.retrofit2:retrofit-mock:2.2.0-SNAPSHOT'

    compile 'com.orhanobut:logger:1.15'
    compile 'com.afollestad:sectioned-recyclerview:0.2.3'
    compile group: 'com.googlecode.libphonenumber', name: 'libphonenumber', version: '8.0.0'
    apt "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"
    compile 'org.parceler:parceler-api:1.1.6'
    apt 'org.parceler:parceler:1.1.6'
}

apt {
    arguments {
        library 'true'
        logLevel 'trace'
        logAppenderConsole 'true'
        resourcePackageName "com.apolotechnologies.appolocommon"
        androidManifestFile variant.outputs[0]?.processResources?.manifestFile
    }
}

class are in build/generated/source/apt/release but generated class are not appearing in android studio and I can't use them, project is a library that I'm using into another project I trying adding:

sourceSets {
    apt{
        java{
            srcDir 'build/generated/source/apt/release'
        }
    }
}

with no luck

this is my androidannotations.log

18:28:44.389 [Daemon worker Thread 63] INFO  o.a.i.AndroidAnnotationProcessor:88 - Initialize AndroidAnnotations 4.2.0 with options {library=true, logLevel=trace, resourcePackageName=com.apolotechnologies.appolocommon, androidManifestFile=/Users/cristiangomez/dev/apolo/android/appolo-android-rider/appolo-android-common/build/intermediates/manifests/aapt/release/AndroidManifest.xml}
18:28:44.405 [Daemon worker Thread 63] INFO  o.a.i.AndroidAnnotationProcessor:108 - Plugins loaded: []
18:28:45.8 [Daemon worker Thread 63] TRACE o.a.i.AndroidAnnotationProcessor:119 - Start processing for 7 annotations [org.androidannotations.annotations.AfterViews, org.androidannotations.annotations.EActivity, org.androidannotations.annotations.EFragment, org.androidannotations.annotations.ViewById, org.androidannotations.annotations.res.StringRes, org.androidannotations.annotations.InstanceState, org.androidannotations.annotations.Click] on 39 elements [com.apolotechnologies.appolocommon.activity.adapter.CountryAdapter, com.apolotechnologies.appolocommon.activity.CountryPickerActivity, com.apolotechnologies.appolocommon.activity.fragment.CountryPickerFragment, com.apolotechnologies.appolocommon.activity.fragment.EmailInputFragment, com.apolotechnologies.appolocommon.activity.fragment.NameInputFragment, com.apolotechnologies.appolocommon.activity.fragment.PasswordInputFragment, com.apolotechnologies.appolocommon.activity.fragment.PhoneConfirmationCodeFragment, com.apolotechnologies.appolocommon.activity.fragment.PhoneInputFragment, com.apolotechnologies.appolocommon.activity.fragment.PhoneNumberFragment, com.apolotechnologies.appolocommon.activity.RegisterActivity, com.apolotechnologies.appolocommon.activity.transition.PhoneInputTransition, com.apolotechnologies.appolocommon.Appolo, com.apolotechnologies.appolocommon.interactor.RegisterInteractor, com.apolotechnologies.appolocommon.interactor.retrofit.RegisterInteractorImpl, com.apolotechnologies.appolocommon.model.Country, com.apolotechnologies.appolocommon.model.CountrySection, com.apolotechnologies.appolocommon.model.Section, com.apolotechnologies.appolocommon.model.User, com.apolotechnologies.appolocommon.network.ApiService, com.apolotechnologies.appolocommon.network.ApiServiceFactory, com.apolotechnologies.appolocommon.network.pojo.BaseResponse, com.apolotechnologies.appolocommon.network.pojo.UserResponse, com.apolotechnologies.appolocommon.service.ConfirmationCodeTimerBroadcastService, com.apolotechnologies.appolocommon.Util, android.support.compat.R, android.support.coreui.R, android.support.coreutils.R, android.support.fragment.R, android.support.graphics.drawable.animated.R, android.support.graphics.drawable.R, android.support.mediacompat.R, android.support.v4.R, android.support.v7.appcompat.R, android.support.v7.recyclerview.R, com.afollestad.sectionedrecyclerview.R, com.apolotechnologies.appolocommon.R, com.orhanobut.logger.R, io.reactivex.android.R, com.apolotechnologies.appolocommon.BuildConfig]
18:28:45.23 [Daemon worker Thread 63] DEBUG o.a.i.h.AndroidManifestFinder:114 - AndroidManifest.xml file found with specified path: /Users/cristiangomez/dev/apolo/android/appolo-android-rider/appolo-android-common/build/intermediates/manifests/aapt/release/AndroidManifest.xml
18:28:45.35 [Daemon worker Thread 63] INFO  o.a.i.AndroidAnnotationProcessor:164 - AndroidManifest.xml found: AndroidManifest [applicationPackage=com.apolotechnologies.appolocommon, componentQualifiedNames=[], metaDataQualifiedNames={}, permissionQualifiedNames=[], applicationClassName=, libraryProject=true, debugabble=false, minSdkVersion=15, maxSdkVersion=-1, targetSdkVersion=25]
18:28:45.38 [Daemon worker Thread 63] INFO  o.a.i.r.ProjectRClassFinder:51 - Found project R class: com.apolotechnologies.appolocommon.R
18:28:45.51 [Daemon worker Thread 63] INFO  o.a.i.r.AndroidRClassFinder:45 - Found Android class: android.R
18:28:45.69 [Daemon worker Thread 63] INFO  o.a.i.p.ModelValidator:46 - Validating elements
18:28:45.70 [Daemon worker Thread 63] DEBUG o.a.i.p.ModelValidator:69 - Validating with EActivityHandler: [com.apolotechnologies.appolocommon.activity.RegisterActivity]
18:28:45.86 [Daemon worker Thread 63] DEBUG o.a.i.p.ModelValidator:69 - Validating with EFragmentHandler: [com.apolotechnologies.appolocommon.activity.fragment.PhoneInputFragment]
18:28:45.90 [Daemon worker Thread 63] DEBUG o.a.i.p.ModelValidator:69 - Validating with ViewByIdHandler: [countryFlagImageView, countryCallingCodeTextView, phoneInputEditText, toolbar]
18:28:45.98 [Daemon worker Thread 63] DEBUG o.a.i.p.ModelValidator:69 - Validating with ClickHandler: [onNext(), onCountrySelect()]
18:28:45.106 [Daemon worker Thread 63] DEBUG o.a.i.p.ModelValidator:69 - Validating with DefaultResHandler: [userType]
18:28:45.109 [Daemon worker Thread 63] DEBUG o.a.i.p.ModelValidator:69 - Validating with InstanceStateHandler: [selectedCountry, phoneNumber, email, firstName, lastName, password, confirmationCode]
18:28:45.119 [Daemon worker Thread 63] DEBUG o.a.i.p.ModelValidator:69 - Validating with AfterViewsHandler: [initViews(), initViews()]
18:28:45.148 [Daemon worker Thread 63] INFO  o.a.i.p.ModelProcessor:67 - Processing root elements
18:28:45.149 [Daemon worker Thread 63] DEBUG o.a.i.p.ModelProcessor:180 - Processing root elements EActivityHandler: [com.apolotechnologies.appolocommon.activity.RegisterActivity]
18:28:45.233 [Daemon worker Thread 63] DEBUG o.a.i.p.ModelProcessor:180 - Processing root elements EFragmentHandler: [com.apolotechnologies.appolocommon.activity.fragment.PhoneInputFragment]
18:28:45.240 [Daemon worker Thread 63] INFO  o.a.i.p.ModelProcessor:79 - Processing enclosed elements
18:28:45.270 [Daemon worker Thread 63] INFO  o.a.i.AndroidAnnotationProcessor:231 - Number of files generated by AndroidAnnotations: 2
18:28:45.271 [Daemon worker Thread 63] DEBUG o.a.i.g.SourceCodeWriter:57 - Generating class: com.apolotechnologies.appolocommon.activity.fragment.PhoneInputFragment_
18:28:45.313 [Daemon worker Thread 63] DEBUG o.a.i.g.SourceCodeWriter:57 - Generating class: com.apolotechnologies.appolocommon.activity.RegisterActivity_
18:28:45.348 [Daemon worker Thread 63] INFO  o.a.i.p.TimeStats:81 - Time measurements: [Whole Processing = 340 ms], [Process Annotations = 150 ms], [Generate Sources = 77 ms], [Validate Annotations = 52 ms], [Find R Classes = 31 ms], [Extract Manifest = 12 ms], [Extract Annotations = 3 ms], 
18:28:45.348 [Daemon worker Thread 63] INFO  o.a.i.AndroidAnnotationProcessor:137 - Finish processing

This is my project (the one using the library) build.gradle

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


android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "com.apolotechnologies.appolorider"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    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'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    testCompile 'junit:junit:4.12'
    apt "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"
    compile 'org.parceler:parceler-api:1.1.6'
    apt 'org.parceler:parceler:1.1.6'
    compile project(":appolo-android-common")
}

and this is my main build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0-beta2'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven {url "https://oss.sonatype.org/content/repositories/snapshots/"}
        maven {url "https://clojars.org/repo/"}
        mavenLocal()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Chris Gomez
  • 6,644
  • 4
  • 18
  • 39
  • 1
    Even is the library project has the annotation processors included in its dependencies, the project that depends on this library also needs to include them explicitly in its dependencies - it doesn't see the annotation processor as a transient dependency when compiling. – Mark Jan 12 '17 at 01:19
  • I have it on my project, added the project build.gradle source code to the question. – Chris Gomez Jan 12 '17 at 01:24
  • 1
    The `apt` plugins are different between projects? – Mark Jan 12 '17 at 01:33
  • I changed booth to be apply plugin: 'com.neenbedankt.android-apt' but still can't see the generated files – Chris Gomez Jan 12 '17 at 01:35
  • 1
    try using `classpath 'com.android.tools.build:gradle:2.2.3'` instead of `classpath 'com.android.tools.build:gradle:2.3.0-beta2'` – Mark Jan 12 '17 at 01:40
  • changed it to classpath 'com.android.tools.build:gradle:2.2.3' but nothing changed. – Chris Gomez Jan 12 '17 at 01:48
  • 1
    you could migrate to the new annotationProcessor : As of android gradle plugin 2.2.0 it is now possible to use annotation processors without any additional plugins. The creator android-apt is even recommending the migration. See link: bitbucket.org/hvisser/android-apt/wiki/Migration – Mark Jan 12 '17 at 01:51
  • tried it but still, files are generated but I can't use then. – Chris Gomez Jan 12 '17 at 02:11
  • https://bitbucket.org/hvisser/android-apt/issues/72/generated-source-not-found-by-android seems similar to this problem – Chris Gomez Jan 12 '17 at 02:12
  • 1
    Hmm .. tried a clean, invalidate caches / restart and then build? Just to rule out any cluttered files ... If they are generated then that means it's worked, why can't you use them? – Mark Jan 12 '17 at 02:14
  • Did that and I still don't see the files but I can use then and I have intellisense now, thanks you. – Chris Gomez Jan 12 '17 at 02:30
  • The project seems to be correct. According to the log, the files are indeed generated. Are you sure they do not exist. Search for the generated file names recursively from the project root folder. – WonderCsabo Jan 12 '17 at 09:03

0 Answers0