簡體   English   中英

如何將 StompProtocolAndroid 添加到 Android Studio gradle?

[英]How to add StompProtocolAndroid to Android Studio gradle?

我是 java 及其構建腳本的新手。 我已經有了一個帶有stompsockjs的 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM