尝试将SendBird消息添加到Android中的现有应用。
我将SendBird(https://github.com/smilefam/SendBird-Android)作为模块导入到Android Studio中正在运行的Android应用程序项目中。
出现此构建同步错误:
找不到方法android()作为参数 项目中的[build_cmuu8gl1t8ajvfzi59kru30vs $ _run_closure1 @ 20899a01] 类型为org.gradle.api.Project的':SendBird'。
此错误将直接发送到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
}
模块:应用程序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'
答案 0 :(得分:0)
这是因为您的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。