相关疑难解决方法(0)

Android Gradle 1.0计算多风味设置中的版本代码

计算不同产品风格的版本代码的代码不再适用于Android Gradle 1.0系统.我成功之前使用了下面的示例代码.

http://tools.android.com/tech-docs/new-build-system/tips#TOC-Computing-Version-code-in-multi-flavor-setup.

productFlavors.get(0).versionCode现在计算为null.

Gradle代码..

android {

  buildscript {
    repositories {
      mavenCentral()
    }
    dependencies {
      classpath 'com.android.tools.build:gradle:1.0.0'
    }
  }

  // This actual the app version code. Our given range is [0, 99999]
  defaultConfig.versionCode = 123

  // 2 dimensions of flavors. API is more important than ABI.
  flavorGroups "api", "abi"

  productFlavors {
    gingerbread {
      flavorGroup "api"
      minSdkVersion 10
      versionCode = 1
    }
    icecreamSandwich {
      flavorGroup "api"
      minSdkVersion 14
      // this must be higher than the gingerbread version to ensure …
Run Code Online (Sandbox Code Playgroud)

android android-gradle-plugin

5
推荐指数
1
解决办法
4910
查看次数

Gradle交换jniLibs资源基于构建风格

我试图根据它的a 或a 来交换res/raw文件夹和jniLibs/armeabi文件夹中的一些资源.我目前也有两种产品口味.release buildTypedebug buildType

build.gradle文件:

apply plugin: 'com.android.application'

android {
    dexOptions {
        preDexLibraries = false
    }

    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.test"
        minSdkVersion 17
        targetSdkVersion 22
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    productFlavors{
        phone{
            applicationId "com.example.testPhone"
        }
        tablet{
            applicationId "com.example.testTablet"
        }
    }

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

    sourceSets{
        release{
            res.srcDirs = ['androidRelease/res/raw']
        }
    }
}

dependencies {
    compile project(':facebook')

}
Run Code Online (Sandbox Code Playgroud)

是用sourceSet正确的方法吗?如果是,应该创建什么文件夹,以便它根据 …

android gradle android-gradle-plugin

5
推荐指数
1
解决办法
4448
查看次数

标签 统计

android ×2

android-gradle-plugin ×2

gradle ×1