导入库(例如,毕加索)到Android工作室之谜毕加索、之谜、工作室、Android

2023-09-08 09:06:39 作者:路亽曱

Android的工作室,这是0.5.9,

Android Studio, it's 0.5.9 (on a Mac, fwiw),

(1)什么(地狱)的内外 build.gradle文件之间的差异?我很困惑,为什么我不能只是把一切离子外一个?

(1) What ("the hell") is the difference between the inner and outer build.gradle file? I'm confused why I can't just put everything ion the outer one?

(2)当我进口的通用图像装载-1.9.2.jar我遵循了这一过程:

(2) When I imported universal-image-loader-1.9.2.jar I followed this procedure:

1,拖动文件到库。 2,点击鼠标右键加到作为库。 3,补充说:编译文件像这样 http://stackoverflow.com/a/17521288/294884 在build.gradle

1, drag that file to "libs". 2, right click add as library. 3, added "compile files" like this http://stackoverflow.com/a/17521288/294884 in build.gradle

工程赫然。 (Android的岩石。)但......................

Works awesomely. (Android rocks.) BUT ......................

当我试图与毕加索-2.3.1.jar,我只是得到一个奇怪的警告重构无法执行 - 只读。它不会让我把它移动到该文件夹​​。那是什么呢?

when I tried that with picasso-2.3.1.jar, i just get a weird warning "Refactoring cannot be performed - read only". It would not let me move it into that folder. What's that about?

(3)实际的毕加索页面,例如,提出这样的:

(3) The actual Picasso page, for example, suggests this:

但我的摇篮文件的看都像,我不能做这项工作。我的摇篮费尔只有{{}}语法。我如何/可以从毕加索页面的工作,建议在我的摇篮文件?

But my gradle files look nothing like that, and I can't make that work. My gradle fils have only { { } } syntax. How/can I make that suggestion from the Picasso page work in my gradle files?

(4)什么是编译..类路径两分法?很多教程说添加这个...

(4) What's the "compile" .. "classpath" dichotomy? Many tutorials say to add this ...

compile 'com.squareup.picasso:picasso:2.1.1'

但是,这不会对我在所有的工作。我得到它的工作只买随机尝试新事物,这工作:

BUT that will not work for me at all. I got it to work only buy randomly trying things, this worked:

classpath 'com.squareup.picasso:picasso:2.3.1'

我似乎无法得到编译工作。

I can't seem to get "compile" to work.

(5)在Android中Studio中其他时间我用(也精彩 - Android的岩石)文件 - >项目结构。然后就是鞭打围绕点击的东西,直到它使魔术发生。我的问题有,其实是一样的改装[查看脚注!]的摇篮文件?,即是一个简单的向导的编辑摇篮文件你?或者是多一点呢?

(5) At other times in Android Studio I've used the (also fabulous -- Android rocks) File -> Project Structure. And then just thrash around clicking on things until it makes magic happen. My question there is, in fact is that the SAME AS modding [see footnote!] the gradle files?, ie is that simply a wizard that edits the gradle files for you? Or is it more than that?

五难题 - 由于

的注脚 - 有摇篮的文件工作,我觉得像我的女儿改装的Minecraft - 但我不把它看作好的

推荐答案

回答您的问题坏了:

1 外build.gradle中有评论内容如下:

1. The outer build.gradle has a comment in it which reads:

//顶级构建文件,你可以添加常用的配置选项,所有分项目/模块。

// Top-level build file where you can add configuration options common to all sub-projects/modules.

内蒙古build.gradle文件是按模块;它是在你做的大部分工作在添加依赖和设置东西方面的​​内部模块。大部分的时间你不修改外层之一。不幸的是它的混乱,很容易犯错误,当你这样做,你得到真正奇怪的错误消息。这是一项正在进行的工作。

Inner build.gradle files are per-module; it's in the inner modules where you do most of your work in terms of adding dependencies and setting things up. Most of the time you don't modify the outer one. Unfortunately it's confusing and it's easy to make mistakes, and when you do, you get really bizarre error messages. It's a work in progress.

2 根据您最近已创建一个项目,如果它有这个的build.gradle文件:

2. With a project you've created recently, if it has this its build.gradle file:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

您应该不需要做右键单击添加库,也不应该你必须以其他方式修改生成文件。只要将库到库文件夹中的在文件系统,它会捡起来;您可能需要单击同步工程与摇篮文件按钮在工具栏上,直到其功能的实现自动检测这种变化。

you shouldn't need to do the right-click "Add as library" nor should you have to otherwise modify your build file. Just drag the library into the libs folder IN THE FILESYSTEM and it will pick it up; you may have to click the "Sync Project with Gradle Files" button in the toolbar until the feature is implemented to detect that change automatically.

我只是想从文件系统到IDE窗口中的libs文件夹拖动一个jar文件,并得到了重构无法执行的消息。这看起来像一个错误,我已经提起https://$c$c.google.com/p/android/issues/detail?id=70784为了它。但是,如果你在副本中的操作系统,而不是IDE,它将把它捡起来,也许除了需要有摇篮的文件同步,我说。

I just tried dragging a jar file from the filesystem into the libs folder of the IDE window and got that "Refactoring cannot be performed" message. This looks like a bug, and I've filed https://code.google.com/p/android/issues/detail?id=70784 for it. But if you do the copy in the OS instead of the IDE, it will pick it up, except perhaps needing to sync with Gradle files as I said.

5。的项目结构对话框本质上是一个向导,修改您的build.gradle文件。这些构建文件是真理的来源,以及项目结构UI读取和写入到他们。如果UI你想要做什么,然后用它的身体健康,不要用手修改构建文件。

5. The Project Structure dialog is essentially a wizard for modifying your build.gradle files. Those build files are the source of truth, and the Project Structure UI reads from and writes to them. If the UI does what you want, then use it in good health and don't modify the build files by hand.

说了这么多,如果你想通过修改构建文件中添加依赖关系:

Having said that, if you want to add dependencies by modifying the build files:

4 要添加毕加索,你可以修改依赖块模块级build.gradle文件看起来像这样:

4. To add Picasso, you could modify your dependencies block in the module-level build.gradle file to look like this:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.squareup.picasso:picasso:2.3.1'
    // Maybe there's other stuff in here too
}

3。的这些指示是Maven的,这是一个完全不同的构建系统。这是可能使用它在Android的工作室,但你会发现在IDE打架你很多,因为它不设置这样做。

3.Those instructions are for Maven, which is a completely different build system. It's possible to use it in Android Studio, but you'll find the IDE fights you a lot since it's not set up to do that.