我有一个由多个模块组成的应用程序,我刚从rxjava1更新到rxjava2。现在无法在Android 10设备或模拟器上安装它。在编译时,没有错误,但安装失败,无论是从Android工作室还是命令行。 这是我的一些设置:
compileSdkVersion = 25
buildToolsVersion = "25.0.1"
minSdkVersion = 10
targetSdkVersion = 21
正在运行./gradlew app:dependencies
compile - Classpath for compiling the main sources.
+--- com.android.support:appcompat-v7:25.3.1
| +--- com.android.support:support-annotations:25.3.1
| +--- com.android.support:support-v4:25.3.1
| | +--- com.android.support:support-compat:25.3.1
| | | \--- com.android.support:support-annotations:25.3.1
| | +--- com.android.support:support-media-compat:25.3.1
| | | +--- com.android.support:support-annotations:25.3.1
| | | \--- com.android.support:support-compat:25.3.1 (*)
| | +--- com.android.support:support-core-utils:25.3.1
| | | +--- com.android.support:support-annotations:25.3.1
| | | \--- com.android.support:support-compat:25.3.1 (*)
| | +--- com.android.support:support-core-ui:25.3.1
| | | +--- com.android.support:support-annotations:25.3.1
| | | \--- com.android.support:support-compat:25.3.1 (*)
| | \--- com.android.support:support-fragment:25.3.1
| | +--- com.android.support:support-compat:25.3.1 (*)
| | +--- com.android.support:support-media-compat:25.3.1 (*)
| | +--- com.android.support:support-core-ui:25.3.1 (*)
| | \--- com.android.support:support-core-utils:25.3.1 (*)
| +--- com.android.support:support-vector-drawable:25.3.1
| | +--- com.android.support:support-annotations:25.3.1
| | \--- com.android.support:support-compat:25.3.1 (*)
| \--- com.android.support:animated-vector-drawable:25.3.1
| \--- com.android.support:support-vector-drawable:25.3.1 (*)
+--- com.android.support:recyclerview-v7:25.3.1
| +--- com.android.support:support-annotations:25.3.1
| +--- com.android.support:support-compat:25.3.1 (*)
| \--- com.android.support:support-core-ui:25.3.1 (*)
+--- com.android.support:design:25.3.1
| +--- com.android.support:support-v4:25.3.1 (*)
| +--- com.android.support:appcompat-v7:25.3.1 (*)
| +--- com.android.support:recyclerview-v7:25.3.1 (*)
| \--- com.android.support:transition:25.3.1
| +--- com.android.support:support-annotations:25.3.1
| \--- com.android.support:support-v4:25.3.1 (*)
+--- com.google.android.gms:play-services-maps:7.5.0
| \--- com.google.android.gms:play-services-base:7.5.0
| \--- com.android.support:support-v4:22.0.0 -> 25.3.1 (*)
+--- com.google.android.gms:play-services-gcm:7.5.0
| \--- com.google.android.gms:play-services-base:7.5.0 (*)
+--- org.ocpsoft.prettytime:prettytime:3.2.4.Final
+--- com.google.maps.android:android-maps-utils:0.4
+--- com.fasterxml.jackson.core:jackson-databind:2.4.4
| +--- com.fasterxml.jackson.core:jackson-annotations:2.4.0
| \--- com.fasterxml.jackson.core:jackson-core:2.4.4 -> 2.8.7
+--- com.google.code.gson:gson:2.7
+--- com.jakewharton.timber:timber:4.3.1
+--- com.google.dagger:dagger:2.8
| \--- javax.inject:javax.inject:1
+--- com.jakewharton:butterknife:8.5.1
| +--- com.jakewharton:butterknife-annotations:8.5.1
| | \--- com.android.support:support-annotations:25.1.0 -> 25.3.1
| +--- com.android.support:support-annotations:25.1.0 -> 25.3.1
| \--- com.android.support:support-compat:25.1.0 -> 25.3.1 (*)
+--- com.getsentry.raven:raven-android:8.0.2
| \--- com.getsentry.raven:raven:8.0.2
| +--- org.slf4j:slf4j-api:1.7.24
| \--- com.fasterxml.jackson.core:jackson-core:2.8.7
+--- com.github.bumptech.glide:glide:3.8.0
+--- com.squareup.sqlbrite2:sqlbrite:2.0.0
| +--- io.reactivex.rxjava2:rxjava:2.1.0
| | \--- org.reactivestreams:reactive-streams:1.0.0
| \--- com.android.support:support-annotations:25.3.1
+--- io.reactivex.rxjava2:rxandroid:2.0.1
| \--- io.reactivex.rxjava2:rxjava:2.0.1 -> 2.1.0 (*)
+--- io.reactivex.rxjava2:rxjava:2.1.0 (*)
+--- project :domain
| +--- com.google.dagger:dagger:2.8 (*)
| +--- io.reactivex.rxjava2:rxandroid:2.0.1 (*)
| \--- io.reactivex.rxjava2:rxjava:2.1.0 (*)
+--- project :data
| +--- project :domain (*)
| +--- project :database
| | +--- com.jakewharton.timber:timber:4.3.1
| | +--- com.squareup.sqlbrite2:sqlbrite:2.0.0 (*)
| | +--- io.reactivex.rxjava2:rxandroid:2.0.1 (*)
| | \--- io.reactivex.rxjava2:rxjava:2.1.0 (*)
| +--- com.google.dagger:dagger:2.8 (*)
| +--- com.squareup.retrofit2:converter-gson:2.3.0
| | +--- com.squareup.retrofit2:retrofit:2.3.0
| | | \--- com.squareup.okhttp3:okhttp:3.8.0
| | | \--- com.squareup.okio:okio:1.13.0
| | \--- com.google.code.gson:gson:2.7
| +--- com.squareup.okhttp3:logging-interceptor:3.6.0
| | \--- com.squareup.okhttp3:okhttp:3.6.0 -> 3.8.0 (*)
| +--- com.squareup.retrofit2:adapter-rxjava2:2.3.0
| | +--- com.squareup.retrofit2:retrofit:2.3.0 (*)
| | \--- io.reactivex.rxjava2:rxjava:2.0.0 -> 2.1.0 (*)
| +--- com.jakewharton.timber:timber:4.3.1
| +--- com.squareup.sqlbrite2:sqlbrite:2.0.0 (*)
| +--- io.reactivex.rxjava2:rxandroid:2.0.1 (*)
| \--- io.reactivex.rxjava2:rxjava:2.1.0 (*)
\--- project :database (*)
我做了其他任何类似线程所说的一切,干净的项目,删除构建文件夹,我甚至在另一台计算机上开始了新的构建,所以没有办法在以前安装该应用程序。
如果我删除rxjava2和rxandroid2依赖项并注释掉所有使用它们的代码,那么该应用程序安装正常。一旦我重新启用它们,我就会再次收到错误。在研究上,错误是:
Installation failed since the device possibly has stale dexed jars
that don't match the current version (dexopt error).
In order to proceed, you have to uninstall the existing application.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
当然我说是的,即使我知道应用程序没有安装,当然也失败了。
我已尝试使用此工具计算方法 https://github.com/KeepSafe/dexcount-gradle-plugin 方法仍然低于64000,但即使我添加了multidex,如下所述:https://developer.android.com/studio/build/multidex.html 但它仍然无法正常工作! 我尝试过使用目标SDK,增加到25甚至buildtools到26,然后使用更新的gradle包装器(目前我在3.5),但没有,仍然是同样的问题。我不知道还有什么可以尝试而不是恢复到rxjava1,但我首先更新的原因是因为我有太多的项目并且在Android 10上得到OOME所以在阅读了这个https://github.com/ReactiveX/RxJava/wiki/What之后-in-2.0#which-type-to-use我决定升级。它没有说rxjava2与android 10不兼容的任何地方。 应用程序安装在Android 19 ++上很好(没有试过10和19之间) 我已经尝试了来自https://github.com/square/sqlbrite的示例,我将其更改为与api 10一起使用,并且它在android 10上安装得很好。 我还能尝试其他任何想法吗?
更新:这些是来自模拟器的日志:
56.584 1186-1207/system_process E/PackageManager: Package com.mypackage.myapp has mismatched uid: 10070 on disk, 10040 in settings
08-18 11:47:56.784 1853-1853/? E/dalvikvm: LinearAlloc exceeded capacity (5242880), last=220
08-18 11:47:56.784 1853-1853/? E/dalvikvm: VM aborting
08-18 11:47:56.804 1132-1132/? E/installd: dexopt failed on '/data/dalvik-cache/data@app@com.mypackage.myapp-1.apk@classes.dex' res = 11
更新2:我添加了proguard,即使在尝试安装发布版本时(使用proguard)仍会出现相同的错误
答案 0 :(得分:0)
不幸的是我没有找到任何其他解决方案而不是删除
com.fasterxml.jackson.core:jackson-databind
库。由于我也使用Gson,我只是使用该库修改代码来代替使用Gson。
当发现自己面临此错误时,不要浪费时间尝试添加multidex并配置为分成2个dex文件,这样做永远不会正常。
例如使用http://www.methodscount.com/检查所有lib,并找到一些可以删除或替换为较小库的大型库。
用于跟踪应用中方法计数的有用插件是https://github.com/KeepSafe/dexcount-gradle-plugin