通过 Flutter 插件集成原生 Android 包

问题描述 投票:0回答:1

我正在从使用原生 android 包迁移到围绕该包制作一个 flutter 插件。在构建过程中,我遇到一个错误,表明在常用的存储库(Google、Maven Central 等)中找不到所需的依赖项。错误消息指出构建失败,因为无法解析

com.github.convertedin:android-pixel-sdk:1.4.4

错误:

出了什么问题: 任务“:app:checkStageReleaseDuplicateClasses”执行失败。 无法解析配置“:app:stageReleaseRuntimeClasspath”的所有文件。 找不到 com.github.convertedin:android-pixel-sdk:1.4.4。 在以下位置进行了搜索: https://dl.google.com/dl/android/maven2/com/github/convertedin/android-pixel-sdk/1.4.4/android-pixel-sdk-1.4.4.pom https://repo.maven.apache.org/maven2/com/github/convertedin/android-pixel-sdk/1.4.4/android-pixel-sdk-1.4.4.pom https://storage.googleapis.com/download.flutter.io/com/github/convertedin/android-pixel-sdk/1.4.4/android-pixel-sdk-1.4.4.pom https://jcenter.bintray.com/com/github/convertedin/android-pixel-sdk/1.4.4/android-pixel-sdk-1.4.4.pom https://sdk.uxcam.com/android/com/github/convertedin/android-pixel-sdk/1.4.4/android-pixel-sdk-1.4.4.pom 要求者: 项目:应用程序 > 项目:convertedin

com.github.convertedin:android-pixel-sdk:1.4.4
可通过 JitPack 获得,但构建系统不会自动检查 JitPack 的依赖关系。

构建.gradle


group = "com.petsegypt.convertedin"
version = "1.0-SNAPSHOT"

buildscript {
    ext.kotlin_version = "1.8.22"
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath("com.android.tools.build:gradle:8.1.0")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"

android {
    if (project.android.hasProperty("namespace")) {
        namespace = "com.petsegypt.convertedin"
    }

    compileSdk = 34

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }

    sourceSets {
        main.java.srcDirs += "src/main/kotlin"
        test.java.srcDirs += "src/test/kotlin"
    }

    defaultConfig {
        minSdk = 21
    }

    dependencies {
        testImplementation("org.jetbrains.kotlin:kotlin-test")
        testImplementation("org.mockito:mockito-core:5.0.0")
    }

    testOptions {
        unitTests.all {
            useJUnitPlatform()

            testLogging {
               events "passed", "skipped", "failed", "standardOut", "standardError"
               outputs.upToDateWhen {false}
               showStandardStreams = true
            }
        }
    }
}

dependencies {
    implementation 'com.github.convertedin:android-pixel-sdk:1.4.4'
}

我尝试过以下方法:

android flutter android-gradle-plugin flutter-dependencies flutter-plugin
1个回答
0
投票

您可以直接将

maven { url 'https://jitpack.io' }
添加到项目的
build.gradle
文件中,或者使用以下方法将其包含到插件中:

[rootProject, this].each {
    it.allprojects {
        repositories {
            maven { url 'https://jitpack.io' }
        }
    }
}

此设置将如下所示:

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

[rootProject, this].each {
    it.allprojects {
        repositories {
            maven { url 'https://jitpack.io' }
        }
    }
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"

参考: 1 2

© www.soinside.com 2019 - 2024. All rights reserved.