Android Studio - 错误:文件过早结束

时间:2016-11-01 18:53:45

标签: java android

用于firebasse存储。将classpath“com.google.gms:google-services:3.0.0”添加到build.gradle(项目模块)并同步项目时。它会出现文件过早结束的错误

这是build.gradle(app module)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.ammar.backupcontacts_sms"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.firebase:firebase-client-android:2.5.2+'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'commons-lang:commons-lang:2.6'
    compile 'com.google.firebase:firebase-auth:9.6.0'
    compile 'com.google.firebase:firebase-storage:9.6.0'
    compile 'com.google.android.gms:play-services:9.8.00'
}
apply plugin: 'com.google.gms.google-services'

build.gradle(项目模块)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.google.gms:google-services:3.0.0'
        /*classpath 'com.google.gms:google-services:1.3.0-beta1'*/
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Error:Premature end of file.

1 个答案:

答案 0 :(得分:0)

删除 .gradle / caches 文件夹解决了我的问题。

[对于Linux(Solus),您可以在主页中找到 .gradle 文件夹。如果您没有看到它,则可能隐藏CTRL+H以查看隐藏文件夹]

希望有所帮助:)