Gradle成功构建但没有生成apk文件

时间:2017-01-26 06:32:07

标签: android proguard

首先,我需要解释我在做什么,我正在构建一个aar,它将在另一个应用程序上运行,调用属于aar的活动。 aar运行正常。因此,现在是时候尝试使用proguard隐藏aar源代码了。但是,我可以成功构建,但不会生成apk。谁知道为什么?我可能需要附上以下信息,请询问我是否遗漏了任何内容。只有在没有使用proguard的情况下调试,我才能看到有生成的apk。

摇篮:

apply plugin: 'com.android.library'

android {
    signingConfigs {
        release {
            keyAlias KEY_ALIAS
            keyPassword KEY_PASSWORD
            storePassword STORE_PASSWORD
            storeFile file(STORE_FILE)
        }
    }

    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "boolean", "LOGGABLE", "false"
            signingConfig signingConfigs.release
        }
        debug {
            debuggable true
            minifyEnabled false            
        }
        pre_release {
            debuggable true
            signingConfig signingConfigs.release
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            buildConfigField "boolean", "LOGGABLE", "true"
        }
    }

    //sourceSets.main.jni.srcDirs = []
    // disable automatic ndk-build call, which ignore our Android.mk
    sourceSets.main.jniLibs.srcDir 'src/main/libs'

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:23.4.0'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'
    compile files('libs/pass-v1.2.1.jar')
    compile files('libs/sdk-v1.0.0.jar')


    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'io.card:android-sdk:5.3.4'
    compile 'com.jakewharton:butterknife:7.0.0'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.3.1'
    compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
    compile 'io.reactivex:rxjava:1.1.3'
    compile 'io.reactivex:rxandroid:1.1.0'
    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile 'com.j256.ormlite:ormlite-core:4.48'
    compile 'com.soundcloud.android:android-crop:1.0.0@aar'
    compile 'cn.pedant.sweetalert:library:1.3'

    compile 'com.github.PhilJay:MPAndroidChart:v2.2.0'
    compile 'com.makeramen:roundedimageview:2.2.1'
    compile 'com.splunk.mint:mint:5.0.0'
    compile 'com.facebook.stetho:stetho:1.3.1'
    compile 'com.facebook.stetho:stetho-okhttp3:1.3.1'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.0'
    compile 'com.dlazaro66.qrcodereaderview:qrcodereaderview:2.0.0'
    compile 'com.loopeer.library:cardstack:1.0.1'
    compile 'net.danlew:android.joda:2.9.4.1'


//    compile 'com.google.android.gms:play-services:9.6.1'  //commented to avoid app crash on xiomi devices, extended application to multi dex app
//    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:9.6.1'
    compile 'com.google.android.gms:play-services-location:9.6.1'
    compile 'com.google.android.gms:play-services-maps:9.6.1'
    compile 'com.jakewharton:butterknife:7.0.0'
    compile project(path: ':app')
    compile project(path: ':app')
    compile project(path: ':app')
    compile project(path: ':app')

}

proguard规则:

-dontwarn org.joda.convert.FromString
-dontwarn org.joda.convert.ToString



#GSON 2.2.4 specific rules ##

# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

-keepattributes EnclosingMethod

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }


# keep samsung sdk classes
# -keep class com.samsung.android.**{*;}
 -dontwarn com.samsung.android.**
 -dontnote com.samsung.android.**


#for fabric Crashlytics
-keep class com.crashlytics.** { *; }
-keep class com.crashlytics.android.**
-keepattributes SourceFile, LineNumberTable, *Annotation*


# Butter Knife
-keep class butterknife.** { *; }
-keep class **$$ViewBinder { *; }
-dontwarn butterknife.internal.**

-keepclasseswithmembernames class * {
    @butterknife.* <fields>;
}

-keepclasseswithmembernames class * {
    @butterknife.* <methods>;
}

#ormlite new
# for ormlite stuff
-keep class com.j256.**
-keepclassmembers class com.j256.** {*;}
-keep enum com.j256.**
-keepclassmembers enum com.j256.**  {*;}
-keep interface com.j256.**
-keepclassmembers interface com.j256.**  {*;}

# keep the classes and members of our entities or OrmLite will not work
-keep class com.korvac.liquid.model.**
-keepclassmembers com.korvac.liquid.model.** {*;}
-keep class com.korvac.liquid.activity.**
-keepclassmembers com.korvac.liquid.activity.** {*;}

