依赖关系有什么问题?我正在使用androidX

时间:2019-11-15 04:11:42

标签: android firebase

这是我的模块应用。我认为 firebaseUi依赖关系是导致错误的原因, 但我不确定。有人帮忙。

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'

    implementation 'com.google.android.material:material:1.0.0'

    implementation 'com.firebaseui:firebase-ui-database:6.0.2'

    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-database:16.0.4'

    implementation 'com.google.firebase:firebase-core:16.0.4'

    implementation 'androidx.cardview:cardview:1.0.0'


    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

应用程序崩溃了, 这是堆栈跟踪的一部分 产生的

 11-11 11:19:05.890 18032-18032/? E/Zygote: MountEmulatedStorage()
11-11 11:19:05.890 18032-18032/? E/Zygote: v2
11-11 11:19:05.900 18032-18032/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
11-11 11:19:06.320 18032-18032/com.example.mytasks E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.mytasks, PID: 18032
    java.lang.NoClassDefFoundError: com.google.firebase.auth.internal.zzae
        at com.google.firebase.auth.FirebaseAuth.zzcb(Unknown Source)
        at com.google.firebase.auth.FirebaseAuth.zza(Unknown Source)
        at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
        at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
        at com.google.firebase.auth.internal.zzj.<init>(Unknown Source)
        at com.google.firebase.auth.zzp.create(Unknown Source)

2 个答案:

答案 0 :(得分:1)

我的猜测是您错过了根级(项目级)Gradle文件中的某些依赖项。检查是否所有这些:

class MATH
{
public:
  virtual ~MATH(){}
    virtual int Tong(int a, int b)
    {
        return a + b;
    }
};

class MockMATH : public MATH
{
public:
    MOCK_METHOD2(Tong, int(int,int));
};

class TestMATH
{
    MATH m ;
public:
    int TestTong(int a, int b)
    {
      cout<<"TONG"<<endl;
        if(m.Tong(a,b))
        {
            cout<<"Successful"<<endl;
            return a+b;
        }
        else
        {
            cout<<"Failed"<<endl;
            return -1;
        }

    }

};

TEST(MyMathTest, Tong_by_true)
{
    MockMATH mM;
    TestMATH math;
    EXPECT_CALL(mM,Tong(_,_));
    //.WillOnce(Return(9));

    int retValue = math.TestTong(4,5);
  std::cout<<retValue<<std::endl;
    EXPECT_EQ(retValue,9);
}

int main(int argc, char** argv)
{ 
  ::testing::InitGoogleTest(&argc, argv);
  int ret = RUN_ALL_TESTS();
  return ret;
}

答案 1 :(得分:0)

显然您似乎正在使用不支持androidx的旧版本。

这里的解决方案是使用最新版本。

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'

    implementation 'com.google.android.material:material:1.0.0'

    implementation 'com.firebaseui:firebase-ui-database:6.1.0'

    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-auth:19.1.0'
    implementation 'com.google.firebase:firebase-database:19.2.0'

//  No longer required implementation 'com.google.firebase:firebase-core:17.2.1' 

    implementation 'com.google.firebase:firebase-analytics:17.2.1'
    implementation 'androidx.cardview:cardview:1.0.0'


    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

请在此处参考最新版本,