升级到 android studio chipmunk 后应用程序未安装在模拟器中

App not installing in emulator after upgrading to android studio chipmunk

因此,在 android 工作室中按下 运行 应用程序按钮即可编译该应用程序。但它不会将编译后的应用程序安装到模拟器中。应用编译成功。

> Task :app:packageGoogleDebug UP-TO-DATE
> Task :app:createGoogleDebugApkListingFileRedirect UP-TO-DATE
> Task :app:assembleGoogleDebug UP-TO-DATE

BUILD SUCCESSFUL in 16s 41 actionable tasks: 41 up-to-date

到此为止。亚行工作正常。我可以看到模拟器登录 logcat.

我有 2 种构建风格。两者是一样的。编译但不安装。

buildscript {
    repositories {
        google()
        mavenCentral()
        maven {url 'https://developer.huawei.com/repo/'}
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.0'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
        classpath 'com.google.firebase:perf-plugin:1.4.1'
        classpath 'com.huawei.agconnect:agcp:1.6.5.300'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {url 'https://developer.huawei.com/repo/'}
        mavenLocal()
        gradlePluginPortal()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

使 Catch 失效对我有用。

  1. 删除所有构建文件夹
  2. 使缓存无效并重新启动
  3. 创建一个新的 API31 模拟器和 运行 'app'

这些步骤对我有用。

找到了罪魁祸首.. 查看 android studio 日志.. 它是 HMS 工具包.. 如果你们安装了它... 只需禁用该插件,直到华为修复它.. 运行 按钮将正常工作..

2022-05-10 16:52:43,924 [  10645]  ERROR - e.plugins.cl.PluginClassLoader - JDK: 11.0.12; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o. 
2022-05-10 16:52:43,924 [  10645]  ERROR - e.plugins.cl.PluginClassLoader - OS: Mac OS X 
2022-05-10 16:52:43,924 [  10645]  ERROR - e.plugins.cl.PluginClassLoader - Plugin to blame: HMS Toolkit version: 6.3.0.3003.AF 
2022-05-10 16:52:43,926 [  10647]  ERROR - e.plugins.cl.PluginClassLoader - Calling `ClassLoader#getResource` with leading slash doesn't work; strip 
com.intellij.diagnostic.PluginException: /icons/pushkit/add_light.png [Plugin: com.huawei.deveco.hms]
    at com.intellij.ide.plugins.cl.PluginClassLoader.doFindResource(PluginClassLoader.java:492)
    at com.intellij.ide.plugins.cl.PluginClassLoader.getResourceAsStream(PluginClassLoader.java:462)
    at com.huawei.kits.pushkit.utils.PushIconUtils.load(PushIconUtils.java:93)
    at com.huawei.kits.pushkit.utils.PushIconUtils.<clinit>(PushIconUtils.java:62)
    at com.huawei.kits.pushkit.ui.SampleMessagePanel.initPanel(SampleMessagePanel.java:87)
    at com.huawei.kits.pushkit.ui.SampleMessagePanel.<init>(SampleMessagePanel.java:80)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.huawei.hms.core.main.module.manager.resloader.JarLoader.createObject(JarLoader.java:130)
    at com.huawei.hms.core.main.module.manager.Module.lambda$createModuleView[=10=](Module.java:245)
    at java.base/java.util.TreeMap.forEach(TreeMap.java:1002)
    at com.huawei.hms.core.main.module.manager.Module.createModuleView(Module.java:239)
    at com.huawei.hms.core.main.module.manager.Application.initAllModuleViews(Application.java:287)
    at com.huawei.hms.core.component.InitProjectComponent.<init>(InitProjectComponent.java:65)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:52)
    at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:877)
    at com.intellij.serviceContainer.MyComponentAdapter.doCreateInstance(MyComponentAdapter.kt:35)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:113)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:67)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:60)
    at com.intellij.serviceContainer.ComponentManagerImpl.createComponents(ComponentManagerImpl.kt:407)
    at com.intellij.openapi.project.impl.ProjectExImpl.init(ProjectExImpl.kt:183)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.initProject(ProjectManagerImpl.java:178)
    at com.intellij.openapi.project.impl.ProjectManagerExImpl.prepareProject(ProjectManagerExImpl.kt:339)
    at com.intellij.openapi.project.impl.ProjectManagerExImpl.access$prepareProject(ProjectManagerExImpl.kt:56)
    at com.intellij.openapi.project.impl.ProjectManagerExImpl$doOpenAsync.invoke(ProjectManagerExImpl.kt:123)
    at com.intellij.openapi.project.impl.ProjectManagerExImpl$doOpenAsync.invoke(ProjectManagerExImpl.kt:56)
    at com.intellij.openapi.project.impl.ProjectUiFrameAllocator$run$progressRunner.apply(ProjectFrameAllocator.kt:94)
    at com.intellij.openapi.project.impl.ProjectUiFrameAllocator$run$progressRunner.apply(ProjectFrameAllocator.kt:71)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit(ProgressRunner.java:243)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess(CoreProgressManager.java:183)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:705)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:647)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:170)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit(ProgressRunner.java:243)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)```

当我遇到同样的问题时,我向 Google 团队提交了工单,他们说请卸载 HMS ToolKit 插件,因为它会导致问题。

你可以在这里查看。

https://issuetracker.google.com/issues/232107670