gpt4 book ai didi

java - 如何在 gradle 3 或更高版本中使用 jar 文件?

转载 作者:行者123 更新时间:2023-12-03 05:06:38 25 4
gpt4 key购买 nike

在我的项目中,“app”模块还使用放置在其依赖模块之一中的 jar 库。当我使用 Gradle 2 和 Gradle Plugin 2.3 时效果很好。然后我将 Gradle 版本更新为 5.1.1 并将 Android Gradle 插件版本更新为 3.4.2 并遇到以下问题。

如果我将 jar 放在两个模块的 libs 文件夹中,则会出现第一个屏幕截图中的错误。但是,如果我删除“app”模块中的 jar,它只是无法识别 jar 中的类,如第二个屏幕截图所示。当我使用旧的 Gradle 时,它​​能够使用这些类。

Error when putting the jar in both modules

Error when removing the jar from app module

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13-beta-3'
implementation 'me.zhanghai.android.materialratingbar:library:1.3.2'

implementation 'com.flurry.android:analytics:11.6.0@aar'

implementation project(':dayWeekLib')
implementation (project(':zappasoft-android-support-library'))
// {
// exclude module: 'libs/YouTubeAndroidPlayerApi'
// exclude group: 'com.google.android.youtube.player'
// }

implementation ('androidx.appcompat:appcompat:1.0.2')

implementation ('com.google.android.material:material:1.0.0')

implementation ('androidx.recyclerview:recyclerview:1.0.0')

implementation ('androidx.legacy:legacy-support-v13:1.0.0')

implementation 'org.apache.httpcomponents:httpcore:4.4.11'
implementation 'org.apache:apache:21'
implementation 'com.google.android.gms:play-services-plus:17.0.0'
implementation 'com.google.apis:google-api-services-youtube:v3-rev112-1.19.0'
implementation 'com.google.http-client:google-http-client-android:1.30.2'
implementation 'com.google.api-client:google-api-client-android:1.30.2'
implementation 'com.google.api-client:google-api-client-gson:1.30.2'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.okhttp3:okhttp:4.0.1'

implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
implementation 'com.github.barteksc:android-pdf-viewer:+'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31'
implementation 'se.emilsjolander:stickylistheaders:2.7.0'
implementation 'com.google.code.ksoap2-android:ksoap2-android:3.6.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'

implementation ('androidx.core:core:1.0.0')

implementation 'org.greenrobot:greendao:3.2.2'

implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.chrisbanes:PhotoView:2.1.0'
implementation 'com.opencsv:opencsv:4.4'
implementation 'xmlwise:xmlwise:1.2.11'

implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
}

最佳答案

I think you implementation is wrong. First you have to put your jar file in your libs folder. then in your gradle add implementation
files('libs/your_jar.jar')

关于java - 如何在 gradle 3 或更高版本中使用 jar 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57088060/

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