android - Android Studio 错误找不到模块项目参数的方法 android()
问题描述
尝试将 SendBird 消息添加到 Android 中的现有应用程序。
我将 SendBird ( https://github.com/smilefam/SendBird-Android ) 作为模块导入到 Android Studio 中的工作 Android 应用程序项目中。
获取此构建同步错误:
在 org.gradle.api.Project 类型的项目“:SendBird”上找不到参数 [build_cmuu8gl1t8ajvfzi59kru30vs$_run_closure1@20899a01] 的方法 android()。
此错误指向 SendBird build.gradle 文件作为问题。我在下面包含了项目和模块的 build.gradle 文件。
项目:VitalConcern8 build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'
classpath project(':SendBird')
classpath project(':app')
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
模块:app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.church.george.vitalconcern"
minSdkVersion 15
targetSdkVersion 26
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'org.apache.commons:commons-text:1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.volley:volley:1.1.0'
}
模块:SendBird build.gradle
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.sendbird.android.sample"
minSdkVersion 14
targetSdkVersion 28
versionCode getVersionCode()
versionName getVersionName()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
maven { url "https://raw.githubusercontent.com/smilefam/SendBird-SDK-Android/master/" }
google()
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// Required for local unit tests (JUnit 4 framework)
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// SendBird
implementation 'com.sendbird.sdk:sendbird-android-sdk:3.0.88'
// Android support libraries
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
// Firebase
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
// External libraries
implementation 'com.github.bumptech.glide:glide:4.3.1'
implementation 'org.jsoup:jsoup:1.11.2'
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
implementation 'com.github.stfalcon:multiimageview:0.1'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.library'
apply plugin: 'com.android.application'
解决方案
这是因为您的SendBird
build.gradle 中有以下代码:
apply plugin: 'com.android.library'
apply plugin: 'com.android.application'
您只需要以下内容:
apply plugin: 'com.android.library'
不要忘记将它作为 SendBird build.gradle 的第一行移动。您还需要从中删除它:
applicationId "com.sendbird.android.sample"
因为你不能有一个库模块的 applicationId 。
推荐阅读
- javascript - 将“3+5/2”之类的字符串转换为数字
- python - VSCode for Python 中的函数参数建议/自动完成
- django - 如何使用 django-filter 显示模型中的字段?
- css - 来自网络的 BG 图像有效,但文件夹图像无效
- regex - 重定向到公用文件夹,支持斜杠
- exception - Azure 管道出现错误:[错误]读取操作失败,请参阅 mac 托管代理上的内部异常
- java - Google CameraXBasic 停止在 android 10 上运行?
- amazon-cloudformation - 由于资源已存在于已删除的堆栈中,AWS CloudFormation 堆栈创建失败
- java - java/jackson问题,需要使用逻辑检查将JSON解析为Employee类型的列表(当前使用jackson)
- vb.net - 为什么我会收到“不必要的导入声明”