代码之家  ›  专栏  ›  技术社区  ›  Danilo

Android库:发布。aar上课。使用proguard时震击器为空

  •  8
  • Danilo  · 技术社区  · 7 年前

    我正在尝试生成一个具有 minifyEnabled true 但是,在版本内部。aar,课程。罐子变空了。

    我已经检查了我的 proguard规则。赞成的意见 看起来没问题。

    我甚至用默认值创建了一个新模块。gradle文件和设置时 minifyEnable true 发布版本仍然获得类。里面没有类的jar。

    毕竟,有可能生成一个混淆代码的android库吗?

    编辑1:添加模块生成。格拉德尔

    apply plugin: 'com.android.library'
    
    android {
        compileSdkVersion 27
        buildToolsVersion '27.0.0'
    
        defaultConfig {
            minSdkVersion 15
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"
    
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    
        }
    
        buildTypes {
            release {
                    minifyEnabled true
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                }
        }
    
        lintOptions {
            abortOnError false
        }
    }
    
    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.1', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
    
        compile 'org.apache.httpcomponents:httpcore:4.3.3'
        compile('org.apache.httpcomponents:httpmime:4.3.6') {
            exclude module: 'httpclient'
        }
    
        compile 'fr.bmartel:jspeedtest:1.25'
        compile "com.android.support:appcompat-v7:27.0.0"
        testCompile 'junit:junit:4.12'
    }
    
    1 回复  |  直到 7 年前
        1
  •  5
  •   Danilo    7 年前

    好的,过了一段时间我解决了我的问题。

    复制/粘贴默认proguard规则配置 (library.pro) 给我的 proguard规则。赞成的意见 . 您可以在中找到此文件和更多示例 sdk/tools/proguard/examples的路径 .

    有关更多信息,请阅读 this .

    在我的 建筑格拉德尔 I chagend:

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    
    }
    
    buildTypes {
        release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
    }
    

    收件人:

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    
    }
    
    buildTypes {
         release {
             minifyEnabled true
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
             consumerProguardFiles 'proguard-rules.pro' //added this line
         }
     }
    

    谢谢你的帮助!