代码之家  ›  专栏  ›  技术社区  ›  EugeneS

我无法从github连接库

  •  -1
  • EugeneS  · 技术社区  · 7 月前
    Failed to resolve: com.jcodecraeer:xrecyclerview:1.6.0
    Failed to resolve: com.github.smarteist:autoimageslider:1.1.1
    Failed to resolve: com.android.volley:volley:1.1.1
    Failed to resolve: com.pierfrancescosoffritti.androidyoutubeplayer:core:8.0.1
    Failed to resolve: tv.danmaku.ijk.media:ijkplayer-java:0.8.8
    Failed to resolve: tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8
    Failed to resolve: tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8
    Failed to resolve: tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8
    Failed to resolve: tv.danmaku.ijk.media:ijkplayer-x86:0.8.8
    Failed to resolve: tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8
    

    我的build.gradle(应用程序)文件

    apply plugin: 'com.android.application'
    
    android {
    compileSdkVersion 34
    namespace "com.androworld.player.video_player"
    defaultConfig {
        applicationId "com.androworld.player.video_player"
        minSdkVersion 21
        targetSdkVersion 34
        versionCode 40
        versionName "4.2.8"
        multiDexEnabled true
        ndk {
            // config you want to support device
            abiFilters 'arm64-v8a', 'armeabi', 'armeabi-v7a', 'x86'
        }
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        debugMini {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    configurations.all {
        resolutionStrategy {
            force 'androidx.annotation:annotation:1.2.0'
        }
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion '28.0.0'
                }
    
            }
    
        }
    
    }
    
    //    sourceSets.main {
    //        jniLibs.srcDirs 'src/main/libs'
    //    }
    
    }
    
    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //noinspection GradleCompatible
    //implementation 'androidx.annotation:annotation:1.2.0'
    //implementation 'androidx.annotation:annotation-jvm:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    //support
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'com.jcodecraeer:xrecyclerview:1.6.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
    //vector,percent,palette
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.percentlayout:percentlayout:1.0.0'
    implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
    //equlizer
    implementation 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2'
    implementation 'com.joanzapata.iconify:android-iconify-entypo:2.2.2'
    //    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    
    implementation 'com.github.smarteist:autoimageslider:1.1.1'
    //data
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'org.apache.commons:commons-io:1.3.2'
    //youtubeplayer
    implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:8.0.1'
    //    implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:10.0.5'
    //Ads
    //implementation 'com.google.android.gms:play-services-ads:20.4.0'
    //intro_screen
    implementation project(':material-intro-screen')
    //player
    implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
    implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
    implementation 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
    implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
    implementation 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
    implementation 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'
    
    //    implementation project(':ijkplayer-java')
    //    implementation 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
    
    //    implementation project(':xvideoplayer')
    //    implementation 'com.henryblue.mxvideoplayer:xvideoplayer:1.2.1'
    implementation 'com.firebase:firebase-client-android:2.5.0'
    implementation 'com.yandex.android:mobileads:5.10.0'
    implementation 'com.yandex.android:mobmetricalib:5.0.0'
    //implementation 'com.google.android.gms:play-services-ads:17.2.1'
    
    //implementation 'com.facebook.android:audience-network-sdk:5.3.0'
    
    implementation 'androidx.work:work-runtime-ktx:2.7.1' //no started android api 32
    }
    

    settings.gradle(项目)

    pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
        maven { url "https://www.jitpack.io" }
    }
    }
    
    plugins {
    id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
    }
    
    dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Note: JCenter is deprecated and should be avoided if possible
        maven { url "https://www.jitpack.io" }
        maven {
            url "https://artifactory-external.vkpartner.ru/artifactory/maven"
        }
        maven { url 'https://dl.bintray.com/yandexmobile/maven' } // Likely deprecated, use 
    alternatives
        maven { url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven- 
    repository/" }
        maven { url "https://dl.bintray.com/theartofdev/Edmodo" } // Deprecated
    }
    }
    
    include ':app', ':material-intro-screen'
    
    1 回复  |  直到 7 月前
        1
  •  1
  •   CommonsWare    7 月前

    交叉发布此材料来自 my blog :


    虽然这可能有几个原因,但正是这个原因让很多开发人员感到困惑 现在源于这样一个事实,即许多图书馆出版商使用的JCenter的Maven存储库, 不再存在。

    对于积极发布的库,库开发人员现在应该已经搬到了其他地方。 对于许多开发人员来说,最好的答案是Maven Central,尽管有些人还有其他选择。 例如,谷歌通过自己的Maven存储库提供了最新版本的Volley。

    然而,有很多图书馆没有积极出版。这些可能已经永远消失了。

    JCenter的变化不会同时影响每个人的原因归结为Gradle 缓存。Gradle缓存工件,只在需要时尝试下载它们,例如:

    • 添加新的库依赖项
    • 更改要使用的依赖项的版本
    • 你的Gradle工件缓存被清除
    • 你试着在一台比以前新的机器上建造

    后两者可能是导致JCenter相关悲伤最多的原因。有些人建造 以前工作过,可能在其他地方工作(例如,在同事的机器上)对你不起作用, 因为“其他地方”缓存了工件,而你没有。使用CI服务器进行检索的团队 每个构建中的工件可能在JCenter关闭后的一天内就被发现了。那些使用 仅仅是本地构建的机器可能几年都不会发现,这取决于它们保存了多长时间 Gradle工件缓存周围。


    那么,如果你被抓到了,你会怎么做?

    首先,在“互联网”上搜索图书馆,看看是否有关于它的网站 这些库是在GitHub等地方公开开发的。查看该网站是否有说明 对于一些较新的维护版本,并迁移到它。相反,如果库尚未 多年来的更新, 拜托 考虑转向积极维护的东西。

    你也可以搜索 MvnRepository 这是一个包含多个元素的索引 不同的工件存储库,包括Maven Central和谷歌的Maven存储库。它曾经 索引JCenter,它还有一些其他不太常见的Maven存储库。也许你会发现 您需要的特定工件的另一个来源。然而, 小心 当取决于 在你要求成为的更随机的存储库中的半随机库上 供应链攻击的受害者。

    如果源代码在GitHub或其他地方可用,您可以分叉源代码并维护自己的 复制。无论你是向公众开放(例如,在Maven Central上)还是只是分享它 你的团队由你决定。Maven Local是一种快速而肮脏的方式,可以在 你的手工艺品机器。设置私有共享存储库(例如通过Amazon S3)是 非常可行,尽管有点晦涩难懂。

    展望未来,我们的目标是定期在清洁的环境中进行清洁建设。即使你没有 选择从事夜间CI服务器工作,每月在缺乏以下功能的环境中进行一次构建 Gradle缓存。这些构建的部分价值在于更快速地识别这样的问题, 因此,您可以在问题开始影响单个开发人员的生产力之前采取措施。