Cannot open layout in Android Studio

I just created a blank activity from File > New > Activity. Its MainActivity.java is editable, same for menu_main.xml, but the activity_main.xml layout file cannot be opened. There is no error message, no sign that anything is happening at all, nothing. I also tried removing the activity and creating it again.

Android Studio is updated to the latest version (1.2.1.1) and I tried opening and closing it. I'm running it on Mac OS X 10.10.3 and the file exists on the file system where the IDE says it is.

Has anyone ever had this problem?

EDIT : Just tried restarting my computer and the same thing happens.

EDIT 2 : my build.gradle


    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"

        defaultConfig {
            applicationId "ca.etsmtl.gti785.telebama"
            minSdkVersion 16
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.1.1'

        testCompile 'junit:junit:4.12'
        testCompile('org.robolectric:robolectric:3.0-rc2') {
            exclude group: 'commons-logging', module: 'commons-logging'
            exclude group: 'org.apache.httpcomponents', module: 'httpclient'
        }
    }


I'm guessing the problem is maybe in the selected preview API or device. Check out this toolbar in the preview.

在这里输入图像描述


  • Please clean & build you project.
  • Reload xml file go to src->main->res->layout->activity_main.xml.

  • I had the same problem. Rebuild, clean, restart mac, reinstall Android Studio, install different Android Studio versions... nothing worked.

    Then I found out that the problem was gradle, not Android Studio . In gradle-wrapper.properties I changed the version from 3.3 to 3.5 :

    distributionUrl=https://services.gradle.org/distributions/gradle-3.5-all.zip
    

    This fixed the problem for me.

    链接地址: http://www.djcxy.com/p/85296.html

    上一篇: Igot这个错误包com.google.firebase.messaging不存在

    下一篇: 无法在Android Studio中打开布局