【发布时间】:2018-03-30 12:36:28
【问题描述】:
我对 Android Studio 有一个奇怪的问题。当我运行我的应用程序时,no gradlebuild 等只是安装应用程序和启动活动,这意味着我在代码中所做的任何更改都不会在我的 apk 中更改。
你知道为什么会这样吗?
项目级等级:
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
classpath 'com.google.gms:google-services:3.2.0'
classpath "io.realm:realm-gradle-plugin:5.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用级分级:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
android {
compileSdkVersion 26
defaultConfig {
applicationId ""
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
realm {
syncEnabled = true;
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
}
apply plugin: 'com.google.gms.google-services'
【问题讨论】:
-
尝试重建代码并运行
-
谢谢 :) 我已经尝试过清理、重建、使现金无效并重新启动一千次。我已经重新安装并更新了所有内容。
-
你用日志试过了吗
-
是的,我有这两个问题:
Configuration 'compile' is obsolete and has been replaced with 'implementation'. It will be removed at the end of 2018Configuration 'provided' is obsolete and has been replaced with 'compileOnly'. It will be removed at the end of 2018 -
但是我对此无能为力。如果我使用“Make project”并在 Run 之后使用,那么有时我的代码确实可以工作,但有时却不行。