Android Studio 1.5.1,Gradle 2.8,带移动和穿戴/免费/付费口味

问题描述 投票:0回答:1

我不知所措。使用AS 1.5.1和Gradle 2.8,我有移动和磨损模块。当我选择移动设备的调试版本并佩戴风味时,我理解我必须手动编译/运行每个设备才能使用它们各自的设备。这没有问题:调试/运行应用程序/等。

但是,对于移动和磨损版本的发布,当我没有在我的mobile / wear build.gradle文件中创建了signedConfigs部分时,AS会提示我这样做,带有一个对话框,并在其底部有“修复“按钮。我首先使用keyAlias,keyPassword,storeFile和storePassword添加我的wear模块。通过这个相同的对话框,我然后选择一个且唯一的buildType版本来签署signedConfig。当我在该对话框上单击“确定”时,上一个对话框的底部有一些措辞,其中FIX按钮曾经是仍存在gradle错误。我使用移动gradle文件执行相同的步骤,并且它在对话框中也指出仍存在gradle错误。 Release中的磨损结果构建/运行不会创建android_wear_micro_apk.apk以将其包含在移动版本中。当移动模块构建时,它没有任何磨损apk。我的整个应用程序(移动/穿戴)最初是一组Eclipse项目(曾在Play商店中工作过),我已经手工合并到AS中。

我尝试用手机和磨损创建一个全新的AS项目。当我去运行发布时,它也促使我创建了签名概念。但是,在磨损编译期间会创建android_wear_micro_apk.apk。此外,移动应用程序包含wear的apk。移动调试和发布APK都是不同的大小,第一版更大。我知道“android_wear_micro_apk.apk”文件的唯一方法是因为这个新的/剥离测试项目 - 否则,我原来没有胶水。

这是移动build.gradle

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {
    signingConfigs {
        the_pro_mobile_config {
            keyAlias 'MY_ALIAS_PRO'
            keyPassword 'MY_PASSWORD_PRO'
            storeFile file('my_keystore_pro.keystore')
            storePassword 'MY_STORE_PASSWORD_PRO'
        }
        the_free_mobile_config {
            keyAlias 'MY_ALIAS_FREE'
            keyPassword 'MY_PASSWORD_FREE'
            storeFile file('my_keystore_free.keystore')
            storePassword 'MY_STORE_PASSWORD_FREE'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    packagingOptions {
        exclude 'META-INF'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES/httpcore-4.0.jar'
        exclude 'META-INF/DEPENDENCIES/httpclient-4.3.6.jar'
    }
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 25
        versionName "2.0.0"

        multiDexEnabled = true
    }
    buildTypes {

        release {

            debuggable false
            jniDebuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-project.txt'), 'proguard-rules.pro'
            zipAlignEnabled true

        }

    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    productFlavors {
        free {
            applicationId "com.my_app.thefree"
            signingConfig signingConfigs.the_free_mobile_config
        }
        pro {
            applicationId "com.my_app.thepro"
            signingConfig signingConfigs.the_pro_mobile_config
        }
    }
}

dependencies {

    wearApp project(':wear')

    compile project(':my_license_module')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:support-annotations:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:palette-v7:23.1.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.android.gms:play-services-wearable:8.4.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'commons-io:commons-io:2.4'
    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'com.google.android.gms:play-services-identity:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
}

这是wear build.gradle

apply plugin: 'com.android.application'

repositories {
    mavenCentral()
}

android {

    signingConfigs {
        the_wearable_config {
            keyAlias 'MY_ALIAS'
            keyPassword 'MY_KEYPASSWORD'
            storeFile file('my_keystore_wearable.keystore')
            storePassword 'MY_STORE_PASSWORD'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 25
        versionName "2.0.0"

        multiDexEnabled = true
    }
    buildTypes {
        release {
            debuggable false
            jniDebuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-project.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            signingConfig signingConfigs.the_wearable_config
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    productFlavors {
        free {
            applicationId "com.myapp.my_free_app"
        }
        pro {
            applicationId "com.myapp.my_pro_app"
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.support:wearable:1.3.0'
    compile 'com.google.android.gms:play-services:8.3.0'
}
android gradle wear-os android-flavors
1个回答
0
投票

我解决了这个问题。还有其他关于同样问题的帖子,这就是我找到它们的地方。

首先添加磨损gradle文件,添加

publishNonDefault true

在文件的“android {”部分。

更改的内容适用于移动gradle文件。

其次,删除“wearApp项目(':wear')”并替换这两者

freeWearApp project(path:':wear', configuration: 'freeRelease')

proWearApp project(path:':wear', configuration: 'proRelease')

我正在创建android_wear_micro_apk并添加到移动apk。

我的下一个任务是找出为什么它不会自动安装观看。在做Eclipse / etc时,所有这些都有效。

© www.soinside.com 2019 - 2024. All rights reserved.