importing ShowcaseView with gradle

江枫思渺然 提交于 2019-12-08 02:47:57

问题


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.


回答1:


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.




回答2:


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.




回答3:


It should actually be

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

That way Maven will use .AAR file




回答4:


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.




回答5:


I added this in build.gradle and it worked

compile 'com.github.amlcurran.showcaseview:library:5.4.3'


来源:https://stackoverflow.com/questions/23258446/importing-showcaseview-with-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!