【发布时间】:2022-01-15 20:04:07
【问题描述】:
我是 java 及其构建脚本的新手。我已经有了stomp 和sockjs 的spring boot 消息服务。我想从 Android 应用程序发送和接收消息。我想使用 https://github.com/NaikSoftware/StompProtocolAndroid 作为 stomp 客户端。不过,我在设置它时遇到了问题。
我按照那方面描述的步骤进行操作,但它有点过时了。链接到https://github.com/NaikSoftware/stomp-protocol-example-server 的服务器示例有一个build.gradle 文件,而在我的android studio 上有两个文件,所以我有点困惑将它们放在哪里。
我已经使用默认 build.gradle 文件清理了 android studio 项目。它们看起来像这样:
第一个文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
第二个文件:
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.chatapp"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'com.android.volley:volley:1.2.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
我将maven { url "https://jitpack.io" } 添加到mavenCentral() 正下方的第一个文件中
和implementation 'com.github.NaikSoftware:StompProtocolAndroid:{latest version}' 到dependencies 范围内的第二个文件。
它正确同步并带有警告:Failed to resolve: com.githubAffected Modules: <a href="someLongPath/app/build.gradle">app</a>
但是当我构建时,我得到了一大堆错误:
我试图打开它们的链接,但它返回“错误 404”,这意味着这些网站不存在。
我也用谷歌搜索了这个错误:Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
我找到了一些“修复”,但它们对我不起作用,可能它们也已经过时了。
如何将此库添加到我的 android 应用程序中?
【问题讨论】: