英文:
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 "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'
// 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
逐步说明:
- 然后将 git 项目检出到您的机器上。
- 修改并构建新版本。
- 在 Android Studio 中从您的本地文件系统添加依赖项作为 Jar 文件。
尝试以下操作:
<kbd>文件</kbd> > <kbd>项目结构</kbd> > <kbd>依赖项选项卡</kbd> > <kbd>添加模块依赖项</kbd> (<code>作用域 = 编译</code>)
其中模块依赖项是项目库 Android 文件夹。
英文:
Step by step description:
- Then ceck out the git project to your machine.
- Modify and build it with a new Version.
- Add the dipendency as Jar from Your local filesystem in Android Studio.
Try this:
<kbd>File</kbd> > <kbd>Project Structure</kbd> > <kbd>Dependencies Tab</kbd> > <kbd>Add module dependency</kbd> (<code>scope = compile</code>)
Where the module dependency is the project library Android folder.
答案2
得分: 0
或者像图片中所示编辑您的 gradle.build 文件:
答案3
得分: 0
这是您的逐步指南:
-
创建一个空项目或打开您要添加此库的现有项目。
-
从Git克隆库项目或下载zip并将其解压到其他目录中。
-
现在,在Android Studio中,转到
文件 -> 新建 -> 导入模块...
。选择克隆/解压缩的库目录。确保选择要导入的:placepicker
模块,然后点击完成
。 -
现在从克隆/解压缩的项目根目录中复制两个文件
bintray.gradle
和install.gradle
到您自己项目的根目录。在此时,您的项目结构应如下所示: -
现在打开您的项目级
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'
总体而言,将会是这样的:
-
最后,转到
文件 -> 使用Gradle文件同步项目
。下载缺失的依赖项需要一些时间,现在您已成功将该库完全集成到您的项目中,可以进行完全编辑。 -
现在,要使此库在您自己的应用模块中起作用,在您的应用模块的
build.gradle
文件中,在依赖项部分添加以下内容:
api project(':placepicker')
英文:
Here is your step-by-step guide:
-
Create an empty project or open your existing project where you want to add this library.
-
Clone the library project from the git or download the zip and extract it in some other directory.
-
Now, in Android Studio, go to
File -> New -> Import Module...
. Select the cloned/extracted library directory. Make sure the:placepicker
module is selected for import. Then clickFinish
.
- Now copy two files
bintray.gradle
andinstall.gradle
from cloned/extracted project root directory to your own project root directory. Add this point your project structure should look like this:
- Now open your project level
build.gradle
. Addext.kotlin_version = '1.3.72'
insidebuildscript {
and also add following dependencies:
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'
Overall, this will look like:
-
Finally, go to
File -> 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. -
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(':placepicker')
答案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 'com.google.android.gms:play-services-places:17.0.0'
let me knew if it's work.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论