Android工作室,导入类从gradle文件中消失 [英] Android studio, import class disappear from gradle file

查看:226
本文介绍了Android工作室,导入类从gradle文件中消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  apply plugin:'com.android.application 

这有点奇怪,我有一个gradle.build文件: '

android {
apply from:'../dev-tools/gradle/common-cyborg-app.gradle'

defaultConfig {
applicationIdcom.nu.art.cyborg.demo
}

defineDefaultVariantsAPK(dev-project)
}

当我添加以下导入时:

  import com .android.build.OutputFile 

导入只会消失..确实没有其他方式可以描述它。
我清除了缓存并重新启动,清理了项目并没有任何东西。



每次粘贴该行时,几秒钟后魔术 ...



任何人?




答案工作了一段时间(一天),一旦工作室崩溃,它停止工作......我真的不知道为什么,我浪费了太多时间在上面,我真的不在乎,但我设法解决问题,看一看,我通过应用程序build.gradle文件中的过滤器

解决方案

Android Studio将从您的gradle文件中移除不需要的导入。当你将它粘贴到你的导入文件中时,它并不会导入它,因此它会将其删除。是的,我知道,这是愚蠢的。



你应该做的是先使用完全分类名称的类,然后再添加import。


This is a little weird, I have a gradle.build file:

apply plugin: 'com.android.application'

android {
    apply from: '../dev-tools/gradle/common-cyborg-app.gradle'

    defaultConfig {
        applicationId "com.nu.art.cyborg.demo"
    }

    defineDefaultVariantsAPK("dev-project")
}

when I add the following import:

import com.android.build.OutputFile

the import just disappears.. really there is no other way to describe it. I've cleared caches and restarted, cleaned the project and nothing.

Every time I paste the line, after a few seconds it is "magically" gone...

Anyone?


Update so the accepted answer worked for a while (a day) and once studio crashed, it stopped working... I really don't know why and I wasted too much time on it that I don't really care, BUT I did manage to workaround the problem, take a look, I pass the filter from the app build.gradle file

解决方案

Android Studio will remove unussed imports from your gradle files. When you paste it in you are not ussing that import so it removes it. Yea I know, it is silly.

What you should do is first use the class with fully classified name and then add import later.

这篇关于Android工作室,导入类从gradle文件中消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