在处理产品风格时,main/AndroidManifest.xml中的包名应该是什么?

在处理产品风格时,main/AndroidManifest.xml中的包名应该是什么?,android,xml,build.gradle,android-productflavors,package-name,Android,Xml,Build.gradle,Android Productflavors,Package Name,我的build.gradle中有两种产品风格,如下所示: apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "23.0.2" aaptOptions.setProperty("cruncherEnabled", false) defaultConfig { minSdkVersion 15 target

我的build.gradle中有两种产品风格,如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.2"
    aaptOptions.setProperty("cruncherEnabled", false)

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 16
        applicationId "com.example.app"
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

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

    def final myApplicationId = 'com.example.app'
    def final appName = 'app'

    productFlavors {
        dev {

            resValue "string", "app_name", appName
            resValue "string", "APIURL", "http://prod.example.com/"
        }
        production {

            resValue "string", "app_name", appName
            resValue "string", "APIURL", "http://test.example.com/"
        }
    }
    buildTypes{
        dtest {
            applicationIdSuffix ".dev"
        }
        dprod{

        }
    }
}



dependencies {
    compile()
    few libraries
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app.dev"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">
    <application>
          <activity list.. </activity>
    </application>
</manifest>
我的dev/AndroidManifest.xml如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.2"
    aaptOptions.setProperty("cruncherEnabled", false)

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 16
        applicationId "com.example.app"
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

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

    def final myApplicationId = 'com.example.app'
    def final appName = 'app'

    productFlavors {
        dev {

            resValue "string", "app_name", appName
            resValue "string", "APIURL", "http://prod.example.com/"
        }
        production {

            resValue "string", "app_name", appName
            resValue "string", "APIURL", "http://test.example.com/"
        }
    }
    buildTypes{
        dtest {
            applicationIdSuffix ".dev"
        }
        dprod{

        }
    }
}



dependencies {
    compile()
    few libraries
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app.dev"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">
    <application>
          <activity list.. </activity>
    </application>
</manifest>

我的production/AndroidManifest.xml如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.2"
    aaptOptions.setProperty("cruncherEnabled", false)

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 16
        applicationId "com.example.app"
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

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

    def final myApplicationId = 'com.example.app'
    def final appName = 'app'

    productFlavors {
        dev {

            resValue "string", "app_name", appName
            resValue "string", "APIURL", "http://prod.example.com/"
        }
        production {

            resValue "string", "app_name", appName
            resValue "string", "APIURL", "http://test.example.com/"
        }
    }
    buildTypes{
        dtest {
            applicationIdSuffix ".dev"
        }
        dprod{

        }
    }
}



dependencies {
    compile()
    few libraries
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app.dev"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">
    <application>
          <activity list.. </activity>
    </application>
</manifest>

我的main/AndroidManifest.xml如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.2"
    aaptOptions.setProperty("cruncherEnabled", false)

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 16
        applicationId "com.example.app"
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

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

    def final myApplicationId = 'com.example.app'
    def final appName = 'app'

    productFlavors {
        dev {

            resValue "string", "app_name", appName
            resValue "string", "APIURL", "http://prod.example.com/"
        }
        production {

            resValue "string", "app_name", appName
            resValue "string", "APIURL", "http://test.example.com/"
        }
    }
    buildTypes{
        dtest {
            applicationIdSuffix ".dev"
        }
        dprod{

        }
    }
}



dependencies {
    compile()
    few libraries
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app.dev"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app"
    android:installLocation="auto"
    android:versionCode="3"
    android:versionName="3.1">
    <application>
          <activity list.. </activity>
    </application>
</manifest>


不要在
productFlavors
中设置,而是在
buildTypes

使用

更新

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.2"
    aaptOptions.setProperty("cruncherEnabled", false)

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 16
        applicationId "com.example.app"
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    buildTypes {
        debug{
            applicationIdSuffix ".dev"
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    productFlavors {
        dev {

            resValue "string", "app_name", appName
            resValue "string", "APIURL", "http://prod.example.com/"
        }
        production {

            resValue "string", "app_name", appName
            resValue "string", "APIURL", "http://test.example.com/"
        }
    }
}



dependencies {
    compile()
    few libraries
}

我应该在哪里添加其他API URL?我有两个不同的API URL用于开发和生产版本。让我再次更新ProductFavors完整代码的问题您是否尝试了我的建议?这对我来说非常有效。我的应用程序中有9种口味。它需要APK签名,有没有其他方法开发APK而不只是为了测试而签名?每个APK都要签名。使用默认的自动调试键进行调试。我现在在build variant中获得了8个选项,当我尝试安装dev Debug时,它会被安装,但对于安装production Debug,它说您必须卸载dev Debug。