Java 您如何在 android studio 中编辑依赖项/外部库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30344053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 09:28:26  来源:igfitidea点击:

How do you edit a dependency/external library in android studio?

javaandroiddependenciesexternaledit

提问by Micah Simmons

There is a lot of information about adding libraries and dependencies, but I haven't been able to find any useful information on being able to actually edit a library.

有很多关于添加库和依赖项的信息,但我没有找到任何关于能够实际编辑库的有用信息。

I have added https://github.com/jdamcd/android-cropas a dependency in my project, but I would like to edit some of its features, mostly layout related stuff. However, when I go into browse the files Android Studio says "files under the build folder are generated and should not be edited" and when I edit them they are returned back to their pre-edited state once the system builds.

我在我的项目中添加了https://github.com/jdamcd/android-crop作为依赖项,但我想编辑它的一些功能,主要是与布局相关的内容。但是,当我浏览文件时,Android Studio 说“生成文件夹下的文件已生成,不应编辑”,当我编辑它们时,它们会在系统构建后返回到它们的预编辑状态。

I also tried editing the files in notepad++ and the same problem occurs (they are returned to their pre-edited state on build).

我还尝试在 notepad++ 中编辑文件,但发生了同样的问题(它们在构建时返回到预编辑状态)。

Can someone tell me either how to edit the library or a workaround whereby I can change the layouts/some java without having to copy and paste the entire library into my project to make it editable?

有人可以告诉我如何编辑库或解决方法,我可以更改布局/某些 java 而无需将整个库复制并粘贴到我的项目中以使其可编辑吗?

Thanks in advance,

提前致谢,

God speed.

神速。

Edit: The answer is instead of simply adding the library as a dependency in the build.gradle file using this code: compile 'com.soundcloud.android:android-crop:0.9.10@aar'

编辑:答案不是简单地使用以下代码在 build.gradle 文件中添加库作为依赖项:compile 'com.soundcloud.android:android-crop:0.9.10@aar'

You have to add it as a module instead of just an external dependency, then you can edit the files.

您必须将其添加为模块而不仅仅是外部依赖项,然后您才能编辑文件。

If anyone is wondering how follows these steps:

如果有人想知道如何遵循这些步骤:

  1. Create library folder (call it whatever you want) in the root directory, i.e. the first folder you go into to get to the app and its contents.
  2. Download the library, unzip it.
  3. Put the folder from step 2 in the folder you created in step 1.
  4. Add the module to the settings.gradlelike so: include ':LibraryContainingFolder:ActualLibFolder'
  5. Sync and clean
  6. Go to project structure in Android Studio, click on the main module, normally called app, click on dependencies tab, then click the green plus, then click "Module dependency". The module should appear written as the containing folder and the library folder in it separated by colons 'something:somethingElse'. Add the module.
  7. Sync, clean, buid etc.
  1. 在根目录中创建库文件夹(随意命名),即您进入应用程序及其内容的第一个文件夹。
  2. 下载库,解压。
  3. 将步骤 2 中的文件夹放入您在步骤 1 中创建的文件夹中。
  4. 将模块添加到settings.gradle像这样: include ':LibraryContainingFolder:ActualLibFolder'
  5. 同步和清理
  6. 在 Android Studio 中进入项目结构,点击主模块,通常称为 app,点击依赖项选项卡,然后点击绿色加号,然后点击“模块依赖项”。该模块应显示为包含文件夹和其中的库文件夹,以冒号“something:somethingElse”分隔。添加模块。
  7. 同步、清理、构建等。

采纳答案by Karim

You should add the library as a module in Android Studio, by downloading the code from the Github repository you're interested in (and removing the line under dependenciesthat you added to build.gradle)

您应该将库作为模块添加到 Android Studio 中,方法是从您感兴趣的 Github 存储库下载代码(并删除dependencies您添加到的行build.gradle

Then follow the steps in this answer: https://stackoverflow.com/a/16639227/1065810

然后按照此答案中的步骤操作:https: //stackoverflow.com/a/16639227/1065810