# OrmLite
-keep class com.j256.**
-keepclassmembers class com.j256.** { *; }
-keep enum com.j256.**
-keepclassmembers enum com.j256.** { *; }
-keep interface com.j256.**
-keepclassmembers interface com.j256.** { *; }

# Picasso
-dontwarn com.squareup.okhttp.**

#Retrofit
# Retrofit 2.X
## https://square.github.io/retrofit/ ##

-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions

-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}


# Rxjava
-dontwarn sun.misc.**
-keep class rx.schedulers.Schedulers {
    public static <methods>;
}
-keep class rx.schedulers.ImmediateScheduler {
    public <methods>;
}
-keep class rx.schedulers.TestScheduler {
    public <methods>;
}
-keep class rx.schedulers.Schedulers {
    public static ** test();
}
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
    long producerIndex;
    long consumerIndex;
}
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
    long producerNode;
    long consumerNode;
}

# Model
-keep class com.korvac.liquid.model.** { *; }

# HttpResponse
-keep class com.korvac.liquid.network.response.HttpResponse { *; }

# SwipeRefreshLayout
-keepclassmembers class * extends com.korvac.liquid.fragment.BaseFragment {
    *;
}
-keep class **$Properties

# GMS
-keep class com.google.android.gms.** { *; }
-keep public class com.google.android.gms.**
-dontwarn com.google.android.gms.**

# MPAndroidChart
-keep class com.github.mikephil.charting.** { *; }
-dontwarn io.realm.**

# Sweet Alert
-keep class cn.pedant.SweetAlert.Rotate3dAnimation {
   public <init>(...);
}

#gif drawable
-keep public class pl.droidsonroids.gif.GifIOException{<init>(int);}
-keep class pl.droidsonroids.gif.GifInfoHandle{<init>(long,int,int,int);}

# appcompat
-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }

-keep public class * extends android.support.v4.view.ActionProvider {
    public <init>(android.content.Context);
}

# Updated as of Stetho 1.1.1
#
# Note: Doesn't include Javascript console lines. See https://github.com/facebook/stetho/tree/master/stetho-js-rhino#proguard
-keep class com.facebook.stetho.** { *; }

# Okio
-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**

Gradle日志:

