找不到属性'androidTestCompile'

时间:2016-07-31 21:49:15

标签: android gradle

我正在尝试使用firebase控制台向我的应用添加Google登录选项。 所以我已经下载了应用程序样本并且累了运行,然后在遇到各种错误并纠正它们之后我就停留在这一点请帮忙

  

错误:(80,0)无法在org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@39a8aa上找到属性'androidTestCompile'。

这是我的gradle代码:

 apply plugin: 'com.android.application'

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

 allprojects {
repositories {
    jcenter()
}
}

android {
compileSdkVersion 24
buildToolsVersion "24.0.0"

defaultConfig {
    applicationId "com.google.firebase.quickstart.auth"
    minSdkVersion 9
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}

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

productFlavors {

    // Build variant to include the Facebook Android SDk
    // The Facebook Android SDK has a min SDK version of 15
    facebook {
        minSdkVersion 15
    }

    // Build variant to exclude the Facebook Android SDK
    // Firebase Authentication has a min SDK version of 9
    nofacebook {
        minSdkVersion 9
    }

}
}

 configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:24.0.0'
}

dependencies {


// Firebase Authentication

// Google Sign In SDK (only required for Google Sign In)

// Facebook Android SDK (only required for Facebook Login)
// This is only compiled into the 'facebook' variant of this app. You can build
// a 'nofacebook' variant to test on devices with SDK < 15.
facebookCompile 'com.facebook.android:facebook-android-sdk:4.9.0'

// Twitter Android SDK (only required for Twitter Login)
compile('com.twitter.sdk.android:twitter-core:1.6.6@aar') {
    transitive = true
}
compile('com.twitter.sdk.android:twitter:1.13.1@aar') {
    transitive = true;
}

androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile
'com.android.support.test:runner:0.5'
compile
'com.android.support:appcompat-v7:24.1.1'compile
'com.google.firebase:firebase-auth:9.2.1'compile
'com.google.android.gms:play-services-auth:9.2.1'}

apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:1)

以正常方式格式化build.gradle:

apply plugin: 'com.android.application'

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

allprojects {
    repositories {
        jcenter()
    }
}

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.google.firebase.quickstart.auth"
        minSdkVersion 9
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
    }

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

    productFlavors {

        // Build variant to include the Facebook Android SDk
        // The Facebook Android SDK has a min SDK version of 15
        facebook {
            minSdkVersion 15
        }

        // Build variant to exclude the Facebook Android SDK
        // Firebase Authentication has a min SDK version of 9
        nofacebook {
            minSdkVersion 9
        }

    }
}

configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:24.0.0'
}

dependencies {

// Firebase Authentication

// Google Sign In SDK (only required for Google Sign In)

// Facebook Android SDK (only required for Facebook Login)
// This is only compiled into the 'facebook' variant of this app. You can build
// a 'nofacebook' variant to test on devices with SDK < 15.
    facebookCompile 'com.facebook.android:facebook-android-sdk:4.9.0'

// Twitter Android SDK (only required for Twitter Login)
    compile('com.twitter.sdk.android:twitter-core:1.6.6@aar') {
        transitive = true
    }
    compile('com.twitter.sdk.android:twitter:1.13.1@aar') {
        transitive = true;
    }

    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    androidTestCompile 'com.android.support.test:runner:0.5'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.google.firebase:firebase-auth:9.2.1'
    compile 'com.google.android.gms:play-services-auth:9.2.1'
}

apply plugin: 'com.google.gms.google-services'

Android Dev Studio中有一个用于自动格式化的热键 - ALT + CMD + L