我遇到了一个我认为是由android studio引起的问题。 我正在开发android studio的稳定版本。当它在调试时一切正常。但是,当我切换到发布变体或生成已签名的APK时,应用程序将在不同的场合崩溃。堆栈跟踪是:
java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.view.inputmethod.InputConnection.finishComposingText()' on a null object reference
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
问题排查步骤:
所以最后一次尝试是在不同的android studio(实际上是一台不同的PC)上运行完全相同的项目。应用程序开始我玩了一段时间它很好。没有崩溃,没有任何可疑之处。甚至试过不同的手机,但崩溃没有发生。
我的设置:
其他计算机设置:
任何帮助将不胜感激。
更新
尝试禁用后的proguard发布版本现在很好但现在问题是相同的规则和依赖关系已应用于两台PC,但proguard功能不同!
依赖关系:
def dependencyGroup(Closure closure) {
closure.delegate = dependencies
return closure
}
project.ext {
supportLibrary = "27.0.0"
multidex = "1.0.1"
archComponent = "1.1.0"
pagingComponent = "1.0.0-alpha6"
dagger = "2.14.1"
butterKnife = "8.8.1"
rxJava = "2.1.6"
rxBinding = "2.0.0"
rxAndroid = "2.0.1"
rxBroadCast = "2.0.0"
timber = "4.6.0"
constraint = "1.0.2"
google = "12.0.1"
oneSignal = "3.8.3"
retrofit = "2.3.0"
moshi = "1.5.0"
okHttp = "3.9.1"
autoValue = "1.5"
autoMoshi = "0.4.5"
autoRedacted = "1.0.1"
autoWith = "1.0.0"
autoParceler = "0.2.6"
fresco = "1.5.0"
frescoProcessor = "2.1.0"
leakCanary = "1.5.4"
btmNav = "2.1.0"
store = "3.0.0"
dexter = "4.2.0"
}
def testLibs = dependencyGroup {
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
def support = dependencyGroup {
implementation "com.android.support:appcompat-v7:$project.supportLibrary"
implementation "com.android.support:design:$project.supportLibrary"
implementation "com.android.support:support-v13:$project.supportLibrary"
implementation "com.android.support:support-v4:$project.supportLibrary"
implementation "com.android.support:support-media-compat:$project.supportLibrary"
implementation "com.android.support:support-fragment:$project.supportLibrary"
implementation "com.android.support:support-core-utils:$project.supportLibrary"
implementation "com.android.support:support-core-ui:$project.supportLibrary"
implementation "com.android.support:support-annotations:$project.supportLibrary"
implementation "com.android.support:support-vector-drawable:$project.supportLibrary"
implementation "com.android.support:transition:$project.supportLibrary"
implementation "com.android.support:customtabs:$project.supportLibrary"
implementation "com.android.support:cardview-v7:$project.supportLibrary"
implementation "com.android.support.constraint:constraint-layout:$project.constraint"
implementation "com.android.support:multidex:$project.multidex"
}
def archComponent = dependencyGroup {
implementation "android.arch.lifecycle:extensions:$project.archComponent"
implementation "android.arch.lifecycle:common-java8:$project.archComponent"
implementation "android.arch.paging:runtime:$project.pagingComponent"
// implementation "android.arch.lifecycle:reactivestreams:$project.archComponent"
}
def analytics = dependencyGroup {
implementation "com.google.firebase:firebase-core:$project.google"
implementation "com.google.firebase:firebase-crash:$project.google"
implementation "com.onesignal:OneSignal:$project.oneSignal"
}
def google = dependencyGroup {
implementation "com.google.android.gms:play-services-base:$project.google"
implementation "com.google.android.gms:play-services-identity:$project.google"
implementation "com.google.android.gms:play-services-auth:$project.google"
implementation "com.google.android.gms:play-services-gcm:$project.google"
implementation "com.google.android.gms:play-services-location:$project.google"
implementation "com.google.android.gms:play-services-maps:$project.google"
implementation "com.google.android.gms:play-services-places:$project.google"
// implementation "com.google.android.gms:play-services-auth-api-phone:$project.google"
}
def RX = dependencyGroup {
implementation "io.reactivex.rxjava2:rxandroid:$project.rxAndroid"
implementation "io.reactivex.rxjava2:rxjava:$project.rxJava"
implementation "com.cantrowitz:rxbroadcast:$project.rxBroadCast"
}
def rxBinding = dependencyGroup {
implementation "com.jakewharton.rxbinding2:rxbinding:$project.rxBinding"
// implementation "com.jakewharton.rxbinding2:rxbinding-design:$project.rxBinding"
// implementation "com.jakewharton.rxbinding2:rxbinding-support-v4:$project.rxBinding"
implementation "com.jakewharton.rxbinding2:rxbinding-appcompat-v7:$project.rxBinding"
// implementation "com.jakewharton.rxbinding2:rxbinding-recyclerview-v7:$project.rxBinding"
}
def butterKnife = dependencyGroup {
implementation "com.jakewharton:butterknife:$project.butterKnife"
annotationProcessor "com.jakewharton:butterknife-compiler:$project.butterKnife"
}
def autoValue = dependencyGroup {
provided "com.jakewharton.auto.value:auto-value-annotations:$project.autoValue"
annotationProcessor "com.google.auto.value:auto-value:$project.autoValue"
annotationProcessor "com.gabrielittner.auto.value:auto-value-with:$project.autoWith"
annotationProcessor "com.squareup.auto.value:auto-value-redacted:$project.autoRedacted"
}
def parceler = dependencyGroup {
annotationProcessor "com.ryanharter.auto.value:auto-value-parcel:$project.autoParceler"
implementation "com.ryanharter.auto.value:auto-value-parcel-adapter:$project.autoParceler"
}
def moshi = dependencyGroup {
implementation "com.squareup.moshi:moshi:$project.moshi"
annotationProcessor "com.ryanharter.auto.value:auto-value-moshi:$project.autoMoshi"
provided "com.ryanharter.auto.value:auto-value-moshi-annotations:$project.autoMoshi"
}
def dagger = dependencyGroup {
implementation "com.google.dagger:dagger:$project.dagger"
annotationProcessor "com.google.dagger:dagger-compiler:$project.dagger"
}
def daggerAndroid = dependencyGroup {
implementation "com.google.dagger:dagger-android-support:$project.dagger"
// if you use the support libraries
annotationProcessor "com.google.dagger:dagger-android-processor:$project.dagger"
}
def annotation = dependencyGroup {
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'javax.annotation:jsr250-api:1.0'
}
def retrofit = dependencyGroup {
implementation "com.squareup.retrofit2:retrofit:$project.retrofit"
implementation "com.squareup.retrofit2:adapter-rxjava2:$project.retrofit"
implementation "com.squareup.retrofit2:converter-moshi:$project.retrofit"
implementation "com.squareup.okhttp3:okhttp:$project.okHttp"
implementation "com.squareup.okhttp3:logging-interceptor:$project.okHttp"
}
def timber = dependencyGroup {
implementation "com.jakewharton.timber:timber:$project.timber"
}
def fresco = dependencyGroup {
implementation "com.facebook.fresco:fresco:$project.fresco"
implementation "jp.wasabeef:fresco-processors:$project.frescoProcessor"
}
def leakCanary = dependencyGroup {
debugImplementation "com.squareup.leakcanary:leakcanary-android:$project.leakCanary"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$project.leakCanary"
}
//noinspection GroovyUnusedAssignment
def store = dependencyGroup {
implementation "com.nytimes.android:cache3:$project.store"
implementation "com.nytimes.android:store3:$project.store"
implementation "com.nytimes.android:middleware-moshi3:$project.store"
implementation "com.nytimes.android:filesystem3:$project.store"
}
def ui = dependencyGroup {
implementation "com.aurelhubert:ahbottomnavigation:$project.btmNav"
implementation 'me.zhanghai.android.materialratingbar:library:1.2.0'
implementation 'com.github.ashokslsk:SquareRatingView:1.2'
implementation 'com.github.stfalcon:frescoimageviewer:0.5.0'
// implementation 'org.zakariya.stickyheaders:stickyheaders:0.7.6'
// implementation 'com.bignerdranch.android:recyclerview-multiselect:0.2'
implementation 'com.bignerdranch.android:simple-item-decoration:1.0.0'
implementation 'com.klinkerapps:android-chips:1.3.0@aar'
implementation 'com.sothree.slidinguppanel:library:3.4.0'
implementation 'com.github.jakob-grabner:Circle-Progress-View:v1.3'
}
//noinspection GroovyUnusedAssignment
def job = dependencyGroup {
implementation 'com.evernote:android-job:1.2.1'
}
//noinspection GroovyUnusedAssignment
def jwPlayer = dependencyGroup {
implementation 'com.longtailvideo.jwplayer:jwplayer-core:+'
implementation 'com.longtailvideo.jwplayer:jwplayer-common:+'
}
def utils = dependencyGroup {
implementation "com.karumi:dexter:$project.dexter"
implementation 'com.f2prateek.rx.preferences2:rx-preferences:2.0.0-RC3'
implementation 'com.linchaolong.android:imagepicker:1.5'
implementation 'com.google.maps.android:android-maps-utils:0.5+'
// implementation 'com.beloo.widget:ChipsLayoutManager:0.3.7@aar'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testLibs()
analytics()
google()
support()
archComponent()
RX()
rxBinding()
retrofit()
// store()
autoValue()
parceler()
moshi()
timber()
butterKnife()
dagger()
daggerAndroid()
fresco()
leakCanary()
annotation()
ui()
utils()
// job()
// jwPlayer()
}
和proguard规则:
#########################auto value
# Retain generated classes that end in the suffix
-keepnames class **_MoshiTypeAdapter
# Prevent obfuscation of types which use @GenerateTypeAdapter since the simple name
-keep class **.AutoValue_*
#########################
#ButterKnife
#########################
-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }
-keep class butterknife.*
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
#########################
#Moshi
#########################
-dontwarn okio.**
-dontwarn javax.annotation.**
-keepclasseswithmembers class * {
@com.squareup.moshi.* <methods>;
}
-keep @com.squareup.moshi.JsonQualifier interface *
#########################
#Dagger
#########################
-dontwarn com.google.errorprone.annotations.*
#########################
#Retrofit
#########################
-dontwarn retrofit.**
-keep class retrofit.** { *; }
-keepattributes Signature
-keepattributes Exceptions
#########################
#OkHttp
#########################
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
#########################
#Fresco
#########################
# Keep our interfaces so they can be used by other ProGuard rules.
# See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
-keep,allowobfuscation @interface com.facebook.soloader.DoNotOptimize
# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.common.internal.DoNotStrip class *
-keepclassmembers class * {
@com.facebook.common.internal.DoNotStrip *;
}
# Do not strip any method/class that is annotated with @DoNotOptimize
-keep @com.facebook.soloader.DoNotOptimize class *
-keepclassmembers class * {
@com.facebook.soloader.DoNotOptimize *;
}
# Keep native methods
-keepclassmembers class * {
native <methods>;
}
-dontwarn javax.annotation.**
-dontwarn com.android.volley.toolbox.**
-dontwarn com.facebook.infer.**
#########################
#Timber
#########################
-dontwarn org.jetbrains.annotations.NonNls
#########################
#LeakCanary
#########################
-keep class org.eclipse.mat.** { *; }
-keep class com.squareup.leakcanary.** { *; }
#########################
#printing mapping for firebase
#########################
-printmapping build/outputs/mapping/release/mapping.txt
#########################
-ignorewarnings
更新2。 我刚设法将我的android工作室更新到3.1.1版并将gradle和插件更新到最新版本。
遗憾的是,错误仍然存在,只有堆栈跟踪发生了变化:
java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.view.inputmethod.InputConnection.finishComposingText()' on a null object reference
at android.view.inputmethod.InputConnectionWrapper.finishComposingText(InputConnectionWrapper.java:78)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:362)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7407)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
答案 0 :(得分:5)
我不确切知道如何解决它,但类似的事情发生在我身上,我设法通过彻底删除android studio并重新安装来修复它。
答案 1 :(得分:0)
我实际上找到了解决方案! 高级分析选项正在解决此问题。通过禁用in
运行 - >编辑配置 - &gt;谱
问题现在已经消失。
希望它能帮助未来的读者!