无法将库添加到Android Studio项目

huangapple go评论88阅读模式
英文:

Unable to add library to Android Studio project

问题

我正尝试将这个库本地添加到Android Studio,使用这个YouTube教程

然而,我遇到了无法在此处贴出的错误,因为它们太多了(99+)。

有人能否详细地逐步告诉我如何成功将这个库添加到我的项目中,并且以后能够对其进行编辑?

当我尝试导入这个库时,我得到的主要错误是:`无法确定构造函数参数#1:缺少类型为Factory的参数,或者没有类型为Factory的服务。

我的build.gradle:

// 顶层构建文件,您可以在其中添加所有子项目/模块共有的配置选项。
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"

    classpath 'com.github.dcendents:android-maven-plugin:1.2'
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'

    classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

    // 注意:不要在此处放置应用程序依赖项;它们属于各个模块build.gradle文件中
}

}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

英文:

I'm trying to add this library to Android Studio locally using this tutorial on YouTube.

However, I get errors that I can't post here because they're too many (99+).

Can someone tell me step by step (in detail) how to succesfully add this library to my project and be able to edit it afterwards?

This is the main error I get when I try to import this library: `Unable to determine constructor argument #1: missing parameter of type Factory, or no service of type Factory<LoggingManagerInternal>.

My build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath &quot;com.android.tools.build:gradle:4.0.0&quot;
        classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72&quot;


        classpath &#39;com.github.dcendents:android-maven-plugin:1.2&#39;
        classpath &#39;com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4&#39;

        classpath &#39;com.github.dcendents:android-maven-gradle-plugin:2.1&#39;

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

答案1

得分: 0

逐步说明:

  1. 然后将 git 项目检出到您的机器上。
  2. 修改并构建新版本。
  3. 在 Android Studio 中从您的本地文件系统添加依赖项作为 Jar 文件。

无法将库添加到Android Studio项目尝试以下操作:
<kbd>文件</kbd> &gt; <kbd>项目结构</kbd> &gt; <kbd>依赖项选项卡</kbd> &gt; <kbd>添加模块依赖项</kbd> (<code>作用域 = 编译</code>)

其中模块依赖项是项目库 Android 文件夹。

英文:

Step by step description:

  1. Then ceck out the git project to your machine.
  2. Modify and build it with a new Version.
  3. Add the dipendency as Jar from Your local filesystem in Android Studio.

无法将库添加到Android Studio项目Try this:
<kbd>File</kbd> &gt; <kbd>Project Structure</kbd> &gt; <kbd>Dependencies Tab</kbd> &gt; <kbd>Add module dependency</kbd> (<code>scope = compile</code>)

Where the module dependency is the project library Android folder.

答案2

得分: 0

或者像图片中所示编辑您的 gradle.build 文件:

无法将库添加到Android Studio项目

英文:

Or edit your gradle.build like in the picture:

无法将库添加到Android Studio项目

答案3

得分: 0

这是您的逐步指南:

  1. 创建一个空项目或打开您要添加此库的现有项目。

  2. 从Git克隆库项目或下载zip并将其解压到其他目录中。

  3. 现在,在Android Studio中,转到文件 -&gt; 新建 -&gt; 导入模块...。选择克隆/解压缩的库目录。确保选择要导入的:placepicker模块,然后点击完成

  4. 现在从克隆/解压缩的项目根目录中复制两个文件bintray.gradleinstall.gradle到您自己项目的根目录。在此时,您的项目结构应如下所示:

  5. 现在打开您的项目级build.gradle。在buildscript {内添加ext.kotlin_version = '1.3.72',并且还要添加以下依赖项:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

总体而言,将会是这样的:

  1. 最后,转到文件 -&gt; 使用Gradle文件同步项目。下载缺失的依赖项需要一些时间,现在您已成功将该库完全集成到您的项目中,可以进行完全编辑。

  2. 现在,要使此库在您自己的应用模块中起作用,在您的应用模块的build.gradle文件中,在依赖项部分添加以下内容:

api project(':placepicker')

英文:

Here is your step-by-step guide:

  1. Create an empty project or open your existing project where you want to add this library.

  2. Clone the library project from the git or download the zip and extract it in some other directory.

  3. Now, in Android Studio, go to File -&gt; New -&gt; Import Module.... Select the cloned/extracted library directory. Make sure the :placepicker module is selected for import. Then click Finish.

无法将库添加到Android Studio项目

  1. Now copy two files bintray.gradle and install.gradle from cloned/extracted project root directory to your own project root directory. Add this point your project structure should look like this:

无法将库添加到Android Studio项目

  1. Now open your project level build.gradle. Add ext.kotlin_version = &#39;1.3.72&#39; inside buildscript { and also add following dependencies:
classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version&quot;
classpath &#39;com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5&#39;
classpath &#39;com.github.dcendents:android-maven-gradle-plugin:2.1&#39;

Overall, this will look like:

无法将库添加到Android Studio项目

  1. Finally, go to File -&gt; Sync Project with Gradle Files. It will take some time to download the missing dependencies and you have now successfully integrated the library within your project which is fully editable.

  2. Now to make this library work in your own app module, in the build.gradle file of your app module, add this inside dependencies section:

api project(&#39;:placepicker&#39;)

答案4

得分: 0

在 build.gradle(Module.app) 文件中添加以下内容:

implementation 'com.google.android.gms:play-services-places:17.0.0'

如果可以的话,请告诉我是否有效。

英文:

In build.gradle(Module.app) file add this.

implementation &#39;com.google.android.gms:play-services-places:17.0.0&#39;

let me knew if it's work.

huangapple
  • 本文由 发表于 2020年5月30日 06:28:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/62095478.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定