2

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

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

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

在此处输入图像描述

这是我目前的项目:

在此处输入图像描述

为什么我在新项目中没有获得相同的“外部库”部分?这是我的新项目的 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
}
4

1 回答 1

1

为什么我在新项目中没有获得相同的“外部库”部分?

在您在这些屏幕截图中显示的 Android Studio 部分的正上方,您会找到一个下拉菜单或类似类型的选择器。

您的第一个屏幕截图可能已设置为 Project:

项目视图

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

安卓视图

将新项目切换到 Project 视图,您应该会看到树的 External Libraries 分支。

于 2020-08-30T21:52:25.300 回答