how update local aar package sources

前端 未结 6 1536
别那么骄傲
别那么骄傲 2021-02-03 20:36

I created two Android Studio applications. One of them is aar library. I used this aar library in second application. I added aar library by using File->New->New Module->Import

相关标签:
6条回答
  • 2021-02-03 20:46

    I was having the same issue, had tried every form of including my local aar in my project, tried every method of rebuilding, invalidating caches etc, but I was still having the problem where changes in my local aar were not available after updating the file in the libs folder.

    The only thing that worked for me was this:

    1. Comment out the implementation files('../libs/yourlib.aar') line in gradle
    2. Sync gradle
    3. Update yourlib.aar in the libs folder
    4. Uncomment the implementation files('../libs/yourlib.aar') line in gradle
    5. Sync again
    6. Build project

    Now the changes in yourlib.aar should be available in your project. If you have this lib included in multiple modules I am guessing you'll have to do it for each module. Not ideal, but I spent at least 5 hours on this issue and these steps were the only way I could seemingly force the changes. I am guessing that removing the library from the gradle file and then syncing will force it to pick up the new one when it is added again.

    0 讨论(0)
  • 2021-02-03 20:46

    I had the same issue and solved it very quickly doing the following:

    • Look in your project /.idea/libraries/ folder for Gradle__artifacts_[subproject].xml
    • Delete this file
    • In Android Studio, go to File->Sync Project with Gradle Files

    This is for an AAR included as a project (which is how it is included when you use File->New->New Module...->Import .JAR/.AAR Package).

    0 讨论(0)
  • 2021-02-03 20:51

    Have you tried closing the tab of your decompiled file on Android Studio first, update the versionName on the AAR project, rebuild AAR, transfer, and then see it gets updated?

    I know it works for me.

    0 讨论(0)
  • 2021-02-03 20:52

    After replacing .arr file through Windows explorer. The only thing that worked for me is File -> Invalidate caches / Restrt

    0 讨论(0)
  • 2021-02-03 21:03

    In addition to Commenting/Uncommenting & Re-sync Gradle project and settings, I had to delete the entire build-cache directory.

    On Mac: ~/.android/build-cache/ Windows: Unsure of where this directory location is.

    0 讨论(0)
  • 2021-02-03 21:09

    Right now you're including the AAR through a project notation. Since an AAR is literally just a file, it should be included with the files notation instead.

    Assuming a folder structure like so:

    You could include the files with any of the following lines in the dependencies block of app/build.gradle:

      // include just my_library
      implementation files('libs/my_library.aar')
    
      // include just other_library
      implementation files("$rootDir/common/libs/other_library.aar")
    
      // include both libraries
      implementation files('libs/my_library.aar', "$rootDir/common/libs/other_library.aar")
    

    By the way, there's a reasonably complete list of supported dependency types at https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html .

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