skip to Main Content

Everytime I open my project in Android Studio, this error appeared:

Error: Run configuration app is not supported in the current project. Cannot obtain the application ID.

When I click Sync project with Gradle Files, after the syncing process, this error disappeared. However when I reopen the project or restart Android Studio, this error appears again.

I know Sync project with Gradle Files can do the trick, but I don’t want to do it everytime I open my project, I have tried to downgrade Android Studio, however it seems not working.

My environment:

  • Android Studio Dolphin | 2021.3.1
  • Gradle 7.5.1
  • Android Gradle Plugin 7.3.0

Some thing interesting is that each time I start Android Studio, an IDE error pop up:

java.lang.IllegalStateException: Cannot find root module data: xxxx-xxxx
    at com.android.tools.idea.gradle.project.sync.idea.VariantSwitcher.getAndroidModules(VariantSwitcher.kt:248)
    at com.android.tools.idea.gradle.project.sync.idea.VariantSwitcher.getSelectedVariants(VariantSwitcher.kt:261)
    at com.android.tools.idea.gradle.project.sync.idea.VariantSwitcher.findAndSetupSelectedCachedVariantData(VariantSwitcher.kt:128)
    at com.android.tools.idea.gradle.project.AndroidGradleProjectStartupActivityKt.attachCachedModelsOrTriggerSync(AndroidGradleProjectStartupActivity.kt:198)
    at com.android.tools.idea.gradle.project.AndroidGradleProjectStartupActivityKt.access$attachCachedModelsOrTriggerSync(AndroidGradleProjectStartupActivity.kt:1)
    at com.android.tools.idea.gradle.project.AndroidGradleProjectStartupActivity.runActivity(AndroidGradleProjectStartupActivity.kt:105)
    at com.intellij.ide.startup.impl.StartupManagerImpl.runStartupActivity(StartupManagerImpl.kt:312)
    at com.intellij.ide.startup.impl.StartupManagerImpl.runActivityAndMeasureDuration(StartupManagerImpl.kt:293)
    at com.intellij.ide.startup.impl.StartupManagerImpl.runActivityAndMeasureDuration$default(StartupManagerImpl.kt:288)
    at com.intellij.ide.startup.impl.StartupManagerImpl$runPostStartupActivities$1$2.run(StartupManagerImpl.kt:256)
    at com.intellij.openapi.project.DumbServiceImpl.doRun(DumbServiceImpl.java:395)
    at com.intellij.openapi.project.DumbServiceImpl.updateFinished(DumbServiceImpl.java:387)
    at com.intellij.openapi.project.TrackedEdtActivityService$TrackedEdtActivity.run(TrackedEdtActivityService.java:66)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
    at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:348)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

I have dependend on another private module I wrote my self in settings.gradle

includeBuild('external/xxxx-xxxx') {
    name "xxxx-xxxx"
    dependencySubstitution {
        substitute module('com.xxxx.xxxx:xxxx:1.0.0') using project(':xxxx-xxxx')
    }
}

Maybe is my submodule’s issue or a bug in Android Studio/Gradle? Other project does not have this issue.

2

Answers


  1. In my case, the package name was missing from the Manifest file (weird because I just created the project and it should have been there by default) but I added it and now it’s working.

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools" package="com.example.name">
    
    Login or Signup to reply.
  2. In my case what is helped:

    1. Close IntelliJ Idea project (or Android studio)
    2. Remove .idea folder in the root of the project
    3. Open the directory of the project, and initialize it again.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search