【问题标题】:ClassNotFoundException Didn't find class "com.google.android.gms.common.internal.zzbqClassNotFoundException 找不到类“com.google.android.gms.common.internal.zzbq
【发布时间】:2019-09-05 12:12:43
【问题描述】:

我必须将文件存储在 Firebase 存储中。

我的 Gradle 文件:

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.deadbrains.propertymanagement"
        minSdkVersion 18
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.github.jineshfrancs:CaptchaImageView:1.0'
    implementation 'com.google.code.gson:gson:2.8.1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation 'com.google.firebase:firebase-firestore:11.8.0'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
        transitive = true;
    }
}
apply plugin: 'com.google.gms.google-services' 

这是我的 build.gradle(项目:appname):

buildscript {

    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.0.2'
    }
}

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

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

当我上传文件时发生错误。 这是我上传文件的代码

private void uploadFile() {
        if (filePath != null) {
            pDialog = ProgressDialog.show( AddNoticeActivity.this ,"" ,"Wait..." ,false ,false );

            StorageReference riversRef = null;
            if (extension.equals( "docx" ) || extension.equals( "doc" )) {
                Random Number = new Random();
                int Rnumber = Number.nextInt( 100000 );
                String name = "doc" + Rnumber;
                riversRef = FirebaseStorage.getInstance().getReference().child( "Notice/" + name );
            } else if (extension.equals( "pdf" )) {
                Random Number = new Random();
                int Rnumber = Number.nextInt( 100000 );
                String name = "pdf" + Rnumber;
                riversRef = FirebaseStorage.getInstance().getReference().child( "Notice/" + name );
            } else {
                Random Number = new Random();
                int Rnumber = Number.nextInt( 100000 );
                String name = "pic" + Rnumber;
                riversRef = FirebaseStorage.getInstance().getReference().child( "Notice/" + name );
            }
            strAttachment = riversRef.getPath();
            Log.d( "storage path : " ,strAttachment );

            riversRef.putFile( filePath )
                    .addOnSuccessListener( new OnSuccessListener <UploadTask.TaskSnapshot>() {
                        @Override
                        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                            callAddNoticeService();
                        }
                    } )
                    .addOnFailureListener( new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception exception) {
                            Log.d( "Error" ,exception.getMessage() );
                            Toast.makeText( getApplicationContext() ,exception.getMessage() ,Toast.LENGTH_LONG ).show();
                        }
                    } )
                    .addOnProgressListener( new OnProgressListener <UploadTask.TaskSnapshot>() {
                        @Override
                        public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {

                        }
                    } );
        }
    }

在行显示错误

     riversRef = FirebaseStorage.getInstance().getReference().child( "Notice/" + name );

错误是

致命异常:java.lang.NoClassDefFoundError 无法解决: Lcom/google/android/gms/common/internal/zzbq;

当我升级依赖并显示错误时:

错误:找不到资源 android:attr/fontVariationSettings。 消息{种类=错误,文本=错误:资源 未找到 android:attr/fontVariationSettings。

错误:找不到资源 android:attr/ttcIndex。消息{种类=错误, text=error: 资源 android:attr/ttcIndex 未找到。

【问题讨论】:

标签: java android firebase android-gradle-plugin firebase-storage


【解决方案1】:

升级以下依赖:

 implementation 'com.google.firebase:firebase-storage:11.8.0'
 implementation 'com.google.firebase:firebase-firestore:11.8.0'
 implementation 'com.google.firebase:firebase-core:16.0.9'
 implementation 'com.google.firebase:firebase-messaging:18.0.0'
 implementation 'com.google.firebase:firebase-auth:17.0.0'

进入这个:

 implementation 'com.google.firebase:firebase-storage:19.0.0'
 implementation 'com.google.firebase:firebase-firestore:21.0.0'
 implementation 'com.google.firebase:firebase-core:17.2.0'
 implementation 'com.google.firebase:firebase-messaging:20.0.0'
 implementation 'com.google.firebase:firebase-auth:19.0.0'

在以下链接中查看最新版本:

https://firebase.google.com/support/release-notes/android

更新依赖项后,您需要迁移androidx,您可以在以下链接中找到方法:

https://stackoverflow.com/a/57005161/7015400

【讨论】:

  • 这些版本还需要 androidx 迁移
  • 然后他可以迁移..他可能稍后会迁移,所以贝蒂现在就这样做
  • 是的,他可以,也许你可以在答案中添加一个注释,因为他使用的是旧支持 27.x。
  • 我升级了依赖项,它显示错误:错误:找不到资源 android:attr/fontVariationSettings。消息{种类=错误,文本=错误:找不到资源 android:attr/fontVariationSettings。并且错误:找不到资源 android:attr/ttcIndex。消息{种类=错误,文本=错误:资源 android:attr/ttcIndex 未找到。 @PeterHaddad
  • @UnnatiPatadia 你也这样做了stackoverflow.com/a/57005161/7015400 吗?
猜你喜欢
  • 2019-04-01
  • 2018-12-30
  • 1970-01-01
  • 2017-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多