gpt4 book ai didi

android library release 启动时崩溃

转载 作者:太空宇宙 更新时间:2023-11-03 13:42:35 26 4
gpt4 key购买 nike

我创建了一个具有依赖关系的库,例如 dagger retrofit rxjava 等,在模块状态下它工作正常但是当我将它部署到 artifactory 并在一个新项目中编译它时,该项目一开始就崩溃了...

这是堆栈:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.yanivtwina.myapplication, PID: 13057
java.lang.NoClassDefFoundError: Failed resolution of: Ldagger/internal/Preconditions;
at com.galcomm.mobiklib.DaggerNetComponent$Builder.appModule(DaggerNetComponent.java:184)
at com.galcomm.mobiklib.MobikApp.onCreate(MobikApp.java:24)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "dagger.internal.Preconditions" on path: DexPathList[[zip file "/data/app/com.example.yanivtwina.myapplication-W0HdPexc2tZZOvAVgNzjIg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.yanivtwina.myapplication-W0HdPexc2tZZOvAVgNzjIg==/lib/arm64, /system/lib64, /vendor/lib64]]

这是我的库依赖项:

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.dagger:dagger:2.9'
compile 'com.squareup.retrofit2:retrofit:2.+'
compile 'com.squareup.retrofit2:converter-gson:2.+'
compile 'com.squareup.retrofit2:adapter-rxjava:2.+'
compile 'io.reactivex:rxjava:1.0.4'
compile "com.google.android.gms:play-services-gcm:11.0.4"
compile 'io.reactivex:rxandroid:0.24.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:23.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.9'
provided 'javax.annotation:jsr250-api:1.0'
compile 'com.evernote:android-job:1.1.8'
}

我的主要猜测是依赖关系不与 aar 文件或其他东西一起使用,有没有办法解决这个问题?在您的库中使用依赖项的最佳做法是什么?

非常感谢。

最佳答案

我遇到了同样的崩溃并通过将 Dagger 库添加到主项目 build.gradle 中解决了这个问题:

dependencies {
implementation(name:'libraryUsingDagger', ext:'aar')

implementation 'com.google.dagger:dagger:2.21'
annotationProcessor 'com.google.dagger:dagger-compiler:2.21'
}

关于android library release 启动时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48804901/

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