0

I have an app using Android Annotations and everything is working fine except one thing - you cannot install both flavors on the same device despite the fact that they have different applicationId.

Researching this I came across some problems (that other people had) with annotation processing and flavors, and as I recall this was an issue also here, but we've manage to add following snippet and everything worked.

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

Until the other day we've didn't notice, that we couldn't install two flavors at once on one device. I've tried changing the gradle but every time I've ended up with the same problem or breaking the gradle script.

As I've mentioned, I've tried all things that I could think of and the online search didn't turn up anything useful, so if anybody have any idea I'll appreciate it.

Following there are my build.gradle scripts.


Top level:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.google.gms:google-services:2.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        mavenLocal()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


App module level:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'android-apt'

android {
    signingConfigs {
        config {
            keyAlias 'release'
            keyPassword 'keyPassword'
            storeFile file('../storeFile.jks')
            storePassword 'storePassword'
        }
    }
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    defaultConfig {
        applicationId "some.awsome.app"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        signingConfig signingConfigs.config
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    testOptions {
        unitTests.returnDefaultValues = true
    }
    productFlavors {
        COGNICARE_personal {
            applicationId "some.awsome.app.free"
        }
        COGNICARE_full {
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
}
repositories {
    flatDir {
        dirs 'libs'
    }
    maven { url "https://jitpack.io" }
    mavenCentral()
}

def android_annotations_version = '3.3.2'
def google_libs_version = '23.3.0'
//some lib versions omitted

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    //some aar lib omitted
    testCompile 'junit:junit:4.12'
    compile "com.android.support:appcompat-v7:$google_libs_version"
    apt "org.androidannotations:androidannotations:$android_annotations_version"
    compile "org.androidannotations:androidannotations-api:$android_annotations_version"
    //some libs omitted

    compile 'com.android.support:multidex:1.0.0'
    //some libs omitted
}

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


Thanks in advance for any suggestion. Kudos!

Janki Gadhiya
  • 4,492
  • 2
  • 29
  • 59
  • what is the error you getwhen trying to install? – ligi Jun 10 '16 at 10:09
  • 1
    @ligi `INSTALL FAILED CONFLICTING PROVIDER` – Dejanarchos Jun 10 '16 at 10:18
  • then post your manifest - or better read: http://stackoverflow.com/questions/16267785/install-shows-error-in-console-install-failed-conflicting-provider – ligi Jun 10 '16 at 10:22
  • 1
    @ligi actually I've seen that answer, but convinced that there is no provider declared n the manifest I've pursued elsewhere. now you mentioned it I've double checked it and there it was, so I've posted an answer. thank you for your time – Dejanarchos Jun 10 '16 at 10:32

1 Answers1

0

OK, so thanks to @ligi pointing me to the right track. We have a similar project with a very similar setup and the main difference are the Android Annotation used in one of them, an that has mislead me.

The bottom line is that I've had a provider in the manifest that I wasn't aware of, and the authority conflict did occur at that point.

Thanks for your time. Kudos.