将库导入Android项目时出错

时间:2016-12-26 16:41:28

标签: android

我正在尝试在我的Android项目中使用此cool library here

在github README上,它说:

  

使用方法:

     

将“SkyconsLibrary”导入项目库。

我是通过点击 file / new / import module 来实现的,现在它在我的Android项目中。但是,当我尝试在项目中使用该库时,我会收到以下错误:

用法

<com.thbs.skycons.library.SunView
    android:id="@+id/top_temp_icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="16dp"
    android:layout_marginTop="12dp"
    android:visibility="visible"
    app:layout_constraintBottom_toTopOf="@+id/time_zone"
    app:layout_constraintHorizontal_bias="1.0"
    app:layout_constraintLeft_toRightOf="@+id/temp_view"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:isStatic = "true"
    app:strokeColor = "#000000"
    app:bgColor = "#ffffff"/>

错误

Error: No resource identifier found for attribute 'isStatic' in package 'com.asus.MyApp'

使用该库需要做什么?我从未导入过这样的库,通常我只是将路径添加到我的gradle文件中。

修改

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@icon value=(@mipmap/ic_launcher) from AndroidManifest.xml:12:9-43
    is also present at [MyApp:SkyconsLibrary:unspecified] AndroidManifest.xml:13:9-29 value=(@null).
    Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:10:5-36:19 to override.

2 个答案:

答案 0 :(得分:1)

将模块导入项目时,不会自动将其添加为该项目中任何其他模块的依赖项。您仍然需要向需要导入的库模块的模块添加compile语句,例如compile project(':SkyconsLibrary')

  

我收到了一个新错误。我现在该怎么办?

错误消息告诉您该怎么做:

  

建议:在AndroidManifest.xml:10:5-36:19中添加'tools:replace =“android:icon”'以覆盖。

答案 1 :(得分:1)

您可以使用以下步骤添加库:

  1. 转到文件 - &gt;新 - &gt;导入模块。
  2. 来源目录 - &gt;浏览项目路径。
  3. 指定模块名称 - 用于内部项目参考。
  4. 打开build.gradle(Module:app)文件。
  5. 使用您的模块名称添加以下行代替依赖项块中的“SkyconsLibrary”:

    编译项目(':SkyconsLibrary')

  6. 此Android Studio开始说“自上次项目同步后gradle文件已更改”,请按“立即同步”链接开始同步。

  7. 多数民众赞成。 Reference