错误:使用Android Studio 3.0 Beta 6进行数据绑定

时间:2017-09-23 10:09:05

标签: java android android-studio data-binding

我已将数据绑定应用于Android Studio 2.3.3中运行良好的项目,就像我为Android Studio 3.0 Beta 6配置它一样,它停止了工作。

找不到任何数据绑定包。我在库模块中为数据绑定添加了一些基类,这可能是个问题吗?请检查proguard文件。

注意:我已经尝试了大多数问题&在SO中给出的答案所以请不要将此标记为重复

注意:评论中建议底部没有错误。正如我已经说过的项目在Android Studio 2.3.3中成功运行

项目build.gradle:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta6'
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
        google()
    }
}

project.ext {
    APPLICATION_ID = "com.packagename"
    BUILD_TOOLS_VERSION = "26.0.1"

    COMPILE_SDK_VERSION = 26
    TARGET_SDK_VERSION = 26
    MIN_SDK_VERSION = 19

    VERSION_CODE = 1
    VERSION_NAME = "1.0"

    SUPPORT_LIB_VERSION = "26.1.0"
    RETROFIT_VERSION = "2.3.0"
    GOOGLE_VERSION = "11.2.2"
    GLIDE_VERSION = "3.7.0"
    DATA_BINDING_VERSION = "1.3.3"

    MINIFY_ENABLE = false
    SHRINK_RESOURCES = false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app module build.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion COMPILE_SDK_VERSION
    buildToolsVersion BUILD_TOOLS_VERSION

    defaultConfig {
        minSdkVersion MIN_SDK_VERSION
        targetSdkVersion TARGET_SDK_VERSION

        versionCode VERSION_CODE
        versionName VERSION_NAME
    }
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
    dataBinding {
        enabled = true
    }
    buildTypes {
        release {
            minifyEnabled MINIFY_ENABLE
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
def supportLibVersion = SUPPORT_LIB_VERSION
def retrofitVersion = RETROFIT_VERSION
def googleVersion = GOOGLE_VERSION
def glideVersion = GLIDE_VERSION
def dataBindingVersion = DATA_BINDING_VERSION
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "com.android.support:appcompat-v7:$supportLibVersion"
    implementation "com.android.support:design:$supportLibVersion"

    implementation "com.android.databinding:library:$dataBindingVersion"
    implementation "com.android.databinding:adapters:$dataBindingVersion"

    implementation("com.google.firebase:firebase-messaging:$googleVersion") {
        exclude group: 'com.android.support', module: 'support-v4'
    }

    //Retrofit
    implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"

    //OkHttp Interceptor
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'

    //RxJava
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.1'

    implementation "com.github.bumptech.glide:glide:$glideVersion"
}

支持模块build.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion COMPILE_SDK_VERSION
    buildToolsVersion BUILD_TOOLS_VERSION

    defaultConfig {
        minSdkVersion MIN_SDK_VERSION
        targetSdkVersion TARGET_SDK_VERSION

        versionCode VERSION_CODE
        versionName VERSION_NAME
    }
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
    dataBinding {
        enabled = true
    }
    buildTypes {
        release {
            minifyEnabled MINIFY_ENABLE
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
def supportLibVersion = SUPPORT_LIB_VERSION
def retrofitVersion = RETROFIT_VERSION
def googleVersion = GOOGLE_VERSION
def glideVersion = GLIDE_VERSION
def dataBindingVersion = DATA_BINDING_VERSION
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "com.android.support:appcompat-v7:$supportLibVersion"
    implementation "com.android.support:design:$supportLibVersion"

    implementation "com.android.databinding:library:$dataBindingVersion"
    implementation "com.android.databinding:adapters:$dataBindingVersion"

    implementation("com.google.firebase:firebase-messaging:$googleVersion") {
        exclude group: 'com.android.support', module: 'support-v4'
    }

    //Retrofit
    implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"

    //OkHttp Interceptor
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'

    //RxJava
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.1'

    implementation "com.github.bumptech.glide:glide:$glideVersion"
}

支持模块proguard:

-keep class com.support.** { *; }

#Retrofit Start
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on RoboVM on iOS. Will not be used at runtime.
-dontnote retrofit2.Platform$IOS$MainThreadExecutor
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
#if using @Header or @Query
-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}

#GSON
-keep class com.google.gson.** { *; }
-keep class com.google.inject.** { *; }
-keep class org.apache.http.** { *; }
-keep class javax.inject.** { *; }
-keep class retrofit.** { *; }
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
-keepclassmembernames interface * {
    @retrofit.http.* <methods>;
}
-keep interface retrofit.** { *;}
-keep interface com.squareup.** { *; }
-dontwarn rx.**
-dontwarn retrofit.**

#retrofit models
-keep class com.google.gson.examples.android.model.** { *; }
-keep class com.support.retrofit.model.** { *; }

-keepattributes InnerClasses
-keepattributes Deprecated
-keepattributes EnclosingMethod
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions
#Retrofit End

-keep public class * extends java.lang.Exception

#Fabric
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**

#Glide
-dontwarn java.nio.file.**
-dontwarn org.codehaus.mojo.animal_sniffer.**

#Glide Module
-keep class com.bumptech.glide.GeneratedAppGlideModuleImpl
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.AppGlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}
-keep class com.bumptech.glide.integration.okhttp3.OkHttpGlideModule

#Support Library
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }

#DataBinding
-dontwarn android.databinding.**
-keep class android.databinding.** { *; }
-keep class <com.support>.databinding.** {
    <fields>;
    <methods>;
}

Error Screenshot

0 个答案:

没有答案