赞
踩
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 文件
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' 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() } } task clean(type: Delete) { delete rootProject.buildDir }
app的build.gradle 文件
apply plugin: 'com.android.application' apply plugin: 'realm-android' android { signingConfigs { config { keyAlias 'Key' keyPassword '' storeFile file('E:/Key.store') storePassword '' } } compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { applicationId "guiyang.bonc.com.collection" minSdkVersion 15 targetSdkVersion 25 versionCode 1 versionName "1.0.0" // 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 true signingConfig signingConfigs.config } } 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:25.3.1' compile 'com.android.support:support-v4:25.3.1' compile 'com.android.support:design:25.3.1' 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' }
几乎用了一个下午的时间,终于解决。是在升级android stadio的配置后解决的 app的build.gradle 做了修改
以前,compileSdkVersion 25,现在compileSdkVersion 27
升级的过程中,按照提示gradle-wrapper.properties文件修改了,
以前,
- distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
- 现在
- 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' }
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。