When I change small thing in XML layout files like maxLength
of a TextInputEditText
I need to clean project to let AS pickup change.
Structure of res folders is:
res
- layout
- drawables
- ...
No more subfolders. AS 3.1.1, Gradle 4.6. I tried to add this in gradle:
sourceSets {
main.res.srcDirs = [
'src/main/res/anim',
'src/main/res/color',
'src/main/res/drawable',
'src/main/res/drawable-hdpi',
'src/main/res/drawable-mdpi',
'src/main/res/drawable-xhdpi',
'src/main/res/drawable-xxhdpi',
'src/main/res/drawable-xxxhdpi',
'src/main/res/menu',
'src/main/res/mipmap-dpi',
'src/main/res/mipmap-hdpi',
'src/main/res/mipmap-mdpi',
'src/main/res/mipmap-xhdpi',
'src/main/res/mipmap-xxhdpi',
'src/main/res/mipmap-xxxhdpi',
'src/main/res/raw',
'src/main/res/values',
'src/main/res/values-land',
'src/main/res/values-large',
'src/main/res/values-v21',
'src/main/res/valuesw820dp',
'src/main/res/xml',
'src/main/res/layout',
'src/main/res']
}
Is there a way to prevent cleaning the project every time for change to take effect?
So whenever I make a change to the XML files and run the app, I should see my change but I have to clean the project every time and its getting annoying.
Clear your project directory Obviously, try to clean your project from android studio : “Build -> Clean Project”. This will clear your build folders. Clear the cache of Android Studio using “File -> Invalidate Caches / Restart” choose “Invalidate and restart option” and close Android Studio.
Cleaning an Android project simply deletes the build directory. It removes the . class files that are generated when you compile your project and then recompiles again.
Note Never clean your project using the Build -> Clean Project. Instead of cleaning your project it will increase the size of it. Update clean has been replaced by cleanBuildCache in the recent versions of Android Studio.
Go to Menu option –> Select Project –> click Clean… Note: The same can also be achieved by clicking CTRL + S (save) simultaneously in Eclipse IDE.
First of all you need to create your additional resource folder beside res folder instead of creating inside it. Then try make XML like this example:
sourceSets{
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', '.apt_generated']
aidl.srcDirs = ['src/main/aidl', '.apt_generated']
res.srcDirs = [
'src/main/res',
'src/main/test',
'src/main/login',
'src/main/main',
'src/main/includes'
]
}
}
Note: Your additional resource folder will change effect without cleaning the project.
First of all you need to create your additional resource folder beside res folder instead of creating inside it. Then try make XML like this example:
sourceSets{
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', '.apt_generated']
aidl.srcDirs = ['src/main/aidl', '.apt_generated']
res.srcDirs = [
'src/main/res',
'src/main/test',
'src/main/login',
'src/main/main',
'src/main/includes'
]
}
}
Note: Your additional resource folder will change effect without cleaning the project.
Problem was with build flavors. One of them was named main
and that causes problems with projects scanning. Changing name fixed issue. It is marked in newer versions of gradle plugin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With