【问题标题】:Android Studio does not change my code after run [duplicate]运行后Android Studio不会更改我的代码[重复]
【发布时间】: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 之后使用,那么有时我的代码确实可以工作,但有时却不行。

标签: android kotlin


【解决方案1】:

您必须在 Android Studio 中修复 Run 进程。

查看您的主工具栏并找到此框:

单击该框并选择Edit Configurations...

确保窗口在Before launch 部分中有以下项目:

  • Gradle-aware Make
  • 即时应用配置

点击确定。

运行您的应用程序。

【讨论】:

  • 我认为这已在 Android Studio 3.1 中修复。
  • 谢谢这是解决方案!
【解决方案2】:

试试这个:文件菜单 -> 使缓存无效/重新启动。我想它会解决你的问题。

【讨论】:

    【解决方案3】:

    Android Studio 3.1.0 构建工具升级出现问题。请按照以下步骤解决。

    1. 选择运行并点击编辑配置

      确保在 TaskList 中添加了 Gradle-aware Make。如果没有,那么:

    2. 点击+

    3. 选择 Gradle-aware Make
    4. 将任务留空并选择确定

    注意:确保 Gradle-aware Make 在 Instant App Provision 之前

    【讨论】:

      【解决方案4】:

      尝试按照说明进行操作,它肯定会对您有所帮助。几个月前我已经面临同样的问题了。


      * 更新您的 Android Studio 中的 ADB。
      * 卸载应用程序。
      * 重启 adb start-server。
      * 重新启动您的测试设备。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-09-03
        • 2019-09-14
        • 1970-01-01
        • 2013-07-22
        • 1970-01-01
        • 2019-08-09
        • 1970-01-01
        相关资源
        最近更新 更多