Editing external libraries in Android Studio

前端 未结 3 1540
粉色の甜心
粉色の甜心 2020-12-08 11:33

I am using an image carousel library that I snagged off of github, but there are a few things I would like to change in the code. I have imported it using the compile \'com.

相关标签:
3条回答
  • 2020-12-08 12:03

    The source code is located here and it is available to edit:

    https://github.com/ArthurHub/Android-Image-Cropper

    0 讨论(0)
  • 2020-12-08 12:13

    For this you need to import it as lib and modify as you like:

    To import the library to Android Studio, there are two methods that can work.

    Method 1:

    1. Open your project in Android Studio
    2. Download the library (using Git, or a zip archive to unzip)
    3. Create a folder "subProject" in your project
    4. Copy and paste the FreemiumLibrary folder to your subProject folder
    5. On the root of your project directory create/modify the settings.gradle file. It should contain something like the following:
    include 'MyApp', ':subProject:FreemiumLibrary'
    
    1. gradle clean & build/close the project and reopen/re-import it.
    2. Edit your project's build.gradle to add this in the "dependencies" section:
    dependencies {
    //...
        compile project(':subProject:FreemiumLibrary')
    }
    
    1. Edit your App Activities to extend AdsFragmentActivity instead of Activity.
    2. Edit the library if you want to use it with ActionBarCompat

    Method 2:

    1. Open your project in Android Studio
    2. Download the library (using Git, or a zip archive to unzip)
    3. Go to File > New > Import-Module and import the library as a module
    4. Right-click your app in project view and select "Open Module Settings"
    5. Click the "Dependencies" tab and then the '+' button
    6. Select "Module Dependency"
    7. Select "Freemium Library" (not Freemium Library Project)
    8. Modify your App Activities to extend AdsFragmentActivity instead of Activity.
    9. Modify the library if you want to use it with ActionBarCompat
    0 讨论(0)
  • 2020-12-08 12:22

    I solved this way. Fork library project. Then clone it (In Android Studio, File -> New -> Project from Version Control -> put the link of your repository that you forked and open it). Edit it and commit it to your master branch. Then push it to your master branch. And finally find snapshot version of that library. For example if you use JitPack. Go to jitpack.io website and search for your repository (forked version with your username). And there go to commits section and get latest version that you committed. And use that library dependency in your project instead of original repo.

    0 讨论(0)
提交回复
热议问题