CJR
CJR

Reputation: 3572

Error when importing library into Android project

I am trying to use this cool library here in my Android project.

On the github README it says:

How to use:

Import 'SkyconsLibrary' as a library to your project.

I did so by clicking file/new/import module and now it is in my Android project. However, when trying to use the library in my project I get these following errors:

Usage:

<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:

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

What do I need to do to use the library? I've never imported a library like this, usually I just add the path into my gradle file.

EDIT:

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.

Upvotes: 0

Views: 448

Answers (2)

Nick Titov
Nick Titov

Reputation: 598

You can add your library with this steps:

  1. Goto File -> New -> Import Module.
  2. Source Directory -> Browse the project path.
  3. Specify the Module Name – it is used for internal project reference.
  4. Open build.gradle (Module:app) file.
  5. Add the following line with your module name in place of “SkyconsLibrary” in the dependencies block:

    compile project(':SkyconsLibrary')

  6. After this Android Studio would start saying “gradle files have changed since last project sync”, press the “sync now” link to start a sync.

Thats it. Reference

Upvotes: 1

CommonsWare
CommonsWare

Reputation: 1006539

When you import a module into your project, that does not automatically add it as a dependency for any other modules in that project. You still need to add a compile statement, such as compile project(':SkyconsLibrary'), to the module(s) that need the library module that you imported.

I got a new error. What should I do now?

The error message tells you what to do:

Suggestion: add 'tools:replace="android:icon"' to element at AndroidManifest.xml:10:5-36:19 to override.

Upvotes: 1

Related Questions