我正在使用Android P并针对AndroidX进行编译。在调试/测试版中效果很好,但是当我发布一个版本时,在运行时出现了一个神秘的崩溃:
2018-06-24 00:21:26.080 11971-11971 /? E / LoadedApk:无法 实例化appComponentFactory java.lang.ClassNotFoundException:在路径:DexPathList上找不到类“ androidx.core.app.CoreComponentFactory” 文件 “ /data/app/app.itsyour.elegantstocks-EuVZWdDgzplhm0Hpa90VwA==/base.apk"],nativeLibraryDirectories=[/data/app/app.itsyour.elegantstocks-EuVZWdDgzplhm0Hpa90VwA==/lib/x86 / system / lib]] 在dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:126) 在java.lang.ClassLoader.loadClass(ClassLoader.java:379) 在java.lang.ClassLoader.loadClass(ClassLoader.java:312) 在android.app.LoadedApk.createAppFactory(LoadedApk.java:226) 在android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:731) 在android.app.LoadedApk.getClassLoader(LoadedApk.java:772) 在android.app.LoadedApk.getResources(LoadedApk.java:994) 在android.app.ContextImpl.createAppContext(ContextImpl.java:2345) 在android.app.ActivityThread.handleBindApplication(ActivityThread.java:5736) 在android.app.ActivityThread.access $ 1000(ActivityThread.java:197) 在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1634) 在android.os.Handler.dispatchMessage(Handler.java:106) 在android.os.Looper.loop(Looper.java:193) 在android.app.ActivityThread.main(ActivityThread.java:6642) 在java.lang.reflect.Method.invoke(本机方法) 在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:493) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 2018-06-24 00:21:26.145 1667-1854 /? E / SurfaceFlinger: ro.sf.lcd_density必须定义为构建属性2018-06-24 00:21:26.233 1667-1703 /? E / SurfaceFlinger:ro.sf.lcd_density必须为 定义为构建属性2018-06-24 00:21:29.627 1796-1913 /? E / TaskPersister:访问最新目录(目录的文件错误) 不存在?)。 2018-06-24 00:21:30.087 11971-11971 /? E / AndroidRuntime:致命异常:main 工艺:app.itsyour.elegantstocks,PID:11971 java.lang.IllegalArgumentException:指定为非null的参数为null:方法c.d.b.h.b,参数$ receiver 在app.itsyour.elegantstocks.a.b.a(未知来源:2) 在app.itsyour.elegantstocks.feature.navigator.b.a $ a.a(未知来源:24) 在app.itsyour.elegantstocks.feature.navigator.b.a.a(未知来源:13) 在app.itsyour.elegantstocks.feature.navigator.b.a.a(未知来源:2) 在androidx.recyclerview.widget.RecyclerView $ a.a(未知来源:0) 在androidx.recyclerview.widget.RecyclerView $ a.b(未知来源:29) 在androidx.recyclerview.widget.RecyclerView $ p.a(未知来源:39) 在androidx.recyclerview.widget.RecyclerView $ p.a(未知来源:510) 在androidx.recyclerview.widget.RecyclerView $ p.a(未知来源:5) 在androidx.recyclerview.widget.RecyclerView $ p.c(未知来源:1) 在androidx.recyclerview.widget.LinearLayoutManager $ c.a(未知 资料来源:11) 在androidx.recyclerview.widget.LinearLayoutManager.a(未知来源:0) 在androidx.recyclerview.widget.LinearLayoutManager.a中(未知来源:44) 在androidx.recyclerview.widget.LinearLayoutManager.c中(未知来源:371) 在androidx.recyclerview.widget.RecyclerView.O(未知来源:42) 在androidx.recyclerview.widget.RecyclerView.q(未知来源:41) 在androidx.recyclerview.widget.RecyclerView.onLayout(未知来源:5) 在android.view.View.layout(View.java:20670) 在android.view.ViewGroup.layout(ViewGroup.java:6194) 在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) 在android.widget.FrameLayout.onLayout(FrameLayout.java:261) 在android.view.View.layout(View.java:20670) 在android.view.ViewGroup.layout(ViewGroup.java:6194) 在androidx.constraintlayout.widget.ConstraintLayout.onLayout(未知 资料来源:66) 在android.view.View.layout(View.java:20670) 在android.view.ViewGroup.layout(ViewGroup.java:6194) 在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) 在android.widget.FrameLayout.onLayout(FrameLayout.java:261) 在android.view.View.layout(View.java:20670) 在android.view.ViewGroup.layout(ViewGroup.java:6194) 在androidx.swiperefreshlayout.widget.SwipeRefreshLayout.onLayout(未知 资料来源:60) 在android.view.View.layout(View.java:20670) 在android.view.ViewGroup.layout(ViewGroup.java:6194) 在androidx.coordinatorlayout.widget.CoordinatorLayout.d(未知 资料来源:143) 在androidx.coordinatorlayout.widget.CoordinatorLayout.a(未知 资料来源:32) 在androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(未知 资料来源:48) 在android.view.View.layout(View.java:20670) 在android.view.ViewGroup.layout(ViewGroup.java:6194) 在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) 在android.widget.FrameLayout.onLayout(FrameLayout.java:261) 在android.view.View.layout(View.java:20670) 在android.view.ViewGroup.layout(ViewGroup.java:6194) 在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) 在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) 在android.widget.LinearLayout.onLayout(LinearLayout.java:1565) 在android.view.View.layout(View.java:20670) 在android.view.ViewGroup.layout(ViewGroup.java:6194) 在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) 在android.widget.FrameLayout.onLayout(FrameLayout.java:261) 在android.view.View.layout(View.java:20670) 在android.view.ViewGroup.layout(ViewGroup.java:6194) 在android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) 在android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) 在android.widget.LinearLayout.onLayout(LinearLayout.java:1565) 在android.view.View.layout(View.java:20670) 在android.view.ViewGroup.layout(ViewGroup.java:6194) 在android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) 在android.widget.FrameLayout.onLayout(FrameLayout.java:261) 在com.android.internal.policy.DecorView.onLayout(DecorView.java:753) 在android.view.View.layout(View.java:20670)2018-06-24 00:21:30.087 11971-11971 /? E / AndroidRuntime:位于 android.view.ViewGroup.layout(ViewGroup.java:6194) 在android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2767) 在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2294) 在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1447) 在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:7130) 在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:935) 在android.view.Choreographer.doCallbacks(Choreographer.java:747) 在android.view.Choreographer.doFrame(Choreographer.java:682) 在android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:921) 在android.os.Handler.handleCallback(Handler.java:873) 在android.os.Handler.dispatchMessage(Handler.java:99) 在android.os.Looper.loop(Looper.java:193) 在android.app.ActivityThread.main(ActivityThread.java:6642) 在java.lang.reflect.Method.invoke(本机方法) 在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:493) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 2018-06-24 00:21:30.137 1796-1880 /? E / InputDispatcher:通道 '5896582 app.itsyour.elegantstocks / app.itsyour.elegantstocks.feature.navigator.NavigatorActivity (服务器)'〜通道无法恢复,将被处置! 2018-06-24 00:21:30.253 5198-9377 /? E / EntrySyncManager:无法 确定帐户名称:删除请求2018-06-24 00:21:30.253 5198-9377 /? E / NowController:无法从EntryProvider访问数据。 ExecutionException。 java.util.concurrent.ExecutionException:com.google.android.apps.gsa.sidekick.main.h.n:无法完成 计划的刷新条目请求。 ClientErrorCode:3 在com.google.common.util.concurrent.d.eA(SourceFile:85) 在com.google.common.util.concurrent.d.get(SourceFile:23) 在com.google.common.util.concurrent.l.get(SourceFile:2) 在com.google.android.apps.gsa.staticplugins.nowstream.b.a.be.caI(SourceFile:47) 在com.google.android.apps.gsa.staticplugins.nowstream.b.a.be.caH(SourceFile:176) 在com.google.android.apps.gsa.staticplugins.nowstream.b.a.bh.run(未知 资料来源:2) 在com.google.android.apps.gsa.shared.util.concurrent.at.run(SourceFile:4) 在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:458) 在java.util.concurrent.FutureTask.run(FutureTask.java:266) 在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:458) 在java.util.concurrent.FutureTask.run(FutureTask.java:266) 在com.google.android.apps.gsa.shared.util.concurrent.b.g.run(未知 资料来源:4) 在com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4) 在com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:641) 在java.lang.Thread.run(Thread.java:764) 在com.google.android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6) 原因:com.google.android.apps.gsa.sidekick.main.h.n:无法完成预定的刷新条目请求。 ClientErrorCode:3 位于com.google.android.apps.gsa.staticplugins.nowstream.b.a.aq.az(未知 资料来源:4) 在com.google.common.util.concurrent.q.ap(SourceFile:7) 在com.google.common.util.concurrent.p.run(SourceFile:32) 在com.google.common.util.concurrent.bt.execute(SourceFile:3) 在com.google.common.util.concurrent.d.b(SourceFile:275) 在com.google.common.util.concurrent.d.addListener(SourceFile:135) 在com.google.common.util.concurrent.p.b(SourceFile:3) 在com.google.android.apps.gsa.shared.util.concurrent.h.a(SourceFile:16) 在com.google.android.apps.gsa.shared.util.concurrent.h.a(SourceFile:13) 在com.google.android.apps.gsa.staticplugins.nowstream.b.a.be.caI(SourceFile:45) 在com.google.android.apps.gsa.staticplugins.nowstream.b.a.be.caH(SourceFile:176) 在com.google.android.apps.gsa.staticplugins.nowstream.b.a.bh.run(未知 资料来源:2) 在com.google.android.apps.gsa.shared.util.concurrent.at.run(SourceFile:4) 在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:458) 在java.util.concurrent.FutureTask.run(FutureTask.java:266) 在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:458) 在java.util.concurrent.FutureTask.run(FutureTask.java:266) 在com.google.android.apps.gsa.shared.util.concurrent.b.g.run(未知 资料来源:4) 在com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4) 在com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:641) 在java.lang.Thread.run(Thread.java:764) 在com.google.android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6)
我的gradle文件。 项目gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
androidXVersion = '1.0.0-alpha3'
supportLibraryVersion = '28.0.0-alpha1'
}
buildscript {
ext.kotlin_version = '1.2.50'
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-beta01'
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()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
def versionMajor = 1
def versionMinor = 0
def versionPatch = project.hasProperty('buildNumber') ? project.getProperties().get('buildNumber').toInteger() : 0
android {
compileSdkVersion 28
defaultConfig {
applicationId "app.itsyour.elegantstocks"
minSdkVersion 25
targetSdkVersion 28
// Version
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
versionCode versionMajor * 1000000 * versionMinor * 10000 + versionPatch
resValue "string", "build_number", "Version ${versionName}"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
}
}
buildTypes {
release {
resValue "string", "app_name", "Elegant Stocks"
signingConfig signingConfigs.release
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-release.pro'
}
staging {
resValue "string", "app_name", "Elegant Stocks"
signingConfig signingConfigs.staging
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-staging.pro'
}
beta {
signingConfig signingConfigs.beta
debuggable true
minifyEnabled false
applicationIdSuffix ".beta"
versionNameSuffix "-BETA"
resValue "string", "app_name", "Elegant Stocks Beta"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-beta.pro'
}
debug {
debuggable true
minifyEnabled false
resValue "string", "app_name", "Elegant Stocks Debug"
applicationIdSuffix ".debug"
versionNameSuffix = "-DEBUG"
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests {
includeAndroidResources = true
all {
testLogging {
events "passed", "failed", "skipped"
}
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:$androidXVersion"
implementation "androidx.fragment:fragment-ktx:$androidXVersion"
implementation "com.google.android.material:material:$androidXVersion"
implementation "androidx.recyclerview:recyclerview:$androidXVersion"
implementation "androidx.core:core-ktx:$androidXVersion"
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
// Dagger 2
implementation 'com.google.dagger:dagger:2.16'
implementation 'com.google.dagger:dagger-android:2.16'
implementation 'com.google.dagger:dagger-android-support:2.16'
kapt 'com.google.dagger:dagger-compiler:2.16'
kapt 'com.google.dagger:dagger-android-processor:2.16'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
// Stetho
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
// Rx
implementation 'io.reactivex.rxjava2:rxjava:2.1.13'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-kotlin:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7-kotlin:2.1.1'
implementation 'com.jakewharton.rx2:replaying-share:2.0.1'
// Room
implementation "androidx.room:room-runtime:2.0.0-alpha1"
implementation "androidx.room:room-rxjava2:2.0.0-alpha1"
kapt "androidx.room:room-compiler:2.0.0-alpha1"
// Logging
implementation 'com.jakewharton.timber:timber:4.7.0'
// Time
implementation 'com.jakewharton.threetenabp:threetenabp:1.1.0'
// UI
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'net.opacapp:multiline-collapsingtoolbar:27.1.1'
implementation 'com.balysv:material-ripple:1.0.2'
// Testing
androidTestImplementation "com.android.support.test:runner:1.0.2"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
testImplementation 'junit:junit:4.12'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:${kotlin_version}"
testImplementation "com.nhaarman:mockito-kotlin-kt1.1:1.5.0"
testImplementation "org.mockito:mockito-core:2.18.3"
testImplementation "org.robolectric:robolectric:3.8"
testImplementation "org.robolectric:shadows-multidex:3.8"
}
Proguard:
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn org.codehaus.mojo.animal_sniffer.**
-dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
答案 0 :(得分:15)
将-keep class androidx.core.app.CoreComponentFactory { *; }
添加到您的proguard配置中,以防止此类被阻止
答案 1 :(得分:-1)
尝试禁用即时运行。这可以通过Android Studio中的设置(文件->设置->生成,执行,部署->即时运行)完成: