首页 > 解决方案 > 使用开源的问题(无法解决com~~)

问题描述

大师。我刚刚开始开发 Android(kotlin)。我尝试为我的项目使用开源,但出现错误。我应该在这里做什么?(我提到了“https://androidexample365.com/customizable-timetableview-for-android/”)

我项目的 gradle(module)-------------------------------------------- --------------------------

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.akj.callback"
        minSdkVersion 23
        targetSdkVersion 30
        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
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}
dependencies {
    implementation 'com.github.islandparadise14:Mintable:x.y.z'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation "com.airbnb.android:lottie-compose:1.0.0-rc02-1"
}

我项目的 gradle(Project)-------------------------------------------- --------------------------

buildscript {
    ext.kotlin_version = "1.5.21"
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

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

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
        // Warning: this repository is going to shut down soon
        maven { url uri("https://jitpack.io") }
    }
}

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

我的项目的 xml------------------------------------------------------------ ----------------------------------

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".test_timetable">

    <com.islandparadise14.mintable.MinTimeTableView
        android:id="@+id/table"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    
</androidx.constraintlayout.widget.ConstraintLayout>

错误信息 - - - - - - - - - - - - - - - - - - - - - - - - -------------------------------------

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.github.islandparadise14:Mintable:x.y.z.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/github/islandparadise14/Mintable/x.y.z/Mintable-x.y.z.pom
       - https://repo.maven.apache.org/maven2/com/github/islandparadise14/Mintable/x.y.z/Mintable-x.y.z.pom
       - https://jcenter.bintray.com/com/github/islandparadise14/Mintable/x.y.z/Mintable-x.y.z.pom
       - https://jitpack.io/com/github/islandparadise14/Mintable/x.y.z/Mintable-x.y.z.pom
     Required by:
         project :app

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html`enter code here`

我没有触摸上述任何设置。我只想在我的项目中使用这个非源代码。我想解决这个问题。

标签: javaandroidgradle-kotlin-dslkotlin-android-extensions

解决方案


请参阅jitpack 页面上的参考。使用最新版本,或适合您目的的任何其他版本。

当您remote dependency在模块级 Gradle 文件(用 Groovy 或 Kotlin 编写)中声明 a 时,格式通常是这样的:

implementation '{package/group}:{module/project}:{versionNumber}'

// Example: 'com.example.android:app-magic:12.3'
// which is shorthand for:

implementation group: 'com.example.android', name: 'app-magic', version: '12.3'

有关更多信息,请参阅 Android文档

这里,模块/项目名称可能存在也可能不存在,因为库/模块的创建者生成或使用它通常是可选的。因此,对于 Mintable 项目,要使用最新版本,您将使用:

implementation 'com.github.islandparadise14:Mintable:1.5.1'  //in place of x.y.z

希望这些信息对未来也有帮助。一切顺利!


推荐阅读