当前位置:   article > 正文

realm for android 集成问题 app:transformClassesWithRealmTransformerForDebug_transformclasseswithtransformrfordebug

transformclasseswithtransformrfordebug

Error:Execution failed for task ':app:transformClassesWithRealmTransformerForDebug'.

> com.android.build.gradle.BaseExtension.getDefaultConfig()Lcom/android/build/gradle/internal/dsl/DefaultConfig;

同步gradle文件的时候不会报错,realm库确实导入了,类的引用可以出来,但是一运行就报这样的错,请大家帮忙解决,在此非常感谢。

现在找到解决办法了,升级编译版本后,正常运行了。修改后的配置文件见文末。

project的buld.gradle 文件 

  1. // Top-level build file where you can add configuration options common to all sub-projects/modules.
  2. buildscript {
  3. repositories {
  4. jcenter()
  5. }
  6. dependencies {
  7. classpath 'com.android.tools.build:gradle:2.3.3'
  8. classpath "io.realm:realm-gradle-plugin:5.4.1"
  9. // NOTE: Do not place your application dependencies here; they belong
  10. // in the individual module build.gradle files
  11. }
  12. }
  13. allprojects {
  14. repositories {
  15. jcenter()
  16. }
  17. }
  18. task clean(type: Delete) {
  19. delete rootProject.buildDir
  20. }

app的build.gradle 文件

  1. apply plugin: 'com.android.application'
  2. apply plugin: 'realm-android'
  3. android {
  4. signingConfigs {
  5. config {
  6. keyAlias 'Key'
  7. keyPassword ''
  8. storeFile file('E:/Key.store')
  9. storePassword ''
  10. }
  11. }
  12. compileSdkVersion 25
  13. buildToolsVersion "25.0.2"
  14. defaultConfig {
  15. applicationId "guiyang.bonc.com.collection"
  16. minSdkVersion 15
  17. targetSdkVersion 25
  18. versionCode 1
  19. versionName "1.0.0"
  20. // testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  21. }
  22. // configurations.all {
  23. // resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
  24. // }
  25. buildTypes {
  26. release {
  27. minifyEnabled false
  28. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  29. }
  30. debug {
  31. minifyEnabled true
  32. signingConfig signingConfigs.config
  33. }
  34. }
  35. sourceSets {
  36. main {
  37. jniLibs.srcDirs = ['libs']
  38. jniLibs.srcDir 'libs'
  39. }
  40. }
  41. realm {
  42. syncEnabled = true;
  43. }
  44. }
  45. dependencies {
  46. compile fileTree(include: ['*.jar'], dir: 'libs')
  47. // androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
  48. // exclude group: 'com.android.support', module: 'support-annotations'
  49. // })
  50. compile 'com.android.support:appcompat-v7:25.3.1'
  51. compile 'com.android.support:support-v4:25.3.1'
  52. compile 'com.android.support:design:25.3.1'
  53. compile 'org.xutils:xutils:3.5.0'
  54. compile 'com.google.android.gms:play-services-appindexing:9.8.0'
  55. // testCompile 'junit:junit:4.12'
  56. compile files('libs/BaiduLBS_Android.jar')
  57. compile files('libs/httpmime-4.3.6.jar')
  58. compile 'com.bigkoo:pickerview:2.1.0'
  59. }

几乎用了一个下午的时间,终于解决。是在升级android stadio的配置后解决的 app的build.gradle 做了修改

以前,compileSdkVersion 25,现在compileSdkVersion 27

升级的过程中,按照提示gradle-wrapper.properties文件修改了,

以前,

  1. distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
  2. 现在
  3. distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

升级的过程中,按照提示project的build.gradle加了google();

以前 classpath 'com.android.tools.build:gradle:2.3.3'

现在classpath 'com.android.tools.build:gradle:3.0.0',

现在我本修改后的配置文件贴出来

gradle-wrapper.properties,路径是project/gradle/wrapper/gradle-wrapper.properties

#Tue Sep 19 16:14:25 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

project 下面的build.gradle

 

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath "io.realm:realm-gradle-plugin:5.4.1"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

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

app下面的gradle

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

android {


    compileSdkVersion 27
    buildToolsVersion "27.0.0"
    defaultConfig {
        applicationId "guiyang.bonc.com.collection"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0.0"
        multiDexEnabled true
//        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
//    configurations.all {
//        resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
//    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false

        }

    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
            jniLibs.srcDir 'libs'
        }

    }
    realm {
        syncEnabled = true;
    }
}


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:27.1.0'
    compile 'com.android.support:support-v4:27.1.0'
    compile 'com.android.support:design:27.1.0'
    compile 'org.xutils:xutils:3.5.0'
    compile 'com.google.android.gms:play-services-appindexing:9.8.0'
//    testCompile 'junit:junit:4.12'
    compile files('libs/BaiduLBS_Android.jar')
    compile files('libs/httpmime-4.3.6.jar')
    compile 'com.bigkoo:pickerview:2.1.0'

}

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/306616
推荐阅读
相关标签
  

闽ICP备14008679号