我正在使用 Android P 并针对 AndroidX 进行编译。在调试/测试版中效果很好,但是当我发布时,我在运行时遇到了一个神秘的崩溃:
2018-06-24 00:21:26.080 11971-11971/? E/LoadedApk:无法实例化 appComponentFactory java.lang.ClassNotFoundException:在路径上找不到类“androidx.core.app.CoreComponentFactory”:DexPathList [[zip 文件“/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。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:致命异常:主进程:app.itsyour.elegantstocks,PID:11971 java.lang.IllegalArgumentException:指定为非空的参数为空:方法 cdbhb,app.itsyour.elegantstocks.aba 中的参数 $receiver(未知来源:2)在 app.itsyour.elegantstocks.feature.navigator.ba$aa(未知来源:24)在 app.itsyour.elegantstocks.feature.navigator.baa(未知来源:13)在 app。20670) 在 android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656) 在 android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812) 在 android.view.ViewGroup.layout(ViewGroup.java:6194) 在 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) 在 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 的 android.view.ViewGroup.layout(ViewGroup.java:6194)。java:6642) 在 java.lang.reflect.Method.invoke(Native Method) 在 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 在 com.android.internal.os.ZygoteInit。主要(ZygoteInit.java:858)2018-06-24 00:21:30.137 1796-1880/?E/InputDispatcher: 频道 '5896582 app.itsyour.elegantstocks/app.itsyour.elegantstocks.feature.navigator.NavigatorActivity (server)' ~ 频道已不可恢复地损坏,将被处置!2018-06-24 00:21:30.253 5198-9377/? E/EntrySyncManager:无法确定帐户名称:删除请求 2018-06-24 00:21:30.253 5198-9377/?E/NowController:无法从 EntryProvider 访问数据。执行异常。java.util.concurrent.ExecutionException:com.google.android.apps.gsa.sidekick.main.hn:无法完成刷新条目的计划请求。FutureTask.run(FutureTask.java:266) at com.google.android.apps.gsa.shared.util.concurrent.bgrun(Unknown Source:4) at com.google.android.apps.gsa.shared.util.concurrent .b.aw.run(SourceFile:4) at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4) at 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.birun(SourceFile:6) 原因:com.google.android.apps.gsa.sidekick.main.hn:无法完成刷新条目的计划请求。ClientErrorCode: 3 at com.google.android.apps.gsa.staticplugins.nowstream.baaq.az(未知来源:
我的 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
}
应用分级:
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"
}
前卫:
# 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.**