【问题标题】:Android app works in debug but not in release, idk whyAndroid 应用程序在调试中工作但在发布中不工作,我知道为什么
【发布时间】:2020-05-14 09:14:48
【问题描述】:

使用 Twitter 登录可以在调试中工作,但在发布中不可用,而且在调试中 apk 的大小更大。 问题出在哪里??

我有 3 个活动

这是 build.grandle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.PolDevs.MyClickerGame"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-auth:19.1.0'
    implementation 'com.google.firebase:firebase-database:19.1.0'
    implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
    implementation 'com.google.firebase:firebase-core:17.2.2'
    implementation 'com.twitter.sdk.android:twitter-core:3.1.0'

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

【问题讨论】:

  • 你有调试和发布的api密钥吗?

标签: android firebase twitter


【解决方案1】:

打开您正在使用的所有库的文档,并仔细检查它们是否有任何特定规则要放入proguard,因为这是在发布构建期间启用的。 proguard 在发布版本时混淆了您的 APK,这意味着删除注释和 cmets 等代码,这也减少了 apk 的大小。

因此,要使某些库正常工作,您必须在 proguard 文件中指定一些规则,以免混淆某些内容。进行调试和发布构建时要注意的常见错误。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-31
  • 2021-03-02
  • 2020-11-08
  • 1970-01-01
  • 1970-01-01
  • 2020-06-30
相关资源
最近更新 更多