gpt4 book ai didi

Android Gradle - 在 gradle 中实现 Apache POI 时无法解决错误

转载 作者:行者123 更新时间:2023-12-03 04:47:59 26 4
gpt4 key购买 nike

我正在尝试使用以下库 (https://github.com/SUPERCILEX/poi-android),以便我的应用程序可以读取 Word 文档的内容。我已尝试按照此类似问题的已接受答案中的说明进行操作:How to add POI Android in Android Studio?但无济于事。我的问题不同,因为我已经定义了 poiVersion我的项目级别的变量 build.gradle文件。

以下是错误:

ERROR: Failed to resolve: com.github.SUPERCILEX.poi-android:poi:3.17



下面是我的代码(项目级 build.gradle ):
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.60'
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
ext {
poiVersion = '3.17'
}
dependencies {
classpath 'com.android.tools:r8:1.4.93'
classpath 'com.android.tools.build:gradle:3.4.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()
jcenter()
}
}

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

下面是我的代码(应用级 build.gradle ):
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.diffchecker"
minSdkVersion 21
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(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.github.SUPERCILEX.poi-android:poi:$poiVersion"
}

最佳答案

您将存储库添加到构建脚本的依赖项,而不是项目中的模块。它应该在 allprojects 下- 也就是说,这一行:

maven { url 'https://jitpack.io' }

应该下移到这个 repositories阻止 allprojects项目级别的部分 build.gradle :
allprojects {
repositories {
google()
jcenter()
}
}

也就是说,该 block 最终应该是:
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

我已确认此更改使项目在 Android Studio 3.5 中正确同步。

关于Android Gradle - 在 gradle 中实现 Apache POI 时无法解决错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59926438/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com