Executing tasks: [:app:generateDevDebugSources, :app:generateDevDebugAndroidTestSources, :app:prepareDevDebugUnitTestDependencies, :app:mockableAndroidJar, :sdk:generateReleaseSources, :sdk:prepareReleaseUnitTestDependencies, :sdk:mockableAndroidJar]

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDevDebugBuild UP-TO-DATE
:app:checkDevDebugManifest
:app:preDevPre_releaseBuild UP-TO-DATE
:app:preDevReleaseBuild UP-TO-DATE
:app:preProDebugBuild UP-TO-DATE
:app:preProPre_releaseBuild UP-TO-DATE
:app:preProReleaseBuild UP-TO-DATE
:app:prepareCnPedantSweetalertLibrary13Library UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2340Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72340Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2340Library UP-TO-DATE
:app:preDevDebugAndroidTestBuild UP-TO-DATE
:app:preProDebugAndroidTestBuild UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72340Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42400Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2340Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidAnswers139Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidBeta122Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidCrashlytics262Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidCrashlyticsCore2311Library UP-TO-DATE
:app:prepareComDlazaro66QrcodereaderviewQrcodereaderview200Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase961Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement961Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm961Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIid961Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation961Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps961Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTasks961Library UP-TO-DATE
:app:prepareComLoopeerLibraryCardstack101Library UP-TO-DATE
:app:prepareComMakeramenRoundedimageview221Library UP-TO-DATE
:app:prepareComPnikosisMaterialishProgress10Library UP-TO-DATE
:app:prepareComSoundcloudAndroidAndroidCrop100Library UP-TO-DATE
:app:prepareDeHdodenhofCircleimageview200Library UP-TO-DATE
:app:prepareIoCardAndroidSdk534Library UP-TO-DATE
:app:prepareIoFabricSdkAndroidFabric1313Library UP-TO-DATE
:app:prepareIoReactivexRxandroid110Library UP-TO-DATE
:app:prepareNetDanlewAndroidJoda2941Library UP-TO-DATE
:app:preparePlDroidsonroidsGifAndroidGifDrawable120Library UP-TO-DATE
:app:prepareDevDebugDependencies
:app:compileDevDebugAidl UP-TO-DATE
:app:compileDevDebugRenderscript UP-TO-DATE
:app:generateDevDebugBuildConfig UP-TO-DATE
:app:mergeDevDebugShaders UP-TO-DATE
:app:compileDevDebugShaders UP-TO-DATE
:app:generateDevDebugAssets UP-TO-DATE
:app:mergeDevDebugAssets UP-TO-DATE
:app:processDevDebugManifest UP-TO-DATE
:app:fabricGenerateResourcesDevDebug
:app:generateDevDebugResValues UP-TO-DATE
:app:generateDevDebugResources
:app:mergeDevDebugResources
:app:processDevDebugResources
:app:generateDevDebugSources
:app:prepareComAndroidSupportMultidexInstrumentation101Library UP-TO-DATE
:app:prepareDevDebugAndroidTestDependencies
:app:compileDevDebugAndroidTestAidl UP-TO-DATE
:app:processDevDebugAndroidTestManifest UP-TO-DATE
:app:compileDevDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDevDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDevDebugAndroidTestResValues UP-TO-DATE
:app:generateDevDebugAndroidTestResources UP-TO-DATE
:app:mergeDevDebugAndroidTestResources UP-TO-DATE
:app:processDevDebugAndroidTestResources UP-TO-DATE
:app:generateDevDebugAndroidTestSources UP-TO-DATE
:app:preDevDebugUnitTestBuild UP-TO-DATE
:app:prepareDevDebugUnitTestDependencies
:app:mockableAndroidJar UP-TO-DATE
:sdk:preBuild UP-TO-DATE
:sdk:extractProguardFiles
:sdk:preReleaseBuild
:sdk:checkReleaseManifest
:sdk:preDebugAndroidTestBuild UP-TO-DATE
:sdk:preDebugBuild UP-TO-DATE
:sdk:preDebugUnitTestBuild UP-TO-DATE
:sdk:prePre_releaseBuild UP-TO-DATE
:sdk:prePre_releaseUnitTestBuild UP-TO-DATE
:sdk:preReleaseUnitTestBuild UP-TO-DATE
:sdk:prepareCnPedantSweetalertLibrary13Library
:sdk:prepareComAndroidSupportAnimatedVectorDrawable2340Library
:sdk:prepareComAndroidSupportAppcompatV72340Library
:sdk:prepareComAndroidSupportDesign2340Library
:sdk:prepareComAndroidSupportMultidex101Library
:sdk:prepareComAndroidSupportRecyclerviewV72340Library
:sdk:prepareComAndroidSupportSupportV42400Library
:sdk:prepareComAndroidSupportSupportVectorDrawable2340Library
:sdk:prepareComDlazaro66QrcodereaderviewQrcodereaderview200Library
:sdk:prepareComGoogleAndroidGmsPlayServicesBase961Library
:sdk:prepareComGoogleAndroidGmsPlayServicesBasement961Library
:sdk:prepareComGoogleAndroidGmsPlayServicesGcm961Library
:sdk:prepareComGoogleAndroidGmsPlayServicesIid961Library
:sdk:prepareComGoogleAndroidGmsPlayServicesLocation961Library
:sdk:prepareComGoogleAndroidGmsPlayServicesMaps961Library
:sdk:prepareComGoogleAndroidGmsPlayServicesTasks961Library
:sdk:prepareComLoopeerLibraryCardstack101Library
:sdk:prepareComMakeramenRoundedimageview221Library
:sdk:prepareComPnikosisMaterialishProgress10Library
:sdk:prepareComSoundcloudAndroidAndroidCrop100Library
:sdk:prepareDeHdodenhofCircleimageview200Library
:sdk:prepareIoCardAndroidSdk534Library
:sdk:prepareIoReactivexRxandroid110Library
:sdk:prepareNetDanlewAndroidJoda2941Library
:sdk:preparePlDroidsonroidsGifAndroidGifDrawable120Library
:sdk:prepareReleaseDependencies
:sdk:compileReleaseAidl
:sdk:compileReleaseRenderscript
:sdk:generateReleaseBuildConfig
:sdk:generateReleaseResValues
:sdk:generateReleaseResources
:sdk:mergeReleaseResources
:sdk:processReleaseManifest
:sdk:processReleaseResources
:sdk:generateReleaseSources
:sdk:prepareReleaseUnitTestDependencies
:sdk:mockableAndroidJar UP-TO-DATE

BUILD SUCCESSFUL

Total time: 24.768 secs

0 个答案:

没有答案