importing ShowcaseView with gradle

2019-05-18 09:29发布

I'm trying to use the ShowcaseView project in my app but can't get the project to build.

when I run 'gradle clean installDebug' I get the following error:

A problem occurred evaluating root project 'hows-it-going'.

Could not find method compile() for arguments [project ':ShowcaseView'] on root project 'hows-it-going'.

I'm using gradle 1.11 and Android Studio 0.54.

I've downloaded the source, and imported the project using file -> Import module -> ShowcaseView
which makes my project structure like:

-project
--app
--ShowcaseView

my settings.gradle file looks like:

include ':app', 'ShowcaseView'


and in my project level build.gradle I have the following:

dependencies {
  compile project (':ShowcaseView')
}

Any help with how to include this properly would be much appreciated. Thanks.

5条回答
贼婆χ
2楼-- · 2019-05-18 09:44

I added this in build.gradle and it worked

compile 'com.github.amlcurran.showcaseview:library:5.4.3'
查看更多
老娘就宠你
3楼-- · 2019-05-18 09:48

It should actually be

compile 'com.github.amlcurran.showcaseview:library:5.0.0-SNAPSHOT@aar'

That way Maven will use .AAR file

查看更多
时光不老,我们不散
4楼-- · 2019-05-18 10:00

The latest version of ShowcaseView is available as a .AAR dependency. To use it, add:

repositories {
    mavenCentral()
    maven {
        url 'https://oss.sonatype.org/content/repositories/snapshots'
    }
}

To your build.gradle file and, under the dependencies block, add:

compile 'com.github.amlcurran.showcaseview:library:5.0.0-SNAPSHOT'

I'll get a stable, non-snapshot, version out soon.

查看更多
Melony?
5楼-- · 2019-05-18 10:01

I recently just added ShowcaseView to an Android Studio project, and I hope this can push you in the correct direction.

My file structure looks something like this:

  • project
    • app
      • build.gradle
    • libraries
      • showcase
    • build.gradle
    • settings.gradle

  1. Add the files from the library folder of ShowcaseView to the showcase directory in the libraries directory.

  2. Add the showcase directory as a module to your project.

  3. Change your app's build.gradle file to include:

    dependencies {
      compile project(':libraries:showcase')
    }
    
  4. Change your settings.gradle to include:

    include ':libraries:showcase'

  5. Sync Project with gradle files

This StackOverflow answer goes over how to do this is much more detail if you have any troubles, but this method works for any library.

查看更多
霸刀☆藐视天下
6楼-- · 2019-05-18 10:04

The compile dependency on ShowcaseView should likely be defined in app/build.gradle, not in the root project's build.gradle. Unless a project explicitly (configurations block) or implicitly (by applying a plugin such as java) defines a compile configuration, it won't have one, and an attempt to add a compile dependency will result in the error you mentioned.

查看更多
登录 后发表回答