Android Studio:来自 github 的依赖项
Android Studio : Dependencies coming from github
我正在尝试在我的应用程序中包含一个操纵杆,来自这里:https://github.com/controlwear/virtual-joystick-android
Gradle 设置:
// 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.1.1'
// 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.tau.betterhovercraft"
minSdk 16
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.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'io.github.controlwear:virtualjoystick:1.10.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
我得到的错误是:
Error
我知道它试图找到这个图书馆,但它没有在 github 上搜索,我不知道如何告诉他。
我已经试过把这行写成:
maven { url "https://jitpack.io" }
然后:
implementation 'com.github.controlwear:virtualjoystick:1.10.1'
但我得到同样的错误
编辑:
好吧,我很笨,很抱歉给您带来不便,您只需将其放入 settings.gradle :
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
}
}
非常感谢你帮助我!
您是否已将 Maven 存储库添加到您的 allprojects 部分?
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}
编辑:根据 https://mvnrepository.com/artifact/io.github.controlwear/virtualjoystick?repo=jcenter,该库可在 jcenter()
上使用
在您的 settings.gradle
中添加 'jcenter()'
repositories {
google()
mavenCentral()
jcenter()
}
希望这能解决您的问题。谢谢。
我正在尝试在我的应用程序中包含一个操纵杆,来自这里:https://github.com/controlwear/virtual-joystick-android
Gradle 设置:
// 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.1.1'
// 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.tau.betterhovercraft"
minSdk 16
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.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'io.github.controlwear:virtualjoystick:1.10.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
我得到的错误是: Error
我知道它试图找到这个图书馆,但它没有在 github 上搜索,我不知道如何告诉他。
我已经试过把这行写成:
maven { url "https://jitpack.io" }
然后:
implementation 'com.github.controlwear:virtualjoystick:1.10.1'
但我得到同样的错误
编辑:
好吧,我很笨,很抱歉给您带来不便,您只需将其放入 settings.gradle :
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
}
}
非常感谢你帮助我!
您是否已将 Maven 存储库添加到您的 allprojects 部分?
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}
编辑:根据 https://mvnrepository.com/artifact/io.github.controlwear/virtualjoystick?repo=jcenter,该库可在 jcenter()
上使用在您的 settings.gradle
中添加 'jcenter()'repositories {
google()
mavenCentral()
jcenter()
}
希望这能解决您的问题。谢谢。