IDEA不总是部署最新的更改。

huangapple go评论80阅读模式
英文:

IDEA does not always deploy latest changes

问题

settings.gradle.kts

我尝试在一个文件夹中同时运行Android应用和Compose for Desktop应用但遇到了一些问题

    MyProject
       │└──android
             └── app
               └──build.gradle.kts
            └── build.gradle.kts
       └── desktop
           └── build.gradle.kts
    └── settings.gradle.kts

**settings.gradle.kts**

    pluginManagement {
      repositories {
        google()
        gradlePluginPortal()
        mavenCentral()
        maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
      }
      plugins {
        kotlin("multiplatform").version("1.7.10")
        id("org.jetbrains.compose").version("1.2.0")
      }
    }
    
    dependencyResolutionManagement {
      repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
      repositories {
        google()
        mavenCentral()
      }
    }
    
    rootProject.name = "MyProject"
    include("android:app")
    include("desktop")

我的Android应用采用单模块架构但当我在IDEA中运行 `android.app`它会尝试**直接**安装APK到模拟器/手机上而不经过构建阶段如果我删除构建文件夹中的 app-debug.apk 并再次运行它它将无法安装APK

    IDEA: IntelliJ IDEA 2022.3.2 (Ultimate Edition)
    AGP: 7.3.0
    gradle: 7.5.1


    02/06: Launching 'android.app' on <default>.
    Error loading build artifacts from: C:\Users\...\android\app\build\intermediates\apk_ide_redirect_file\debug\redirect.txt

就像上面的错误一样IDEA似乎一直在尝试安装缓存的APK而不是构建最新的APK
英文:

I tried to run both the android app and the compose for desktop app in one folder, but I ran into some problems.

MyProject
│   │└──android
│   │     │ └── app
│   │     │   └──build.gradle.kts
│   │     └── build.gradle.kts
│   └── desktop
│       └── build.gradle.kts
└── settings.gradle.kts

settings.gradle.kts

pluginManagement {
  repositories {
    google()
    gradlePluginPortal()
    mavenCentral()
    maven(&quot;https://maven.pkg.jetbrains.space/public/p/compose/dev&quot;)
  }
  plugins {
    kotlin(&quot;multiplatform&quot;).version(&quot;1.7.10&quot;)
    id(&quot;org.jetbrains.compose&quot;).version(&quot;1.2.0&quot;)
  }
}

dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  repositories {
    google()
    mavenCentral()
  }
}

rootProject.name = &quot;MyProject&quot;
include(&quot;android:app&quot;)
include(&quot;desktop&quot;)

My Android app has a single module architecture, but when I run android.app in IDEA, it tries to install the apk directly on my emulator/phone without going through the building stage. If I delete the app-debug.apk in the build folder and run it again, it will not be able to install the apk.

IDEA: IntelliJ IDEA 2022.3.2 (Ultimate Edition)
AGP: 7.3.0
gradle: 7.5.1


02/06: Launching &#39;android.app&#39; on &lt;default&gt;.
Error loading build artifacts from: C:\Users\...\android\app\build\intermediates\apk_ide_redirect_file\debug\redirect.txt

Just like the error above, IDEA seems to be forever trying to install the cached apk instead of building the latest apk

答案1

得分: 2

这个答案对我有用,但我仍然不明白为什么当我从单模块Gradle项目切换到多模块Gradle项目时会出现这个问题。

https://stackoverflow.com/a/65955788/15486462

英文:

This answer worked for me, but I still don't understand why I have this problem when I change from a single-module gradle project to a multi-module gradle project.

https://stackoverflow.com/a/65955788/15486462

答案2

得分: 0

以下是翻译好的部分:

创建一个新的运行配置,参数与默认的配置应用相同:

运行 &&
编辑配置 &&
添加新配置 &&
重命名 &&
选择应用模块 &&
应用 &&
从 Android Studio 的运行按钮正常运行应用
英文:

what worked for me is this :

Create a new configuration for Run with the same parameters as the default config app

Run &amp;&amp; 
Edit Configuration  &amp;&amp;
Add New Configuration &amp;&amp; 
Rename &amp;&amp; 
Choose app Module &amp;&amp; 
Apply &amp;&amp; 
Run app normally from Run Button android studio 

huangapple
  • 本文由 发表于 2023年2月6日 19:36:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75360810.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定