简体   繁体   English

将库添加到Android Studio时出错

[英]Error while adding library to Android Studio

I have been trying to add a library to android studio and have encountered a few problems. 我一直在尝试向android studio添加一个库,并遇到了一些问题。 I have looked everywhere and didn't find the solution. 我到处寻找并没有找到解决方案。 错误屏幕

I'd like to add this library ( https://github.com/lucasr/twoway-view/ ) to my project but when I past this line to build.gradle that error occurs 我想将这个库( https://github.com/lucasr/twoway-view/ )添加到我的项目中但是当我通过这行来构建.gradle时发生错误

repositories { 存储库{

 maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } 

} }

dependencies { 依赖{

 compile 'org.lucasr.twowayview:core:1.0.0-SNAPSHOT@aar' compile 'org.lucasr.twowayview:layouts:1.0.0-SNAPSHOT@aar' 

} }

Pls help me because I have no idea what to do. 请帮助我,因为我不知道该怎么做。

You put the statements in the wrong places. 你把陈述放在错误的地方。 Here's how to fix that: 以下是解决这个问题的方法:

maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }

This line above should be in this build.gradle , but inside the allprojects { repositories { ... } } , so like this: 上面的这一行应该在这个build.gradle ,但在allprojects { repositories { ... } } ,所以这样:

allprojects {
    repositories {
        jCenter()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
}

Then make sure you removed the dependencies { ... } part from this file. 然后确保从此文件中删除了dependencies { ... }部分。 In your app folder there is another build.gradle . 在您的app文件夹中,还有另一个build.gradle Open that one, and on the bottom you should see a dependencies { ... } already (probably with the AppCompat library). 打开那个,在底部你应该看到一个dependencies { ... } (可能与AppCompat库)。

Now insert these two lines inside that dependency { ... } clause: 现在在dependency { ... }子句中插入这两行:

compile 'org.lucasr.twowayview:core:1.0.0-SNAPSHOT@aar'
compile 'org.lucasr.twowayview:layouts:1.0.0-SNAPSHOT@aar'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM