2016-02-21 253 views
0

我用项目结构GSON库添加到的build.gradle(模块:应用程序)文件不会自动导入文件,但我的Android 1.5.1的工作室不自动导入在MainActivity.java库文件。我不知道为什么......添加在摇篮依赖关系MainActivity

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile 'com.android.support:design:23.1.1' 
    compile 'com.google.code.gson:gson:2.2.4' 
} 

回答

0

我发现,当我在MainActivity.java添加代码

Gson gson = new Gson(); 

它自动导入库~~~欢呼

使用库
0

如果它是一个库 - > 文件>打开模块设置>库>新建项目库(在中间卡“+”号)>从Maven的>键入库名称,并将其应用

+0

这不提供答案这个问题。一旦你有足够的[声誉](https://stackoverflow.com/help/whats-reputation),你将可以[对任何帖子发表评论](https://stackoverflow.com/help/privileges/comment);相反,[提供不需要提问者澄清的答案](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-c​​an- I-DO-代替)。 - [评分](/审查/低质职位/ 16870151) – Parfait