Cannot create new activity in android studio

后端 未结 9 1268
猫巷女王i
猫巷女王i 2021-01-02 09:48

I keep getting an IllegalStateException error in the event log while creating new activity in android studio:

11:27:15 InvalidReferenceException         


        
相关标签:
9条回答
  • 2021-01-02 10:22

    Comment the code in build.gradle which creates folders in tmp directory and then create the Activity.

    After successful creation of activity ,revert back the commented code in build.gradle (Co)

    allprojects {
    /*String osName = System.getProperty("os.name").toLowerCase();
    if (osName.contains("windows")) {
        buildDir = "C:/tmp/${rootProject.name}/${project.name}"
    }*/
    repositories {
        jcenter()
    }
    

    }

    0 讨论(0)
  • 2021-01-02 10:23

    I had the same issue. Visit this Link. https://code.google.com/p/android/issues/detail?id=232076

    this happens if you have your project in a different drive other then C: android studio will automatically create a copy of your project (i hope they are cache files) in the C: drive's tmp folder. this folder is the cause for this issue.

    try File-> Invalidate Caches/Restart. or just deleted the tmp folder in the c: drive and restart everything and it will work fine.

    0 讨论(0)
  • 2021-01-02 10:27

    In the file build.gradle, add

    buildDir = "C:/tmp/${rootProject.name}/${project.name}"
    

    sychronize gradle then remove it and synchronize again. This worked for me.

    allprojects {
    buildDir = "C:/tmp/${rootProject.name}/${project.name}"
    repositories {
        jcenter()
    }
    

    }

    0 讨论(0)
提交回复
热议问题