首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不同AndroidStudio上的NPE

不同AndroidStudio上的NPE
EN

Stack Overflow用户
提问于 2018-04-15 04:08:28
回答 2查看 226关注 0票数 0

我遇到了一个问题,我认为是由android工作室造成的。我正在开发android工作室的稳定版本。当它在调试时,一切都很好。但是,当我切换到发布变体或者生成一个签名APK的时候,这个应用程序就会在不同的场合崩溃。堆栈跟踪是:

代码语言:javascript
复制
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)

故障排除步骤:

  1. 换了测试电话。
  2. 尝试D8编译器
  3. 在DEbug和版本变体之间来回切换

因此,最后一次尝试是在不同的android工作室(实际上是不同的PC)上运行完全相同的项目。这个应用程序开始了,我玩了一段时间,很好。没有撞车也没有可疑。甚至尝试过不同的手机,但撞车事件没有发生。

我的设置:

  1. Mac版本10.13.4
  2. Android 3.0.1版

另一个计算机设置:

  1. Windows 10
  2. Android 3.0.1版

任何帮助都将不胜感激。

更新:

经过尝试,禁用的保护发布版本现在是好的,但现在的问题是,相同的规则和依赖关系已经应用到这两台PC,但保护功能不同!

依赖关系:

代码语言:javascript
复制
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()
}

以及保安规则:

代码语言:javascript
复制
#########################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.我刚刚成功地将我的安卓工作室更新到3.1.1版本,并将gradle和插件更新到最新版本。

不幸的是,错误仍然存在,只有堆栈跟踪已经更改:

代码语言:javascript
复制
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)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-04-15 13:53:58

我不知道该如何解决这个问题,但我也遇到了类似的事情,我成功地修复了它,完全删除了android工作室并重新安装。

remove from mac remove from windows

票数 6
EN

Stack Overflow用户

发布于 2018-06-03 04:40:05

我真的找到了解决办法!高级分析选项正在造成这个问题。通过禁用in

运行->编辑配置->分析

问题现在已经解决了。

希望它能帮助未来的读者!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49838390

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档