求助:TedBottomPicker库修改后变更无法正常生效
Got it, let's break down why your modifications to TedBottomPicker aren't sticking and how to make them permanent.
Why Your Changes Keep Getting Overwritten
When you edit the downloaded library files directly (like swapping DIRECTORY_PICTURES for DIRECTORY_DOCUMENTS in TedBottomPicker.java), those changes don't stick because Gradle pulls the original library from its remote repository or local cache every time you build your project. Your edited files get replaced without warning.
The Reliable Fix: Import the Library as a Local Module
To make your customizations stay put, you need to add the library as a local module in your project instead of using the remote dependency. Here's a step-by-step guide:
Set up the local library files
Unzip the full TedBottomPicker code you downloaded into a new folder in your project root—something likeyour-project/libs/tedbottompicker. Double-check that this folder has the library'sbuild.gradlefile and the full source code structure.Add the module to your project settings
Open your project'ssettings.gradlefile and add this line to include the local library:include ':libs:tedbottompicker'Swap the remote dependency for the local module
Go to your app module'sbuild.gradlefile, find the original TedBottomPicker dependency line (it’ll look likeimplementation 'gun0912.ted:tedbottompicker:x.x.x'), and delete it. Replace it with a dependency on your local module:implementation project(':libs:tedbottompicker')Apply your changes and verify
Now you can editTedBottomPicker.java(line 446) in your local module folder. Sync your project with Gradle. From now on, your app will use your modified local library code instead of the remote version—so your changes will persist across every build.
Bonus: Fork the Library for Long-Term Customizations
If you’re planning to make more tweaks down the line, consider forking the library’s repository. Make your changes in your fork, then add your forked repo as a Gradle dependency. This way, you can pull updates from the original library and merge your customizations whenever you need to.
内容的提问来源于stack exchange,提问作者Rafia

