I'm having some troubles by using a SNAPSHOT dependency on Android Studio 3.0.1. I've also tried Android Studio 3.1, and the same issue remains.
I'm including the dependency in the following way:
dependencies {
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
resolutionStrategy.cacheDynamicVersionsFor 0, 'seconds'
}
implementation('com.example:lib:0.0.1-SNAPSHOT') { changing = true }
}
When a new version of the library is published, if I click the "Refresh all Gradle projects" icon, the app builds fine. However, Android Studio doesn't see any change made in the snapshot.
I've already tried to restart Android Studio and to invalidate its cache, without any difference.
How to make Android Studio aware of the changes?
Snapshot Dependencies By setting a snapshot dependency of a build (for example, build B) on another build's (build A) sources, you can ensure that build B will start only after build A is run and finished. We call build A a dependency build, whereas build B is a dependent build.
Go to File > Project Structure in Android Studio. Select the app module in the Modules list on the left. Select the Dependencies tab. Click the + button on the lower left to add the dependency.
A Maven snapshot is a special version of a Maven package that refers to the latest production branch code. It is a development version that precedes the final release version. You can identify a snapshot version of a Maven package by the suffix SNAPSHOT that is appended to the package version.
Dependency injection (DI) is a technique widely used in programming and well suited to Android development. By following the principles of DI, you lay the groundwork for good app architecture. Implementing dependency injection provides you with the following advantages: Reusability of code. Ease of refactoring.
I have the same problem. So far, what works for me is to refresh the dependencies through the command line:
./gradlew clean --refresh-dependencies
After that, quit AS completely and open it again. I'll update my answer if I find something else.
It is a bug in studio 3.1 -> https://issuetracker.google.com/issues/72614343
Fixed in latest Canary version (3.2)
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