使用crashytics添加产品风味时,android-gradle失败

时间:2014-09-15 14:49:42

标签: android groovy gradle android-studio crashlytics

我是Gradle的新手,特别是产品口味

我有一个带有SDK库和TestApp的android项目。我的客户将集成SDK库aar文件,我们开发了一个TestApp用于测试,它也使用这个SDK库。

我们最近搬到gradle,运行良好,最近我们包括crashlytics,我修改了我的build.gradle也支持crashlytics。 但是现在我尝试包含产品风格以使用相同的src但不同的res和assets文件夹。

但是,当我是产品风味的建设者时,我收到以下错误

19:41:39.615 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: groovy.lang.MissingPropertyException: No such property: ext for class: com.android.builder.DefaultProductFlavor
19:41:39.616 [ERROR] [org.gradle.BuildExceptionReporter]    at com.crashlytics.tools.gradle.CrashlyticsPlugin.isCrashlyticsEnabled(CrashlyticsPlugin.groovy:126)
19:41:39.616 [ERROR] [org.gradle.BuildExceptionReporter]    at com.crashlytics.tools.gradle.CrashlyticsPlugin.this$2$isCrashlyticsEnabled(CrashlyticsPlugin.groovy)
19:41:39.617 [ERROR] [org.gradle.BuildExceptionReporter]    at com.crashlytics.tools.gradle.CrashlyticsPlugin$_apply_closure1_closure5.doCall(CrashlyticsPlugin.groovy:89)
19:41:39.618 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)
19:41:39.618 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)
19:41:39.619 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:164)
19:41:39.620 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:159)

以下是我的构建

apply plugin: 'android-library'
apply plugin: 'maven'
apply plugin: 'crashlytics'
buildscript {
   repositories {
      mavenCentral()
      maven { url 'http://download.crashlytics.com/maven' }
   }
   dependencies {
      classpath 'com.android.tools.build:gradle:0.9.+'
      classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
   }
}
version = System.getProperty("sdkVersion", "")
group = System.getProperty("sdkGroup", "")
repositoryPath = System.getProperty("sdkRepositoryPath")
archivesBaseName = 'MyAndroidSDK'
repositories {
   mavenCentral()
   maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
   compile ('com.google.android.gms:play-services:4.0.30') {
      exclude module: 'support-v4'
   }
   compile 'com.android.support:appcompat-v7:19.0.1'
   compile 'com.crashlytics.android:crashlytics:1.+'
   compile files('libs/libphonenumber-5.9.jar')
   compile files('libs/libGoogleAnalyticsServices.jar')
}

android {
   buildToolsVersion "19.0.1"
   compileSdkVersion 19
   defaultConfig {
      minSdkVersion 9
   }
   lintOptions {
      abortOnError false
   }
   productFlavors {
      flavor1 {
         packageName "com.flavors.flavors1"
         buildConfigField "boolean", "USE_CRASHLYTICS", "true"
         ext.enableCrashlytics = true
      }
      flavor2 {
         packageName "com.flavors.flavors2"
         buildConfigField "boolean", "USE_CRASHLYTICS", "true"
         ext.enableCrashlytics = true
      }
   }
   sourceSets {
      main {
         manifest.srcFile 'AndroidManifest.xml'
         java.srcDirs = ['src']
         resources.srcDirs = ['src']
         aidl.srcDirs = ['src']
         renderscript.srcDirs = ['src']
         res.srcDirs = ['res']
         assets.srcDirs = ['assets']
      }
      sourceSets.flavor1 {
         res.srcDirs = ['flavor1/res']
         assets.srcDirs = ['flavor1/assets']
      }
      sourceSets.flavor2 {
         res.srcDirs = ['flavor2/res']
         assets.srcDirs = ['flavor2/assets']
      }
      instrumentTest.setRoot('tests')
   }
}

0 个答案:

没有答案