【问题标题】:Android studio minify enabled = true , not able to generate apk?Android studio minify enabled = true ,无法生成apk?
【发布时间】:2016-08-21 08:47:28
【问题描述】:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'realm-android'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultPublishConfig "debug"

defaultConfig {
    applicationId "com.youth4work.ibps"
    minSdkVersion 16
    targetSdkVersion 23

    multiDexEnabled true

    versionCode 1
    versionName "1.0.0"
}

signingConfigs {

    release {
        storeFile file('keystore/youth4work_second_key')
        keyAlias 'youth4work_second_key_alias'
        keyPassword "youth4work"
        storePassword "youth4work"
    }

    debug {
        storeFile file('keystore/debug.keystore')
        keyAlias 'androiddebugkey'
        storePassword 'android'
        keyPassword 'android'
    }
}

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'),      'proguard-rules.pro'
    }

    debug {
        versionNameSuffix "Debug"
        debuggable true
    }
}

lintOptions {
    disable 'InvalidPackage'
    checkReleaseBuilds false
}

packagingOptions {
    exclude 'META-INF/services/javax.annotation.processing.Processor'
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

retrolambda {
jvmArgs '-noverify'
}

dependencies {
final PLAY_SERVICES_VERSION = '8.3.0'
final SUPPORT_LIBRARY_VERSION = '23.3.0'

// Google Play Services
compile "com.google.android.gms:play-services-base:$PLAY_SERVICES_VERSION"
compile "com.google.android.gms:play-services-    analytics:$PLAY_SERVICES_VERSION"
compile "com.google.android.gms:play-services-gcm:$PLAY_SERVICES_VERSION"
compile "com.google.android.gms:play-services-plus:$PLAY_SERVICES_VERSION"

// Support Libraries
compile "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
compile 'com.android.support:support-annotations:23.3.0'

compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'

compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.jakewharton.timber:timber:4.1.0'
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'


compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
compile 'com.github.kevinsawicki:timeago:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.8.2'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.mobsandgeeks:android-saripaar:2.0.2'
compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.1.1'
compile 'com.github.jakob-grabner:Circle-Progress-View:1.2.8'
compile 'com.github.vlonjatg:progress-activity:v1.0.3'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
compile 'com.daasuu:animateHorizontalProgressBar:0.2.2'

compile 'io.reactivex:rxjava:1.1.0'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'com.trello:rxlifecycle:0.4.0'
compile 'com.trello:rxlifecycle-components:0.4.0'



compile('com.github.afollestad.material-dialogs:core:0.8.5.6@aar') {
    transitive = true
}

compile('com.mikepenz:fastadapter:1.4.0@aar') {
    transitive = true
}

testCompile 'junit:junit:4.12'
}

// Log out test results to console
tasks.matching { it instanceof Test }.all {
testLogging.events = ["failed", "passed", "skipped"]
}

在这里,如果我让minify enabled = false 代码运行良好,而如果我使用 true,则代码显示

信息:Gradle 任务 [:app:assembleRelease] google-services 插件 无法检测到 com.google.android.gms 的任何版本,默认 版本:将使用 8.3.0。请在以下位置应用 google-services 插件 构建文件的底部。 :app:preBuild UP-TO-DATE :app:preReleaseBuild UP-TO-DATE :app:checkReleaseManifest :app:preDebugBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2330Library 最新:app:prepareComAndroidSupportAppcompatV72330Library 最新:app:prepareComAndroidSupportCardviewV72330Library 最新:app:prepareComAndroidSupportDesign2330Library 最新 :app:prepareComAndroidSupportMultidex101Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72330Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42330Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2330Library 最新:app:prepareComDaasuuAnimateHorizo​​ntalProgressBar022Library 最新:app:prepareComFacebookAndroidFacebookAndroidSdk482Library 最新 :app:prepare ComGithubAfollestadMaterialDialogsCore0856Library 最新 :app:prepare ComGithubJakobGrabnerCircleProgressView128Library 最新:app:prepareComGithubSiyamedAndroidShapeImageview093Library 最新:app:prepareComGithubVlonjatgProgressActivityV103Library 最新 :app:prepareComGoogleAndroidGmsPlayServicesAnalytics830Library 最新:app:prepareComGoogleAndroidGmsPlayServicesBase830Library 最新 :app:prepareComGoogleAndroidGmsPlayServicesBasement830Library 最新:app:prepareComGoogleAndroidGmsPlayServicesGcm830Library 最新 :app:prepareComGoogleAndroidGmsPlayServicesMeasurement830Library 最新:app:prepareComGoogleAndroidGmsPlayServicesPlus830Library 最新:app:prepareComJakewhartonRxbindingRxbinding040Library 最新:app:prepareComJakewhartonTimberTimber410Library 最新 :app:prepareComJoanzapataIconifyAndroidIconify211Library UP-TO-DATE :app:prepareComJoanzapataIconifyAndroidIconifyFontawesome211Library 最新:app:prepareComMikepenzFastadapter140Library 最新 :app:prepareComRengwuxianMaterialedittextLibrary214Library UP-TO-DATE :app:prepareComTrelloRxlifecycle040Library UP-TO-DATE :app:prepareComTrelloRxlifecycleComponents040Library UP-TO-DATE :app:prepareIoReactivexRxandroid110Library UP-TO-DATE :app:prepareIoRealmRealmAndroidLibrary0883Library UP-TO-DATE :app:prepareMeZhanghaiAndroidMaterialprogressbarLibrary114Library 最新:app:prepareReleaseDependencies:app:compileReleaseAidl :app:compileReleaseRenderscript :app:generateReleaseBuildConfig :app:generateReleaseAssets 最新 :app:mergeReleaseAssets :app:generateReleaseResValues 最新 :app:processReleaseGoogleServices :app:generateReleaseResources :app:mergeReleaseResources :app:processReleaseManifest :app:processReleaseResources :app:generateReleaseSources :app:compileReleaseJavaWithJavac 注意:一些输入文件使用或 覆盖已弃用的 API。注意:使用 -Xlint:deprecation 重新编译 细节。注意:某些输入文件使用未经检查或不安全的操作。 注意:使用 -Xlint:unchecked 重新编译以获取详细信息。 :app:compileRetrolambdaRelease :app:compileReleaseNdk UP-TO-DATE :app:compileReleaseSources :app:prePackageMarkerForRelease :app:transformClassesWithRealmTransformerForRelease :app:processReleaseJavaRes 最新 :app:transformResourcesWithMergeJavaResForRelease :app:transformClassesAndResourcesWithProguardForRelease assmember) 警告:对库类成员有 1 个未解决的引用。 您可能需要更新库版本。 (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember) 警告:处理任务 java.io.IOException 时出现异常:请 首先更正上述警告。 :app:transformClassesAndResourcesWithProguardForRelease 失败 错误:任务执行失败 ':app:transformClassesAndResourcesWithProguardForRelease'.

