Android 3.1 build gradle 4.4配置项目':app'时发生错误 [英] Android 3.1 build gradle 4.4 error occurred configuring project ':app'

查看:550
本文介绍了Android 3.1 build gradle 4.4配置项目':app'时发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用模拟器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 {
applicationIdvn.top12 .app
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName1.0
testInstrumentationRunnerandroid.support.test.runner.AndroidJUnitRunner
multiDexEnabled = true
// blur
renderscriptTargetApi 18
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile ('proguard-android.txt'),'pr oguard-rules.pro'
}
}
signingConfigs {
版本{
keyAliastop12vn
keyPasswordtop12vn
storeFile文件('key_store / top12_released_key.keystore')
storePasswordtop12vn

}
debug {
keyAliastop12vn
keyPasswordtop12vn
storeFile文件('key_store / top12_released_key.keystore')
storePasswordtop12vn
}
}
lintOptions {
checkReleaseBuilds true
// Or ,如果你愿意,你可以继续检查发布版本中的错误,
//但是即使发现错误也继续构建:
abortOnError false
}
buildToolsVersion '27 .0 .3'

}
依赖项{
implementation fileTree(include:['* .jar'],dir:'libs')
implementation'com.android .supp ort: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'
//黄油刀。
implementation'com.jakewharton:butterknife:8.8.1'
annotationProcessor'com.jakewharton:butterknife-compiler:8.8.1'
// gson。
实现'com.google.code.gson:gson:2.8.2'
//图像加载。
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 '
//键盘keyboardvisibilityevent
实现'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'
// com.google.firebase。
实现'com.google.firebase:firebase-messaging:12.0.1'
//云消息传递
实现'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使用Room
实现'android.arch.persistence.room:runtime:1.0.0'$ b $将数据保存在本地数据库中b annotationProcessorandroid.arch.persistence.room:compiler:1.0.0
//推送onesignal
//执行'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'
}

//将此添加到底部
apply插件:'com.google.gms.google-se rvices'

构建gradle应用程序:

  //顶层构建文件,您可以在其中添加对所有子项目/模块通用的配置选项。 

uildscript {

repositories {
google()
jcenter()
mavenCentral()

}
依赖项{
classpath'com.android.tools.build:gradle:3.1.0'
classpath'com.google.gms:google-services:3.1.1'
// google-services插件


//注意:不要在这里放置应用程序依赖项;它们属于单个模块build.gradle文件中的
//
}
}

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

}
}

任务清理(类型:删除){
删除rootProject。 buildDir
}


解决方案

但为了让即时运行再次工作,将您的项目gradle降级到



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& 27.0.3在未来的版本中...


When i build app to android studio 3.1 with emulator api<26 not error, but when i build api>26 error. i have not to use kotlin because not import kotlin,but build api>26 error. > kotlin.KotlinNullPointerException (no error message).

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

Build 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'

Build 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
}

解决方案

Not a permanent solution, but to get instant run working again, downgrade your project gradle to

classpath 'com.android.tools.build:gradle:3.0.1' (instead of 3.1.0) and in your app/build.gradle, downgrade buildTools: buildToolsVersion '27.0.0' (instead of 27.0.3)

This will allow you to use instant run again. hopefully they will fix the issue with 3.1.0 & 27.0.3 in a future release...

这篇关于Android 3.1 build gradle 4.4配置项目':app'时发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