2016-12-26 154 views
0

我正在尝试在我的Android项目中使用此cool library here将库导入Android项目时出错

在GitHub的README它说:

使用方法:

导入 'SkyconsLibrary' 作为库到您的项目。

我这样做是通过点击文件/新建/导入模块而现在它在我的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 [email protected] 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. 
+0

您是否已将'compile project(':SkyconsLibrary')'添加到您的应用的'build.gradle'文件中? (假设你的模块命名为SkyconsLibrary) – CommonsWare

+0

@CommonsWare不,我没有,但我刚刚添加它,并且我得到了一个新的错误。我现在应该怎么做? – Carlton

回答

1

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

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

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

建议:添加 '工具:更换= “机器人:图标”' 到元件的AndroidManifest.xml中:10:5-36:19覆盖。

+0

非常感谢! – Carlton

1

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

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

    编译项目(“:SkyconsLibrary”)

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

那就是它。 Reference