[英]How to add StompProtocolAndroid to Android Studio gradle?
我是 java 及其构建脚本的新手。 我已经有了一个带有stomp
和sockjs
的 spring 引导消息服务。 我想从 android 应用程序发送和接收消息。 我想使用https://github.com/NaikSoftware/StompProtocolAndroid作为 stomp 客户端。 不过,我在设置它时遇到了问题。
我按照那方面描述的步骤进行操作,但它有点过时了。 那里链接的服务器示例https://github.com/NaikSoftware/stomp-protocol-example-server有一个build.gradle
文件,在我的 android 中有两个文件的混淆工作室有两个属性
我已经用默认build.gradle
文件清理了 android 工作室项目。 它们看起来像这样:
第一个文件:
// 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
项 scope 中的第二个文件。
它与警告正确同步: 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 应用程序中?
我发现我必须将maven { url 'https://jitpack.io' }
放入settings.gradle
文件中,而不是top-level build
文件,它现在可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.