【问题标题】:Android aar library does not include BR classAndroid aar 库不包含 BR 类
【发布时间】:2016-10-20 09:58:06
【问题描述】:

我开发了一个小型库,用于测试使用数据绑定创建 aar 库。

我的问题是,当我生成 aar 文件时,它不包含为布局中的数据绑定引用生成的 BR 类。但是这个类是由 Android Studio 生成的。

你有解决这个问题的办法吗?

提前致谢。

build.gradle

apply plugin: 'com.android.library'
apply plugin: 'android-maven'

android {
    signingConfigs {
        release {
            keyAlias 'homelightcore'
            keyPassword 'overcraft'
            storeFile file('/Users/acidspike/Development/Certificats/Android/HomeLight/Core/homelightcore.jks')
            storePassword 'overcraft'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }
    dataBinding {
        enabled = true
    }
}

version '1.0'
group "fr.acidspike.homelight"

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    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.loopj.android:android-async-http:1.4.9'
}

proguard-rules.pro

-keep public class *

-keepclassmembers public class * {
   public *;
}

-keepattributes Exceptions

【问题讨论】:

    标签: android android-library aar android-databinding


    【解决方案1】:

    我找到了解决方案,这是因为proguard没有检测到BR类成员的使用情况。

    我已添加:

    -keepclassmembers class **.R$* {
        public static <fields>;
    }
    

    进入 proguard-rules.pro 和 BR 类从 .aar 变得可用

    【讨论】:

      猜你喜欢
      • 2015-02-24
      • 2018-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 2015-11-11
      • 1970-01-01
      相关资源
      最近更新 更多