reixa
reixa

Reputation: 7011

Android - The package conflicts with an existing package by the same name

I´ve this default config on Gradle.

defaultConfig {
    applicationId "com.my.application"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 190011
    versionName "2.2.1"
}

And those flavors

productFlavors {
    dev {
        applicationIdSuffix ".dev"
        versionCode 333333
        buildConfigField "String", "ANVIL_BASE_URL", "DEBUG_URL"
        resValue "string", "app_name", "app name dev"
        signingConfig signingConfigs.releasesign
    }
    prod {
        buildConfigField "String", "ANVIL_BASE_URL", "PROD_URL"
        resValue "string", "app_name", "app name"
        signingConfig signingConfigs.releasesign
    }
}

I´ve got the app released on the Play Store with the default application id "com.my.application" but when I´ve the Play Store version installed and want to install the "dev" flavored application it pop a message that says this:

app name dev 
App not installed
The package conflicts with an existing package by the same name

Am I doing something wrong? I´ve tried changing the buildCode for dev but that didn't work either.

Any guess?

Thanks in advance.

Upvotes: 8

Views: 3101

Answers (3)

Qian Sijianhao
Qian Sijianhao

Reputation: 564

You've installed an application on your phone with same package name.Reinstall int before you install this one.

Upvotes: 0

reixa
reixa

Reputation: 7011

Well, while trying to install a modified version of the app through command line I found the following error:

adb install ~/Desktop/app-dev-release.apk
Failed to install /Users/axier/Desktop/app-dev-release.apk: Failure [INSTALL_FAILED_DUPLICATE_PERMISSION: Package com.my.application.dev attempting to redeclare permission com.my.application.permission.C2D_MESSAGE already owned by com.my.application]

So I´ve modified my AndroidManifest.xml file like this:

<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />

Pretty poor error description for this one. Hope the solution works for someone like me in the future.

Thanks anyway.

Upvotes: 5

Bernd Kampl
Bernd Kampl

Reputation: 6299

You should have a look at the gradle documentation (ApplicationId versus PackageName). Also, have you really released the version on the play store with the package name "com.my.application"? My suggestion to your problem would be to put the applicationId into the productFlavors. Also take a look at this stackoverflow answer, which basically answers your question as well.

Upvotes: 1

Related Questions