java.io.IOException: 请先更正上述警告。信息:BUILD FAILED 信息:总时间:27.946 秒 信息:1 错误信息:91 警告信息:查看完整 控制台输出

【问题讨论】:

    标签: android android-studio


    【解决方案1】:

    如果您启用缩小,构建将调用 Proguard 删除所有不必要的类、成员和方法。 为此,您需要一个 proguard 配置文件,该文件将告诉 Proguard 哪些类是您的类的入口点以及应保留哪些成员和方法。 您看到的错误是方法调用不匹配的常见错误。

    该错误包含指向Proguard 手册的链接,进一步描述了该错误:您必须确保使用正确的 Android 构建目标并保留所有必要的库及其方法。

    尝试在您的属性中调整 Android 构建目标。如果这不起作用,您必须检查您的 proguard 配置中是否需要更多条目。

    【讨论】:

    • 您能否举例说明,因为我是 proguard 的新手。此外,我正在从事的项目是由其他人开发的,所以我真的不知道完整的项目细节,因为我开始从事同样的工作仅 3 天,我的第一个目标是缩小 apk 并删除错误。
    • 好吧,您可以从提供的链接中建议的解决方案开始:you should change the build target in your project.properties file or build.gradle file to that recent version. You can still specify a different minSdkVersion and a different targetSdkVersion in your AndroidManifest.xml file. 如果这不起作用,您将不得不查看您的 proguard-config 文件(将其添加到您的问题中) 或创建一个,如果你没有。为您的项目从头开始创建新配置可能有点乏味,因为您有很多外部库。
    • 项目中是否有任何用于proguard的单独文件,请提供更多详细信息
    • 是的,应该有 proguard-rules.pro 或 proguard.cfg 或 progaurd.txt。这是在“porguardFiles”下的 Gradle 构建文件中引用的文件。请看这里:guides.codepath.com/android/Configuring-ProGuard,这是有关如何创建的一个很好的示例。还有一些您正在使用的库的示例
    猜你喜欢
    • 1970-01-01
    • 2018-09-19
    • 1970-01-01
    • 2016-09-07
    • 1970-01-01
    • 1970-01-01
    • 2016-09-11
    • 2019-03-29
    • 2016-01-08
    相关资源
    最近更新 更多