我生成了一个签名的apk,当我启动它时,它在我登录后崩溃。
但是当我在没有签名的 Apk 的情况下启动应用程序时,通常在模拟器上它工作正常。
这是日志猫:
2020-06-08 21:53:17.293 6729-6729/? D/AndroidRuntime: Shutting down VM
--------- beginning of crash
2020-06-08 21:53:17.294 6729-6729/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.diplomate.sasiraj, PID: 6729
java.lang.InternalError
at q.m.d.j.z.a(Unknown Source:14)
at q.m.d.j.i.<clinit>(Unknown Source:4)
at q.m.d.b.a(Unknown Source:6)
at q.m.d.b.<init>(Unknown Source:16)
at q.m.d.b.<init>(Unknown Source:3)
at q.m.d.e$a.<init>(Unknown Source:0)
at q.m.d.e.<clinit>(Unknown Source:73)
at q.b.a(Unknown Source:0)
at com.diplomate.sasiraj.Payment.v.createEphemeralKey(Unknown Source:30)
at com.stripe.android.EphemeralKeyManager.retrieveEphemeralKey(Unknown Source:37)
at com.stripe.android.EphemeralKeyManager.<init>(Unknown Source:45)
at com.stripe.android.CustomerSession.<init>(Unknown Source:101)
at com.stripe.android.CustomerSession.<init>(Unknown Source:44)
at com.stripe.android.CustomerSession.<init>(Unknown Source:0)
at com.stripe.android.CustomerSession$Companion.initCustomerSession(Unknown Source:34)
at com.stripe.android.CustomerSession$Companion.initCustomerSession$default(Unknown Source:10)
at com.stripe.android.CustomerSession.initCustomerSession(Unknown Source:9)
at com.diplomate.sasiraj.Customer.CustomerMapActivity.onCreate(Unknown Source:29)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NoSuchFieldException: No field producerIndex in class Lq/m/d/j/i; (declaration of 'q.m.d.j.i' appears in base.apk!classes2.dex)
at java.lang.Class.getDeclaredField(Native Method)
at q.m.d.j.z.a(Unknown Source:0)
at q.m.d.j.i.<clinit>(Unknown Source:4)
at q.m.d.b.a(Unknown Source:6)
at q.m.d.b.<init>(Unknown Source:16)
at q.m.d.b.<init>(Unknown Source:3)
at q.m.d.e$a.<init>(Unknown Source:0)
at q.m.d.e.<clinit>(Unknown Source:73)
at q.b.a(Unknown Source:0)
at com.diplomate.sasiraj.Payment.v.createEphemeralKey(Unknown Source:30)
at com.stripe.android.EphemeralKeyManager.retrieveEphemeralKey(Unknown Source:37)
at com.stripe.android.EphemeralKeyManager.<init>(Unknown Source:45)
at com.stripe.android.CustomerSession.<init>(Unknown Source:101)
at com.stripe.android.CustomerSession.<init>(Unknown Source:44)
at com.stripe.android.CustomerSession.<init>(Unknown Source:0)
at com.stripe.android.CustomerSession$Companion.initCustomerSession(Unknown Source:34)
at com.stripe.android.CustomerSession$Companion.initCustomerSession$default(Unknown Source:10)
at com.stripe.android.CustomerSession.initCustomerSession(Unknown Source:9)
at com.diplomate.sasiraj.Customer.CustomerMapActivity.onCreate(Unknown Source:29)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2020-06-08 21:53:17.300 1852-2998/? W/ActivityManager: Force finishing activity com.diplomate.sasiraj/.Customer.CustomerMapActivity
2020-06-08 21:53:17.314 6729-6729/? I/Process: Sending signal. PID: 6729 SIG: 9
2020-06-08 21:53:17.326 1852-1867/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
2020-06-08 21:53:17.327 1852-1867/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
2020-06-08 21:53:17.328 1609-1609/? E/lowmemorykiller: Error writing /proc/6729/oom_score_adj; errno=22
2020-06-08 21:53:17.427 1852-1927/? W/InputDispatcher: channel 'f74e236 com.diplomate.sasiraj/com.diplomate.sasiraj.Login.LauncherActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
2020-06-08 21:53:17.427 1852-1927/? E/InputDispatcher: channel 'f74e236 com.diplomate.sasiraj/com.diplomate.sasiraj.Login.LauncherActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
我尝试在gradle中使minifyEnabled为假,并且应用程序没有崩溃,但谷歌地图没有显示
我在模拟器上使用APK,我也在设备上尝试
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'.
android {.
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "com.diplomate.chauffeur"
minSdkVersion 21
//noinspection OldTargetApi
targetSdkVersion 29
versionCode 1
versionName "2.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
useLibrary 'org.apache.http.legacy'
manifestPlaceholders = [onesignal_app_id : '',
onesignal_google_project_number: 'REMOTE']
}
buildTypes {
release {
multiDexKeepFile file('multidex-config.txt')
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility '1.8'
targetCompatibility '1.8'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation 'com.google.firebase:firebase-database:19.2.1'
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.firebase:firebase-storage:19.1.1'
implementation 'com.firebase:geofire-android:2.3.1'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-places:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.facebook.android:facebook-login:5.13.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.stripe:stripe-android:13.1.3'
implementation 'com.github.bumptech.glide:glide:4.10.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.akexorcist:googledirectionlibrary:1.1.1'
implementation 'com.onesignal:OneSignal:3.9.1'
implementation 'com.google.android.libraries.places:places:2.2.0'
implementation "com.github.addisonelliott:SegmentedButton:3.1.5"
implementation 'com.paypal.sdk:paypal-android-sdk:2.16.0'
implementation 'com.google.android.libraries.places:places:2.2.0'
implementation 'com.github.rtchagas:pingplacepicker:1.1.2'
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
implementation 'androidx.multidex:multidex:2.0.1'
/* Needed for RxAndroid */
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.1.6'
implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
/* Needed for Rx Bindings on views */
implementation 'com.jakewharton.rxbinding:rxbinding:0.4.0'
annotationProcessor 'com.jakewharton:butterknife:8.6.0'
implementation 'com.squareup.retrofit2:retrofit:2.6.0' //Proguard
implementation 'com.squareup.retrofit2:converter-gson:2.3.0' //Proguard
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0' //Proguard
/* Used for server calls */
implementation 'com.squareup.okio:okio:1.17.4'
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
/* Used to make Retrofit easier and GSON & Rx-compatible*/
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
/* Used to debug your Retrofit connections */
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.3'
implementation "com.yuyakaido.android:card-stack-view:2.3.4"
implementation 'com.lorentzos.swipecards:library:1.0.9'
implementation 'com.mikhaellopez:circularprogressbar:3.0.3'
implementation 'com.shreyaspatil:MaterialDialog:2.1'
// Material Design Library
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.ncorti:slidetoact:0.7.0'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
按相同的顺序尝试其中一项或全部尝试:
1( 在 gradle 中使 minifyEnabled 为假
2(无效并重新启动安卓工作室
3(启动后,请确保同步并重新生成项目
然后尝试。很可能是因为progaurd规则。应用程序正在混淆/分叉您的课程。但这是临时解决方案。您不应该保持 minifyEnabled false 并发布应用程序。
4(最重要的是,根据您的用例正确编写progaurd规则,然后再次使/设置为minifyEnabled true。然后它不会崩溃 有关该或此链接,请参阅官方安卓文档
https://developer.android.com/studio/build/shrink-code