更新到SDK 26后,Android Studio无法实例化一个或多个类

时间:2017-09-08 10:25:35

标签: java android xml gradle

下载SDK 26并更新我的项目后,我遇到了一些我成功修复的库冲突。但我有这个持久的问题,它在论坛或SO中无处可寻。

我的XML预览已损坏。我可以构建和运行程序,但由于这个原因我看不到任何东西:

enter image description here

我试过了:

  1. 将主题从Theme.AppCompat.Light.DarkActionBar更改为
    Base.Theme.AppCompat.Light.DarkActionBar
  2. Updating my gradle in a similar way
  3. 无效缓存/重启
  4. 检查并更新了我的所有库并删除了有关gradle的所有错误
  5. 更改了预览中的api
  6. 所有SDK均已更新。
  7. 在我更新到SDK 26之前一切都很好。所有可用的解决方案都不做任何事情。非常感谢帮助

    修改

    my gradle.build

    buildscript {
        repositories {
            maven { url 'https://maven.fabric.io/public' }
        }
    
        dependencies {
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }
    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'
    
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    
    
    android {
        compileSdkVersion 26
        buildToolsVersion "26.0.0"
        defaultConfig {
            applicationId "gr.softweb.sakouli"
            minSdkVersion 19
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true
        }
    
        buildTypes {
            release {
                minifyEnabled true
                shrinkResources true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
        packagingOptions {
            exclude 'META-INF/DEPENDENCIES.txt'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/dependencies.txt'
            exclude 'META-INF/LGPL2.1'
        }
    }
    
    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 project(path: ':linkedin-sdk')
        compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
            transitive = true;
        }
        //    configurations.all {
        //        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        //            def requested = details.requested
        //            if (requested.group == 'com.android.support') {
        //                if (!requested.name.startsWith("multidex")) {
        //                    details.useVersion '26.0.1'
        //                }
        //            }
        //        }
        //    }
        compile 'com.facebook.android:facebook-android-sdk:4.26.0'
        compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
        compile 'com.android.support:design:26.0.0-alpha1'
        compile 'com.android.support:customtabs:26.0.0'
        compile 'com.koushikdutta.ion:ion:2.2.1'
        compile 'com.google.code.gson:gson:2.8.1'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'de.hdodenhof:circleimageview:2.1.0'
        compile 'com.roughike:bottom-bar:2.3.1'
        compile 'com.ncapdevi:frag-nav:2.0.1'
        compile 'com.google.android.gms:play-services-maps:11.0.4'
        compile 'co.lujun:androidtagview:1.1.4'
        compile 'com.google.android.gms:play-services-gcm:11.0.4'
        compile 'com.braintreepayments.api:drop-in:3.1.0'
        testCompile 'junit:junit:4.12'
        apply plugin: 'com.google.gms.google-services'
    }
    

2 个答案:

答案 0 :(得分:1)

更新以下内容:

compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'

以下为我解决了问题:

compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'

Build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.example.myandroidgoogleappengine"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}

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:26.0.0-alpha1'
    compile 'com.android.support:design:26.0.0-alpha1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'

    compile 'com.google.firebase:firebase-database:11.2.2'
}

apply plugin: 'com.google.gms.google-services'

答案 1 :(得分:0)

我遇到了同样的问题。已更新 26.0.0 26.0.0-alpha1,问题就解决了。