- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
根据 Android documentation 启用 minifyEnabled
和 shrinkResources
后,Android 应用构建的release 版本有望成功运行、Crashlytics 和 Proguard。
此问题的代码可以在 open-sourced GitHub repository 中找到对于 Coinverse。
应用程序的发布版本在从 Google Play 下载后打开后立即崩溃。
在没有 minifyEnabled
和 shrinkResources
的情况下,应用程序在生产环境中按预期运行,应用程序大小从 ~4mb 到 ~10mb。
错误日志表明这是 Firebase 兼容性问题,并推荐这篇 StackOverflow 帖子。 - What ProGuard configuration do I need for Firebase on Android?
ProGuard 也有类似的问题 - transformClassesAndResourcesWithProguardForRelease FAILED .
总结
启用 Crashlytics。
Crashlytics 核心:无法执行任务
未启用 Crashlytics。
无法使用 ProGuard 实例化 AndroidPlatform 类
详情
2020-04-19 12:08:48.137 21704-21704/? E/app.coinverse: Unknown bits set in runtime_flags: 0x8000
2020-04-19 12:08:49.684 21704-21704/app.coinverse E/AndroidRuntime: FATAL EXCEPTION: main
Process: app.coinverse, PID: 21704
java.lang.RuntimeException: Unable to create application app.coinverse.App: java.lang.RuntimeException: Failed to instantiate AndroidPlatform class. Using ProGuard? See http://stackoverflow.com/questions/26273929/what-proguard-configuration-do-i-need-for-firebase-on-android
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6465)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.RuntimeException: Failed to instantiate AndroidPlatform class. Using ProGuard? See http://stackoverflow.com/questions/26273929/what-proguard-configuration-do-i-need-for-firebase-on-android
at d.b.a.d.a.a(:69)
at d.b.a.a.a(:974)
at app.coinverse.j.a.<init>(:44)
at app.coinverse.j.b.a(:29)
at app.coinverse.j.b.get(:21)
at app.coinverse.j.b.get(:8)
at e.b.b.get(:47)
at app.coinverse.i.d.a(:107)
at app.coinverse.App.onCreate(:18)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.NoSuchMethodException: d.b.a.c.a.<init> [class android.content.Context]
at java.lang.Class.getConstructor0(Class.java:2332)
at java.lang.Class.getConstructor(Class.java:1728)
at d.b.a.d.a.a(:62)
at d.b.a.a.a(:974)
at app.coinverse.j.a.<init>(:44)
at app.coinverse.j.b.a(:29)
at app.coinverse.j.b.get(:21)
at app.coinverse.j.b.get(:8)
at e.b.b.get(:47)
at app.coinverse.i.d.a(:107)
at app.coinverse.App.onCreate(:18)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
build.gradle (:app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'androidx.navigation.safeargs'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'io.fabric'
apply plugin: 'de.mannodermaus.android-junit5'
android {
compileSdkVersion 29
defaultConfig {
applicationId "app.coinverse"
minSdkVersion 24
targetSdkVersion 29
versionCode 57
versionName "0.57"
kotlinOptions { jvmTarget = '1.8' }
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
sourceSets { androidTest.assets.srcDirs += files("$projectDir/schemas".toString()) }
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'),
'proguard-rules.pro',
'proguard.cfg'
}
debug {
applicationIdSuffix ".staging"
debuggable true
}
open {
initWith debug
applicationIdSuffix ".open"
}
}
compileOptions { targetCompatibility JavaVersion.VERSION_1_8 }
dataBinding.enabled = true
testOptions { unitTests.includeAndroidResources = true }
}
dependencies {
def lifecycle_version = '2.2.0'
def lifecycle_test_version = '2.1.0'
def nav_version = '2.2.1'
def play_services_version = '17.0.0'
def exoplayer_version = '2.11.1'
def room_version = '2.2.5'
def glide_version = '4.11.0'
def mopub_version = '5.12.0'
def junit_version = '5.5.1'
def test_rules_core_version = '1.2.0'
def fragment_version = '1.2.4'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.dagger:dagger:2.27'
kapt 'com.google.dagger:dagger-compiler:2.27'
implementation "androidx.fragment:fragment-ktx:$fragment_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.paging:paging-runtime-ktx:2.1.2"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.1.1'
implementation "com.google.android.gms:play-services-auth:18.0.0"
implementation "com.google.android.gms:play-services-location:$play_services_version"
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.google.firebase:firebase-perf:19.0.5'
implementation 'com.google.firebase:firebase-firestore-ktx:21.4.0'
implementation 'com.google.firebase:firebase-functions:19.0.2'
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation 'com.firebaseui:firebase-ui-firestore:4.2.0'
implementation 'com.firebaseui:firebase-ui-auth:4.2.1'
implementation 'com.google.firebase:firebase-storage:19.1.1'
implementation 'com.google.firebase:firebase-inappmessaging-display:19.0.4'
implementation 'com.google.firebase:firebase-config:19.1.3'
implementation 'com.jjoe64:graphview:4.2.2'
implementation "com.google.android.exoplayer:exoplayer-core:$exoplayer_version"
implementation "com.google.android.exoplayer:exoplayer-ui:$exoplayer_version"
implementation files('libs/YouTubeAndroidPlayerApi.jar')
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
implementation("com.mopub:mopub-sdk-native-static:$mopub_version") { transitive = true }
implementation("com.mopub:mopub-sdk-native-video:$mopub_version") { transitive = true }
implementation 'com.facebook.android:audience-network-sdk:5.8.0'
implementation 'com.mopub.mediation:facebookaudiencenetwork:5.8.0.0'
implementation 'com.flurry.android:ads:12.3.0'
implementation 'com.flurry.android:analytics:12.3.0'
implementation 'com.mopub.mediation:flurry:12.0.3.1'
// Testing
// Local Unit
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
testImplementation "io.mockk:mockk:1.9.3"
testImplementation 'org.assertj:assertj-core:3.13.2'
debugImplementation "androidx.fragment:fragment-testing:$fragment_version"
testImplementation "androidx.arch.core:core-testing:$lifecycle_test_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.2"
// AndroidX - JVM
testImplementation "androidx.test:core-ktx:1.2.0"
testImplementation "androidx.test.ext:junit-ktx:1.1.1"
testImplementation "androidx.test:rules:$test_rules_core_version"
testImplementation "androidx.test:core:$test_rules_core_version"
}
build.gradle (android)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.71'
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:perf-plugin:1.3.1'
classpath 'io.fabric.tools:gradle:1.31.2'
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.5.1.0"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com/' }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App.kt
在尝试初始化 FirebaseHelper.kt 类时应用的发布版本崩溃。
class App : Application() {
val component = DaggerComponent.builder()
.utilsModule(UtilsModule(this))
.build()
override fun onCreate() {
super.onCreate()
// Here is where the crash occurs.
component.firebaseHelper()
MoPub.initializeSdk(this, SdkConfiguration.Builder(AD_UNIT_ID).build(), initSdkListener())
}
private fun initSdkListener() = SdkInitializationListener { /* MoPub SDK initialized.*/ }
}
FirebaseHelper.kt
@Singleton
class FirebaseHelper @Inject constructor(context: Context) {
private val LOG_TAG = FirebaseHelper::class.java.simpleName
init {
if (BuildConfig.BUILD_TYPE == open.name) {
var openSharedStatus = false
FirebaseApp.getApps(context).map { app ->
if (app.name.equals(open.name))
openSharedStatus = true
}
if (!openSharedStatus)
FirebaseApp.initializeApp(
context,
FirebaseOptions.Builder()
.setApplicationId(APP_ID_OPEN_SHARED)
.setApiKey(APP_API_KEY_OPEN_SHARED)
.setDatabaseUrl(DATABASE_URL_OPEN_SHARED)
.setProjectId(PROJECT_ID_OPEN_SHARED)
.setStorageBucket(STORAGE_BUCKET_OPEN_SHARED)
.build(),
open.name)
}
Firebase.setAndroidContext(context)
initializeRemoteConfig()
}
private fun initializeRemoteConfig() {
val firebaseRemoteConfig = FirebaseRemoteConfig.getInstance()
firebaseRemoteConfig.setConfigSettingsAsync(FirebaseRemoteConfigSettings.Builder().build())
firebaseRemoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
val cacheExpiration = 3600L
try {
firebaseRemoteConfig.fetch(cacheExpiration)
firebaseRemoteConfig.fetchAndActivate()
} catch (exception: FirebaseRemoteConfigException) {
Crashlytics.log(Log.ERROR, LOG_TAG, "initializeRemoteConfig: ${exception.localizedMessage}")
}
}
}
<强>1。删除 Crashlytics。
一个。删除 Crashlytics.log(...)
B.删除 build.gradle (:app)
中的 Fabric 插件和 Crashlytics 库// apply plugin: 'io.fabric'
...
// implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
C.从 build.gradle (android)
中移除 Fabric repositories {
...
// maven { url 'https://maven.fabric.io/public' }
}
dependencies {
...
// classpath 'io.fabric.tools:gradle:1.28.0'
}
<强>2。使用 Proguard 处理模型到 Firestore 数据库的序列化/反序列化。
# Add this global rule
-keepattributes Signature
-keepclassmembers class app.coinverse.analytics.models.** {
*;
}
-keepclassmembers class app.coinverse.analytics.models.ContentAction.** {
*;
}
-keepclassmembers class app.coinverse.analytics.models.UserAction.** {
*;
}
-keepclassmembers class app.coinverse.analytics.models.UserActionCount.** {
*;
}
-keepclassmembers class app.coinverse.feed.models.** {
*;
}
-keepclassmembers class app.coinverse.feed.models.FeedViewState.** {
*;
}
-keepclassmembers class app.coinverse.feed.models.FeedViewState.Content.** {
*;
}
-keepclassmembers class app.coinverse.feed.models.FeedViewState.ContentToPlay.** {
*;
}
-keepclassmembers class app.coinverse.feed.models.FeedViewState.ContentPlayer.** {
*;
}
-keepclassmembers class app.coinverse.priceGraph.models.** {
*;
}
-keepclassmembers class app.coinverse.priceGraph.models.ExchangeOrderData.** {
*;
}
-keepclassmembers class app.coinverse.priceGraph.models.ExchangeOrdersDataPoints.** {
*;
}
-keepclassmembers class app.coinverse.priceGraph.models.MaximumPercentPriceDifference.** {
*;
}
-keepclassmembers class app.coinverse.priceGraph.models.Order.** {
*;
}
-keepclassmembers class app.coinverse.priceGraph.models.PercentDifference.** {
*;
}
-keepclassmembers class app.coinverse.priceGraph.models.PriceGraphData.** {
*;
}
-keepclassmembers class app.coinverse.priceGraph.models.PriceGraphXAndYConstraints.** {
*;
}
-keepclassmembers class app.coinverse.priceGraph.models.PricePair.** {
*;
}
-keepclassmembers class app.coinverse.user.models.** {
*;
}
-keepclassmembers class app.coinverse.user.models.User.** {
*;
}
-keepclassmembers class app.coinverse.utils.** {
*;
}
# If Enums are used in the database, use 'ADB Clear App Data and Restart', and then re-run.
-keepclassmembers enum * { *; }
B.定义模型的 no-argument constructors .对于已经在 data class
构造函数中定义了默认值的模型,这应该不是必需的。但是,如果没有显式定义无参数构造函数“ users does not define no argument constructor ” 就会出错。
C.按 annotating enum names with @SerializedName
处理枚举和 adding the Proguard rule above to keep enumerations' members .应该只需要这些实现中的一个。
<强>3。 Add proguard.cfg rules用于 Firebase。
-keep class com.firebase.** { *; }
-keep class org.apache.** { *; }
-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class javax.servlet.** { *; }
-keepnames class org.ietf.jgss.** { *; }
-dontwarn org.w3c.dom.**
-dontwarn org.joda.time.**
-dontwarn org.shaded.apache.**
-dontwarn org.ietf.jgss.**
# Only necessary if you downloaded the SDK jar directly instead of from maven.
-keep class com.shaded.fasterxml.jackson.** { *; }
<强>4。 Add pro-guard-rules-release.txt
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-release.txt'
testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-test.txt'
最佳答案
我遇到了类似的问题,从 Fabric 完全迁移到 Firebase Crashlytics 为我解决了这个问题:https://firebase.google.com/docs/crashlytics/get-started-new-sdk?platform=android&authuser=0
希望这对您有所帮助!
关于android - 无法使用 ProGuard 实例化 AndroidPlatform 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57010884/
有没有一种方法可以使用标准类型构造函数(例如 int、set、dict、list、tuple 等)以用户定义的方式将用户定义类的实例强制转换为其中一种类型?例如 class Example:
我知道这个问题在Stackoverflow中有很多问题,但是即使有很多答案,这些答案也帮不了我什么,也没有找到答案。 在我的WebAPP中,它可以正常工作,但是当我将其转换为API时,它失败了(主题标
这个问题已经有答案了: Why does the ternary operator unexpectedly cast integers? (3 个回答) 已关闭 9 年前。 最近遇到一个Java的陷
我尝试使用 FirebaseApp.configure() 配置 Firebase,但遇到以下崩溃: *** Terminating app due to uncaught exception 'c
我有一个自连接员工实体类,其中包含与其自身相关的 id、name 和 ref 列。我想创建它的新实例并将其保存到数据库。 首先我创建了一个 Employee 类的实例并将其命名为 manager。然后
我有一个用于添加新公寓的表单,在该表单中我有一个下拉列表,用户可以在其中选择负责的人员。 显然,当您从下拉列表中选择并尝试保存公寓时,我的应用程序认为该人已被修改。它给了我下面的错误,指示我应该首先保
从 Visualforce 页面,我需要检索我们组织的 salesforce 实例的 URL,而不是 Visual Force URL。 例如我需要https://cs1.salesforce.com
我遇到了一些可能的问题答案,但这是关于从 Hibernate 3.4.0GA 升级到 Hibernate 4.1.8 的问题。所以这曾经在以前的版本下工作,我已经四处搜索了为什么它在这个新版本中出现了
似乎一遍又一遍地问这个问题,我仍然找不到解决我问题的答案。我在下面有一个域模型。每个新创建或更新的“安全用户”都需要我确保其具有配置文件,如果没有,则创建一个新的配置文件并分配给它。 配置文件的要求相
我很难调试为什么 JPA 不级联我的 @ManyToMany 关系。我发现的所有答案都与缺少级联语句有关。但我确实拥有它们并且仍然得到: Caused by: org.hibernate.Transi
Play 服务 API 表明有一个叫做 Instance ID 的东西 但是,在 Android Studio 中包含以下内容后,我无法导入 InstanceID 类 compile "com.goo
我正在使用 Seam 框架。我有 2 个实体: 请求.java @Entity @Table(name = "SRV_REQUEST") public class Request { private
This question处理构建一个适当的Monad来自单子(monad)的实例,但仅在某些约束下 - 例如Set .诀窍是将其包装成 ContT ,它将约束推迟到包装/展开其值。 现在我想对 Ap
我正在尝试执行此查询: StringBuffer sb = new StringBuffer(); sb.append("select p from PointsEntity p " + "where
我试图了解是否可以更改我的 hibernate 配置并使用单个 MySQL 实例(而不是我当前拥有的多个 MySQL 实例): 我有一个使用 hibernate 的 Java 应用程序,与 2 个模式
我有一个选项卡滑动布局,其中包括四个选项卡,每个选项卡都有自己的布局和 fragment ,在我的主要 Activity 布局中,viewpager 参与更改选项卡。特定 View (选项卡)在应用程
我看到很多帖子声称他们正在运行 MySql 的 RDS 实例,但无法连接到该实例,但我没有运行 RDS。 我使用 EC2 实例来托管我的 WordPress 博客,该博客是使用 Web 平台安装程序安
因为我在我的 ec-2 实例上的 python 虚拟环境中运行应用程序( Airflow ),并且我想在同一个 ec2 实例上的默认 python 环境中运行命令,所以我认为 ssh 到我自己的实例更
这个问题已经有答案了: How to fix the Hibernate "object references an unsaved transient instance - save the tra
例子: run APP1 .. ... run APP1 ... run APP2 如何在 APP2 中对 Vue 说我需要调用 APP1?
我是一名优秀的程序员,十分优秀!