【发布时间】:2018-04-01 06:20:44
【问题描述】:
当我使用模拟器 api26 时出现错误。我不必使用 kotlin,因为没有导入 kotlin,而是构建 api>26 错误。 > kotlin.KotlinNullPointerException(无错误消息).
com.android.build.gradle.tasks.ir.InstantRunMainApkResourcesBuilder$ConfigAction.execute(InstantRunMainApkResourcesBuilder.kt:129)
构建等级:
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 应用程序:
// 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
}
【问题讨论】:
-
请您使用这个:
classpath 'com.android.tools.build:gradle:3.0.0',只是为了测试。 -
谢谢Mr.Hyde,帮助我走向成功。
-
所以,它可能与
ButterKnife版本有关。我想有一天你将不得不使用最新版本的 Android Build Gradle,所以完全尝试解决这个问题。也许,现在,使用黄油刀快照版本:com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT。 -
尝试
classpath 'com.android.tools.build:gradle:3.0.1'或尝试在 Android Studio 中关闭 Instant Run。这应该可以解决您的问题。但我仍在试图弄清楚为什么会出现这个问题。 -
亨利尝试检查 3.0.0
标签: android gradle kotlin android-gradle-plugin