gpt4 book ai didi

java - 无法使用最新的 Firebase 版本创建用户。我得到一个 W/DynamiteModule 和 W/GooglePlayServicesUtil

转载 作者:太空宇宙 更新时间:2023-11-03 12:04:03 26 4
gpt4 key购买 nike

我想在我的应用中添加 Firebase 身份验证和 Firebase 云消息传递。关注最新get started guide后我无法创建新用户。我也考虑过this code example .我在我的 Firebase 控制台中启用了:

  • 使用电子邮件/密码登录
  • 并出于测试目的匿名登录

输出:

D/EmailPassword: onAuthStateChanged:signed_out
D/EmailPassword: createAccount:mail
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
W/GooglePlayServicesUtil: Google Play services out of date. Requires 10084000 but found 9877470

我发现了类似的问题,但所有答案都没有帮助我解决我的问题...我认为这只是一个愚蠢的小错误,但我无法解决问题。


我在应用级别的 gradle 文件如下所示:

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "app.radiant.c.lly"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}

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.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:appcompat-v7:24.2.1'
//compile 'com.google.android.gms:play-services-appindexing:9.8.0'
compile 'com.google.android.gms:play-services:10.0.0'
compile 'com.android.support:design:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:24.2.1'

// Firebase Dependencies
compile 'com.google.firebase:firebase-core:10.0.0'
compile 'com.google.firebase:firebase-auth:10.0.0'
compile 'com.google.firebase:firebase-messaging:10.0.0'
}

// Firebase Plugin
apply plugin: 'com.google.gms.google-services'

我在项目级别的 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.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

// Added this line for Firebase
classpath 'com.google.gms:google-services:3.0.0'
}
}

allprojects {
repositories {
jcenter()
}
}

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

我有一个外部数据库,用于存储登录用户。在 Firebase 中,我只想使用默认密码存储来 self 的数据库的电子邮件地址。为此,我刚刚创建了一个按钮,该按钮应在按下时将用户存储在 Firebase 上。

public class InboxFragment extends Fragment {

View view;
Activity callingActivity;
Account account;
ListView chats;
Button btn;

ArrayList<String> exampleContent = new ArrayList<>();
ArrayAdapter<String> adapter;

// Firebase instance variables
private static final String TAG = "EmailPassword";
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
String username;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_inbox, container, false);
callingActivity = getActivity();
account = (Account) callingActivity.getApplication();

// Firebase
// [START initialize_auth]
mAuth = FirebaseAuth.getInstance();
// [END initialize_auth]

// [START auth_state_listener]
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
} else {
// User is signed out
Log.d(TAG, "onAuthStateChanged:signed_out");
}
// [START_EXCLUDE]
//updateUI(user);
// [END_EXCLUDE]
}
};
// [END auth_state_listener]

btn = (Button) view.findViewById(R.id.addUsernameBtn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
createAccount(account.getEmail(), "empty");
}
});

// Code
chats = (ListView) view.findViewById(R.id.userChatList);

// Add example content to array
exampleContent.add("Chat 1");
exampleContent.add("Chat 2");
//exampleContent.add(username);

adapter = new ArrayAdapter<String>(callingActivity, android.R.layout.simple_list_item_1, exampleContent);
chats.setAdapter(adapter);

chats.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getActivity(), ChatActivity.class);
startActivity(i);
}
});

return view;
}

// [START on_start_add_listener]
@Override
public void onStart() {
super.onStart();
mAuth.addAuthStateListener(mAuthListener);
}
// [END on_start_add_listener]

// [START on_stop_remove_listener]
@Override
public void onStop() {
super.onStop();
if (mAuthListener != null) {
mAuth.removeAuthStateListener(mAuthListener);
}
}
// [END on_stop_remove_listener]

private void createAccount(String email, String password) {
Log.d(TAG, "createAccount:" + email);
/*if (!validateForm()) {
return;
}*/

//showProgressDialog();

// [START create_user_with_email]
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(getActivity(), new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());

// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
Log.e(TAG, "ERROR");
/*Toast.makeText(EmailPasswordActivity.this, R.string.auth_failed,
Toast.LENGTH_SHORT).show();*/
}

// [START_EXCLUDE]
//hideProgressDialog();
// [END_EXCLUDE]
}
});
// [END create_user_with_email]
}

}

但这行不通。我得到了输出(请参阅问题顶部)。

最佳答案

问题是:

W/GooglePlayServicesUtil: Google Play services out of date.  Requires 10084000 but found 9877470

如果您在模拟器上运行,则需要将 Play 服务和 Firebase 库降级到版本 9.8.0 或 9.6.1,具体取决于您模拟的 API 级别。没有发布支持版本 10.0.0 的模拟器镜像。

如果您在真实设备上运行,则需要更新您的 Google Play 服务版本。当前版本为 10.0.84。您可以前往“设置”>“应用程序管理器”>“Google Play 服务”查看手机上安装的版本。

此日志消息并不表示存在问题。正常运行时好像是这样输出的:

W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.

关于java - 无法使用最新的 Firebase 版本创建用户。我得到一个 W/DynamiteModule 和 W/GooglePlayServicesUtil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40740372/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com