Firebase文件未找到异常

时间:2017-01-03 09:17:03

标签: android firebase build.gradle geofire

我在Rideshare应用程序中使用Firebase数据库,我正在尝试将代码转储到设备中,它向我显示文件未找到例外,其中Jackson数据绑定库文件未在构建时集成。我需要清理它并gradle运行它10或15次然后它安装一次。我在我的代码中将Firebase数据快照转换为我的自定义java对象,并且Jackson库文件丢失,最终映射失败。 尝试删除传统的Api,只是再次看到它崩溃。有人帮助我。

以下是我一直在收到的错误:

  

错误:无法捕获任务的输出文件的快照   在最新检查期间'transformClassesWithDexForDebug'。

     
    

java.io.FileNotFoundException:D:\ FirebaseDBTesting \ app \ build \ intermediates \ transforms \ dex \ debug \ folders \ 1000 \ 10 \ jackson-databind-2.2.2_502dac698d8ab87b5c73024fb2c1baa4c979a770 \ classes.dex     (系统找不到指定的文件)

  

这是我的gradle文件:

apply plugin: 'com.android.application'

android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice.txt'
    }
    compileSdkVersion 23
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "com.example.xinthe.firebasedbtesting"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    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'
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.firebase:geofire-android:2.1.1'
    compile 'com.google.firebase:firebase-crash:10.0.1'
    compile 'com.google.firebase:firebase-auth:10.0.1'
    compile 'com.firebase:firebase-client-android:2.5.2'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:design:23.4.0'
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.serhatsurguvec.libraries:continuablecirclecountdownview:1.2'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

3 个答案:

答案 0 :(得分:0)

首先尝试清理并重建项目。

然后打开文件 - >使高速缓存/重新启动无效,单击蓝色按钮使高速缓存/重新启动无效。

答案 1 :(得分:0)

查看这些更改是否有帮助:

compileSdkVersion 25
buildToolsVersion "25.0.3"

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    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' // <= CHANGE
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.firebase:geofire-android:2.1.1'
    compile 'com.google.firebase:firebase-crash:10.0.1'
    compile 'com.google.firebase:firebase-auth:10.0.1'
    compile 'com.firebase:firebase-client-android:2.5.2'  // <= Why using legacy SDK??
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:design:25.3.1' // <= CHANGE
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.android.support:support-v4:25.3.1' // <= CHANGE
    compile 'com.serhatsurguvec.libraries:continuablecirclecountdownview:1.2'
    testCompile 'junit:junit:4.12'
}

正如我在评论中指出的那样,您正在构建旧版SDK和10.x.x SDK。这通常是不必要的,可能会导致问题。遗留SDK中是否存在您认为10.x.x SDK中没有的内容?

答案 2 :(得分:0)

TL; DR

正如@ bob-snyder所提到的,为什么要同时使用旧版API和最新版API?您是否正在迁移应用代码?

Cleaner build gradle

有几次我们被Gradle构建所控制,所以为了使更新构建依赖项不易出错并且容易修复错误,我们应该更好地构造配置文件。

杰克逊&amp; Firebase 3

Jackson依赖项是原始Firebase的一部分,而不是Firebase 3.如果您要将应用程序从2迁移到3,我建议您将数据对象迁移到Google Gson

启用缩小

您没有使用这么多库,您应该被迫使用multidexFirebase-UI AndroidAndroid Blueprints有很多关于如何配置ProGuard文件的例子。

支持库版本

在根项目build.gradle文件中定义您的库版本,如Google Samples所示:

ext {
    // SDK and tools
    minSdkVersion = 10
    targetSdkVersion = 25
    compileSdkVersion = 25
    buildToolsVersion = '25.0.0'

    // App dependencies
    firebaseVersion = '11.0.2'
    guavaVersion = '18.0'
    googleServicesVersion = rootProject.firebaseVersion
    supportLibraryVersion = '25.3.1'
}

并使用项目rootProject中的build.gradle值:

dependencies {
    compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
    compile "com.android.support:design:$rootProject.supportLibraryVersion"
    compile "com.android.support:support-v4:$rootProject.supportLibraryVersion"

    // Legacy Firebase
    compile "com.firebase:firebase-client-android:2.5.2"
    compile "com.firebase:geofire-android:2.1.1"

    // Google Services
    compile "com.google.android.gms:play-services-location:$rootProject.googleServicesVersion"
    compile "com.google.android.gms:play-services-maps:$rootProject.googleServicesVersion"

    // Google Firebase
    compile "com.google.firebase:firebase-auth:$rootProject.firebaseVersion"
    compile "com.google.firebase:firebase-crash:$rootProject.firebaseVersion"
    compile "com.google.firebase:firebase-database:$rootProject.firebaseVersion"

    compile 'com.serhatsurguvec.libraries:continuablecirclecountdownview:1.2'
}