相关疑难解决方法(0)

如何用Android Studio和gradle构建一个Android库?

我正在尝试从Eclipse迁移项目,但我尝试过的任何工作都没有.在Eclipse中我有3个项目(2个Android应用程序项目和1个android库项目).2个app项目取决于库项目.当我进行gradle导出时,我得到3个不起作用的项目.我愿意重组该项目,但没有找到任何关于如何完成这项工作的文件.

有没有办法让Eclipse导出的3个项目一起工作?我是否最好重组一些事情,如果是这样的文件应该怎么做呢?

更新

我已将整个项目上传到GitHub https://github.com/respectTheCode/android-studio-library-example

更新1

根据Padma Kumar的建议,这就是我所尝试的.

  1. 创建一个名为的新项目 MyApp
  2. 单击File > New Module,选择Android Library并命名MyLib
  3. 点击 Build > Make Project

构建因此错误而失败

Module "MyLib" was fully rebuilt due to project configuration/dependencies changes
Compilation completed with 1 error and 0 warnings in 19 sec
1 error
0 warnings
/.../MyApp/MyLib/build/bundles/debug/AndroidManifest.xml
Gradle: <manifest> does not have package attribute.
Run Code Online (Sandbox Code Playgroud)

然后我package在清单中添加了一个属性

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.mylib" >
Run Code Online (Sandbox Code Playgroud)

建成后我得到了这个错误

Module "MyApp" was fully rebuilt due to project configuration/dependencies changes
Compilation completed with …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio

143
推荐指数
2
解决办法
17万
查看次数

标签 统计

android ×1

android-studio ×1

gradle ×1