我正在 Android Studio 中开发一个简单的音乐应用程序,我想导入以下项目 (https://github.com/hexise/jaudiotagger-android),以便更改手机上 .mp3 文件的元数据名称(如专辑名称)。 当我想在我的 Activity 中导入像 AudioFile 这样的类时:
import com.github.hexise.jaudioTagger.AudioFile;
我收到符号“github”无法解析的错误。
即使我将其导入到我的构建和settings.gradle中:
plugins {
id 'com.android.application'
}
android {
namespace 'com.example.musica'
compileSdk 34
defaultConfig {
applicationId "com.example.musica"
minSdk 24
targetSdk 34
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.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.github.hexise:jaudiotagger-android:'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "Musica"
include ':app'
Jiptpack 工件需要使用模式
com.github.User:Repo:Version
,因此你的语句存在三个错误:项目名称错误、没有使用冒号分隔不同部分以及版本完全丢失。
您需要指定要使用的版本。由于项目没有版本或标签,您需要使用要使用的提交哈希或分支名称+快照:
master-snapshot
。请参阅jiptpack文档https://jitpack.io/docs/
因此正确的导入语句将是 gor example
import com.github.hexise:jaudiotagger-android:master-SNAPSHOT