问题描述
我创建了一个新项目,并试图包括一个外部依赖项:https://github.com/KirkBushman/ARAW
我希望当我在应用程序级别build.gradle
中添加依赖项并重新同步项目时,外部依赖项会被下载。
这是我的 old 项目之一的文件截图:
这是我当前的项目:
为什么在新项目中没有得到相同的“外部库”部分?这是新项目的build.gradle(应用程序级)文件的样子:
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
}
解决方法
为什么我的新项目没有得到相同的“外部库”部分?
在这些屏幕快照中显示的Android Studio部分的紧上方,您会找到一个下拉列表或类似的选择器。
您的第一个屏幕截图可能已将其设置为Project:
您的第二张屏幕截图可能已将其设置为Android,这是整体默认设置:
将新项目切换到“项目”视图,您应该看到树的“外部库”分支。