Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android wear项目具有3种风格、3种构建类型和2个应用程序补丁_Android_Build.gradle_Wear Os_Android Productflavors_Android Build Type - Fatal编程技术网

Android wear项目具有3种风格、3种构建类型和2个应用程序补丁

Android wear项目具有3种风格、3种构建类型和2个应用程序补丁,android,build.gradle,wear-os,android-productflavors,android-build-type,Android,Build.gradle,Wear Os,Android Productflavors,Android Build Type,在尝试将wearApp风格和构建类型与ApplicationIDSuffix组合后构建项目时,我收到以下错误消息: Error:Execution failed for task ':app:handleFirstCustomerTestMicroApk'. > The main and the micro apps do not have the same package name. 从我的应用程序/build.gradle: buildTypes { debug {

在尝试将wearApp风格和构建类型与ApplicationIDSuffix组合后构建项目时,我收到以下错误消息:

Error:Execution failed for task ':app:handleFirstCustomerTestMicroApk'.
> The main and the micro apps do not have the same package name.
从我的应用程序/build.gradle:

buildTypes {
    debug {
        applicationIdSuffix '.debug'
        debuggable true
        embedMicroApp = true
    }
    customerTest {
        applicationIdSuffix '.customertest'
        debuggable true
        embedMicroApp = true
    }
    release {
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        minifyEnabled true
        embedMicroApp = true
    }
}

productFlavors {
    first {
        applicationId 'com.my.app.first'
    }
    second {
        applicationId 'com.my.app.second'
    }
    third {
        applicationId 'com.my.app.third'
    }
}

dependencies {
    firstWearApp project(path: ':wear', configuration: 'firstDebug')
    firstWearApp project(path: ':wear', configuration: 'firstCustomerTest')
    firstWearApp project(path: ':wear', configuration: 'firstRelease')

    secondWearApp project(path: ':wear', configuration: 'secondDebug')
    secondWearApp project(path: ':wear', configuration: 'secondCustomerTest')
    secondWearApp project(path: ':wear', configuration: 'secondRelease')

    thirdWearApp project(path: ':wear', configuration: 'thirdDebug')
    thirdWearApp project(path: ':wear', configuration: 'thirdCustomerTest')
    thirdWearApp project(path: ':wear', configuration: 'thirdRelease')
}
buildTypes {
    debug {
        applicationIdSuffix '.debug'
        minifyEnabled false
    }
    customerTest {
        applicationIdSuffix '.customertest'
        minifyEnabled false
    }
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
    first {
        applicationId 'com.my.app.first'
    }
    second {
        applicationId 'com.my.app.second'
    }
    third {
        applicationId 'com.my.app.third'
    }
}

android {
    publishNonDefault true
}
从my wear/build.gradle:

buildTypes {
    debug {
        applicationIdSuffix '.debug'
        debuggable true
        embedMicroApp = true
    }
    customerTest {
        applicationIdSuffix '.customertest'
        debuggable true
        embedMicroApp = true
    }
    release {
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        minifyEnabled true
        embedMicroApp = true
    }
}

productFlavors {
    first {
        applicationId 'com.my.app.first'
    }
    second {
        applicationId 'com.my.app.second'
    }
    third {
        applicationId 'com.my.app.third'
    }
}

dependencies {
    firstWearApp project(path: ':wear', configuration: 'firstDebug')
    firstWearApp project(path: ':wear', configuration: 'firstCustomerTest')
    firstWearApp project(path: ':wear', configuration: 'firstRelease')

    secondWearApp project(path: ':wear', configuration: 'secondDebug')
    secondWearApp project(path: ':wear', configuration: 'secondCustomerTest')
    secondWearApp project(path: ':wear', configuration: 'secondRelease')

    thirdWearApp project(path: ':wear', configuration: 'thirdDebug')
    thirdWearApp project(path: ':wear', configuration: 'thirdCustomerTest')
    thirdWearApp project(path: ':wear', configuration: 'thirdRelease')
}
buildTypes {
    debug {
        applicationIdSuffix '.debug'
        minifyEnabled false
    }
    customerTest {
        applicationIdSuffix '.customertest'
        minifyEnabled false
    }
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
    first {
        applicationId 'com.my.app.first'
    }
    second {
        applicationId 'com.my.app.second'
    }
    third {
        applicationId 'com.my.app.third'
    }
}

android {
    publishNonDefault true
}
从这些信息中我知道,
WearApp
是可能的,但我真正需要的是
WearApp
(目前似乎不可能):

如果我删除了ApplicationIDSuffix,那么保持上述9个wearApp依赖项都会起作用,但不管我在Android Studio中选择哪种构建类型,它仍然会为每个构建类型构建一个wear apk,而且我真的需要ApplicationIDSuffix

有人有解决办法吗?从今天起,每当我需要更改构建类型和/或风格时,我都会手动添加和删除wearApp依赖项,从长远来看,这并不是一个让我感到舒服的解决方案

编辑:一开始我没有注意到这一点,但出于某种原因,firstDebug、secondDebug和thirdDebug版本在build.gradle中的所有9个wearApp依赖项都很好。但firstCustomerTest、firstRelease、secondCustomerTest、secondRelease、thirdCustomerTest和thirdRelease的错误消息保持不变。所有变体每次编译9个wearApps,将其精简为1个。

根据

试试这个

configurations {
    firstDebugWearApp
    firstCustomerTestWearApp
    firstReleaseWearApp
    secondDebugWearApp
 ...//  And all the others
}
  dependencies {
        firstDebugWearApp project(path: ':wear', configuration: 'firstDebug')
        firstCustomerTestWearApp project(path: ':wear', configuration: 'firstCustomerTest')
        firstReleaseWearApp project(path: ':wear', configuration: 'firstRelease')

        secondDebugWearApp project(path: ':wear', configuration: 'secondDebug')
        secondCustomerTestWearApp project(path: ':wear', configuration: 'secondCustomerTest')
        secondReleaseWearApp project(path: ':wear', configuration: 'secondRelease')

        thirdDebugWearApp project(path: ':wear', configuration: 'thirdDebug')
        thirdCustomerTestWearApp project(path: ':wear', configuration: 'thirdCustomerTest')
        thirdReleaseWearApp project(path: ':wear', configuration: 'thirdRelease')
    }

谢谢,“配置”是丢失的链接!它仍然会在每个构建上构建所有这些,但重要的是它正在工作。与您的问题无关:在buildTypes customerTest中定义“initwith debug”,这样您的自定义构建类型将自动使用“debug”中的所有设置。现在,您只需要定义“applicationIdSuffix”:与“debug”相比,唯一不同的是请参阅dev.android.com以获取参考:。。。我知道这在你的情况下不是非常有用,但我还是想指出可能性。