配置项目':app'时出现Android 3.1 build gradle 4.4错误

时间:2018-04-01 06:20:44

标签: android gradle kotlin android-gradle

当我使用模拟器api< 26构建应用程序到android studio 3.1时没有错误,但是当我构建api> 26错误时。我没有使用kotlin,因为没有导入kotlin,但是构建api> 26错误。 的> kotlin.KotlinNullPointerException(无错误消息)

com.android.build.gradle.tasks.ir.InstantRunMainApkResourcesBuilder $ ConfigAction.execute(InstantRunMainApkResourcesBuilder.kt:129)

构建gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "vn.top12.app"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled = true
        // blur
        renderscriptTargetApi 18
        renderscriptSupportModeEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    signingConfigs {
        release {
            keyAlias "top12vn"
            keyPassword "top12vn"
            storeFile file('key_store/top12_released_key.keystore')
            storePassword "top12vn"

        }
        debug {
            keyAlias "top12vn"
            keyPassword "top12vn"
            storeFile file('key_store/top12_released_key.keystore')
            storePassword "top12vn"
        }
    }
    lintOptions {
        checkReleaseBuilds true
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    buildToolsVersion '27.0.3'

}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    //them multiDexEnabled = true
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:recyclerview-v7:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    // butter knife.
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    // gson.
    implementation 'com.google.code.gson:gson:2.8.2'
    // image loading.
    implementation 'com.github.bumptech.glide:glide:4.6.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
    //    com.squareup.retrofit2
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    //com.squareup.okhttp3
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
    implementation 'com.squareup.okhttp3:okhttp:3.9.1'
    //    reactive
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.8'
    // keyboard keyboardvisibilityevent
    implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'
    // com.google.firebase.
    implementation 'com.google.firebase:firebase-messaging:12.0.1'
    // Cloud Messaging
    implementation 'com.google.firebase:firebase-core:12.0.1'
    //Analytics
    implementation 'com.google.firebase:firebase-invites:12.0.1'
    //Invites and Dynamic Links
    // ViewModel and LiveData
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    //room Save data in a local database using Room
    implementation 'android.arch.persistence.room:runtime:1.0.0'
    annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
    //push onesignal
    //  implementation 'com.onesignal:OneSignal:3.7.1'
    //gmc
    implementation 'com.google.android.gms:play-services-gcm:12.0.1'
    //exoplayer-textureview
    implementation 'com.google.android.exoplayer:exoplayer:2.7.0'
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

构建gradle app:

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

buildscript {

    repositories {
        google()
        jcenter()
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath 'com.google.gms:google-services:3.1.1'
        // google-services plugin


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()

    }
}

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

1 个答案:

答案 0 :(得分:4)

不是永久性的解决方案,但要立即重新开始工作,请将项目评级降级为

classpath'com.android.tools.build:gradle:3.0.1'(而不是3.1.0) 和 在你的app / build.gradle中,降级buildTools: buildToolsVersion '27 .0.0'(而不是27.0.3)

这将允许您再次使用即时运行。希望他们能解决3.1.0& amp; 27.0.3在未来的版本中......