安卓java把原文件隐藏,包括.java文件作为Android Studio中java源文件删除红色圆圈" J"在他们...

Today after update android studio my source folder in project marks as below("J" inside a red circle mark). How can I fix it? I tried clear caches, re-import project, use gradlew clean build, but it doesn't help.

U3K85.png

build.gradle

apply plugin: 'android'

apply plugin: 'android-apt'

android {

compileSdkVersion 19

buildToolsVersion "19.0.3"

sourceSets {

main {

manifest.srcFile 'AndroidManifest.xml'

java.srcDirs = ['src']

resources.srcDirs = ['src']

aidl.srcDirs = ['src']

res.srcDirs = ['res']

assets.srcDirs = ['assets']

}

}

defaultConfig {

minSdkVersion 14

targetSdkVersion 19

versionCode 1

versionName "1.0"

}

buildTypes {

release {

runProguard false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'

}

}

lintOptions {

abortOnError false

}

}

def AAVersion = '3.0.1'

dependencies {

......

}

apt {

arguments {

....

}

}

解决方案

I found some magical solution while playing with this

There are two possible solution you can try to make it correct (tricky one)

1.Replace this in your build.gradle file

java.srcDirs = ['src'] to java.srcDirs = ['src/com']

2.Create a subdirectory inside src name it whatever you want, I prefer name it java like

src > java

move all your java package in to it and change the

java.srcDirs = ['src'] to java.srcDirs = ['src/java']

These are the tricky solutions. It can be considered as a bug in Android Studio that it is not considering the java source set if it is the root of src directory but compiles fine.

After doing all the necessary changes sync your project with gradle and your yellow directory will be magically turned into blue.

Note : Even you have them in root there will be no effect on compilation as per my experience. Only Studio will not mark them as java sourcesets in IDE.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值