Android Studio无法选择构建变体

时间:2017-01-02 18:58:52

标签: android android-studio

我为众多架构生成了* .so,在我的gradle中我定义了productFlavors:

productFlavors {
    x86 {
        ndk {
            abiFilter "x86"
        }
    }
    armv7a {
        ndk {
            abiFilter "armeabi-v7a"
        }
    }
    fat
}

由于某种原因,唯一可行的是armv7a-debug,如果我选择任何其他的,它将导致以下错误:

2017-01-02 10:43:29,393 [3729690]  ERROR - riant.view.BuildVariantUpdater - Unable to select build variant 'fatDebug':
    Cannot find NativeAndroidProject for module 'app'.
    com.intellij.openapi.diagnostic.Logger$EmptyThrowable
        at com.intellij.openapi.diagnostic.Logger.error(Logger.java:129)
        at com.android.tools.idea.gradle.variant.view.BuildVariantUpdater.logAndShowUpdateFailure(BuildVariantUpdater.java:264)
        at com.android.tools.idea.gradle.variant.view.BuildVariantUpdater.getNativeAndroidModel(BuildVariantUpdater.java:255)
        at com.android.tools.idea.gradle.variant.view.BuildVariantUpdater.doUpdate(BuildVariantUpdater.java:105)
        at com.android.tools.idea.gradle.variant.view.BuildVariantUpdater.lambda$updateSelectedVariant$0(BuildVariantUpdater.java:70)
        at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.mergeRootsChangesDuring(ProjectRootManagerImpl.java:314)
        at com.android.tools.idea.gradle.util.Projects.lambda$null$5(Projects.java:236)
        at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:898)
        at com.android.tools.idea.gradle.util.Projects.lambda$executeProjectChanges$6(Projects.java:234)
        at com.intellij.util.ui.UIUtil.invokeAndWaitIfNeeded(UIUtil.java:2453)
        at com.android.tools.idea.gradle.util.Projects.executeProjectChanges(Projects.java:234)
        at com.android.tools.idea.gradle.variant.view.BuildVariantUpdater.updateSelectedVariant(BuildVariantUpdater.java:69)
        at com.android.tools.idea.gradle.variant.view.BuildVariantView.buildVariantSelected(BuildVariantView.java:520)
        at com.android.tools.idea.gradle.variant.view.BuildVariantView$BuildVariantTable.lambda$addBuildVariants$0(BuildVariantView.java:486)
        at javax.swing.JComboBox.fireItemStateChanged(JComboBox.java:1223)
        at javax.swing.JComboBox.selectedItemChanged(JComboBox.java:1280)
        at javax.swing.JComboBox.contentsChanged(JComboBox.java:1330)
        at javax.swing.AbstractListModel.fireContentsChanged(AbstractListModel.java:118)
        at javax.swing.DefaultComboBoxModel.setSelectedItem(DefaultComboBoxModel.java:93)
        at javax.swing.JComboBox.setSelectedItem(JComboBox.java:576)
        at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:622)
        at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:861)
        at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)
        at java.awt.Component.processMouseEvent(Component.java:6533)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
        at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(BasicComboPopup.java:510)
        at java.awt.Component.processEvent(Component.java:6298)
        at java.awt.Container.processEvent(Container.java:2236)
        at java.awt.Component.dispatchEventImpl(Component.java:4889)
        at java.awt.Container.dispatchEventImpl(Container.java:2294)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
        at java.awt.Container.dispatchEventImpl(Container.java:2280)
        at java.awt.Window.dispatchEventImpl(Window.java:2746)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:709)
        at java.awt.EventQueue$3.run(EventQueue.java:703)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
        at java.awt.EventQueue$4.run(EventQueue.java:731)
        at java.awt.EventQueue$4.run(EventQueue.java:729)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
        at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:795)
        at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:627)
        at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:387)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

我之前在家用台式机上做过产品口味,它运行良好,而且我不确定我现在做的不同或错误。

以前是否还有其他人遇到此问题?

2 个答案:

答案 0 :(得分:2)

删除.idea*.iml文件,然后将项目重新导入Android Studio,为我解决了这个问题

答案 1 :(得分:0)

将其替换为:

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
}

以我的情况为我的Android Studio v3.0.1:

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
}