AndroidAnnotations + Android Studio - Generated class null.R not found

I have ActiveAndroid installed according to wiki instructions using the latest version of AndroidStudio. I am using Flavors product. This is my gradle build file:

apply plugin: 'android'
apply plugin: 'android-apt'

apt {
    arguments {
        androidManifestFile variant.processResources.manifestFile
        resourcePackageName android.defaultConfig.packageName
    }
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    productFlavors {
        a {
            packageName "com.a.a"
        }

        b {
            packageName "com.a.b"
        }

        c {
            packageName "com.a.c"
        }
    }
}

dependencies {
    apt "org.androidannotations:androidannotations:3.0+"
    compile "org.androidannotations:androidannotations-api:3.0+"
    compile 'com.android.support:support-v4:19.0.1'
    compile 'com.android.support:appcompat-v7:19.0.1'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

Gradle to create files, but when I compile / go to debug on the device, I get two errors:

Error :: Generated class null.R not found

and

Error: execution completed for task ': ml: compileADebugJava'.

Compilation error; see compiler error output for details.

I tried a lot of settings for my build file, but could not get it to work for life. Also when I try to change my AndroidManifest using

Android: name = "com.aaMainActivity"

to

Android: name= "com.a.a.MainActivity _"

, .

gradle ActiveAndroid.

.

+4
6
android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.your.app"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}



apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        resourcePackageName android.defaultConfig.applicationId
    }
}

.

+4

, :

resourcePackageName android.defaultConfig.packageName

.

+3

, packageName defaultConfig:

:

defaultConfig {
    packageName "com.example.myapp"
    minSdkVersion 8
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}

com.example.myapp , AndroidManifest.xml.

, .

+3
apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        resourcePackageName android.defaultConfig.applicationId
    }

.

+2

, -.

, applicationId. script , "android.defaultConfig.applicationId". null, , , null.R. , :

defaultConfig {

    // Rest of Config

    javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["resourcePackageName": "<Original Package Name>"]
            }
    }
}

, R .

, !

+2

applicationId == . 100% .

0

Source: https://habr.com/ru/post/1533937/


All Articles