android - 新项目中未下载 Gradle 依赖项

标签 android android-studio gradle external-dependencies

我创建了一个新项目并试图包含一个外部依赖项:https://github.com/KirkBushman/ARAW

我希望当我向我的应用级 build.gradle 添加依赖项并重新同步我的项目时,外部依赖项会被下载。

这是我的一个项目文件结构的截图:

enter image description here

这是我当前的项目:

enter image description here

为什么我的新项目没有得到相同的“外部库”部分?这是我新项目的 build.gradle(app-level) 文件的样子:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29

    defaultConfig {
        applicationId "com.sometimestwo.jumblev2"
        minSdkVersion 26
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.navigation:navigation-fragment:2.1.0'
    implementation 'androidx.navigation:navigation-ui:2.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'com.github.KirkBushman:ARAW:v1.0.0-rc01' // what im trying to include

}

这是我新项目中的“顶级”build.gradle 文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.1"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }

    }

}

task clean(type: Delete) {
    delete rootProject.buildDir
}

最佳答案

Why aren't I getting the same "External Libraries" part in my new project?

在这些屏幕截图中显示的 Android Studio 部分的正上方,您会发现一个下拉列表或类似的选择器。

您的第一个屏幕截图可能已将其设置为项目:

Project View

您的第二个屏幕截图可能已将其设置为 Android,这是整体默认设置:

Android View

将新项目切换到项目 View ,您应该会看到树的外部库分支。

关于android - 新项目中未下载 Gradle 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63662443/

相关文章:

android - 在运行时拒绝和授予权限后在 Android 应用程序上获取 FileNotFoundException

java - 如何将形状或位图绘制到另一个位图中,Java/android

android - Android Studio错误:此文件夹不属于gradle项目(Jsoup.jar)

android - 如何在android studio中导入外部库?

Android Studio 找不到我导入的任何本地模块

spring-mvc - 我可以在Spring 4 MVC项目中使用Stylus和/或Jade吗?

java - Android 上未安装应用程序的应用程序链接

java - 无法在 SharedPreferences 中保存值

android - 自创库依赖于另一个自创库

gradle - 如何为每个 `repositories` block 或每个 RepositoryHandler 添加一个方法?