如何使用Android studio 0.3.0导入新模块(android库项目)

mic*_*noy 7 android gradle android-studio

当使用新的用户界面引入android studio 0.3.0以使用项目结构修改build.grade文件时,android工具团队迈出了一大步.

但是如何将android库项目导入我的常规项目?当我按下项目结构 - >模块部分中的"+"按钮时,我只能创建新模块.

Jto*_*heR 13

The way I just did it was by copy pasting the library project in the root of your project (not using android studio, this gives a 'cannot create class-file error', but just using the file manager of your operating system. When using android studio for this it didn't copy some of the files).

Then mark the java folder of the library project as 'source root' (right mouse on the folder).

然后到settings.gradle添加你的lib项目,如下所示:

include ':youApp', ':yourLibrary'
Run Code Online (Sandbox Code Playgroud)

然后你的app的build.gradle添加依赖:

dependencies {
    compile project(':yourLibrary')
}
Run Code Online (Sandbox Code Playgroud)

现在重建您的项目.

现在添加库项目的功能(显示红色),当您单击它并按Alt-Enter它应该说"添加依赖于模块yourAppProject"


mic*_*noy 8

在android studio 0.3.1中,他们修复了它.

项目结构 - >模块 - >"+" - >导入模块.

导入模块屏幕