无法找到 KickoffActivity Firebase
Unable to find KickoffActivity Firebase
我正在使用此站点构建一个聊天应用程序,仅用于学习目的。 https://code.tutsplus.com/tutorials/how-to-create-an-android-chat-app-using-firebase--cms-27397
不幸的是,我总是以错误告终。我发现了这个问题 但 none 的答案解决了我的问题。
这是错误信息:
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myapp.user.chatatwork/com.firebase.ui.auth.KickoffActivity}; have you declared this activity in your AndroidManifest.xml?
我的 AndroidManifest.xml
看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.myapp.user.chatatwork">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
android:supportsRtl="true"
tools:replace="android:value"
>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
</application>
这是我的 gradle(app)
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-core:10.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.firebaseui:firebase-ui:1.1.1'
compile 'com.android.support:design:26.0.0'
}
apply plugin: 'com.google.gms.google-services'
编辑
这是 Firebase 中的 KickoffActivity
class:
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class KickoffActivity extends HelperActivityBase {
private static final String TAG = "KickoffActivity";
private static final String IS_WAITING_FOR_PLAY_SERVICES = "is_waiting_for_play_services";
private static final int RC_PLAY_SERVICES = 1;
private boolean mIsWaitingForPlayServices = false;
public static Intent createIntent(Context context, FlowParameters flowParams) {
return ActivityHelper.createBaseIntent(context, KickoffActivity.class, flowParams);
}
@Override
protected void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
if (savedInstance == null || savedInstance.getBoolean(IS_WAITING_FOR_PLAY_SERVICES)) {
if (isOffline()) {
Log.d(TAG, "No network connection");
finish(ErrorCodes.NO_NETWORK,
IdpResponse.getErrorCodeIntent(ErrorCodes.NO_NETWORK));
return;
}
boolean isPlayServicesAvailable = PlayServicesHelper.makePlayServicesAvailable(
this,
RC_PLAY_SERVICES,
new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish(ResultCodes.CANCELED,
IdpResponse.getErrorCodeIntent(
ErrorCodes.UNKNOWN_ERROR));
}
});
if (isPlayServicesAvailable) {
SignInDelegate.delegate(this, mActivityHelper.getFlowParams());
} else {
mIsWaitingForPlayServices = true;
}
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
// It doesn't matter what we put here, we just don't want outState to be empty
outState.putBoolean(ExtraConstants.HAS_EXISTING_INSTANCE, true);
outState.putBoolean(IS_WAITING_FOR_PLAY_SERVICES, mIsWaitingForPlayServices);
super.onSaveInstanceState(outState);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_PLAY_SERVICES) {
if (resultCode == ResultCodes.OK) {
SignInDelegate.delegate(this, mActivityHelper.getFlowParams());
} else {
finish(ResultCodes.CANCELED,
IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR));
}
} else {
SignInDelegate delegate = SignInDelegate.getInstance(this);
if (delegate != null) delegate.onActivityResult(requestCode, resultCode, data);
}
}
/**
* Check if there is an active or soon-to-be-active network connection.
*
* @return true if there is no network connection, false otherwise.
*/
private boolean isOffline() {
ConnectivityManager manager =
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
return !(manager != null
&& manager.getActiveNetworkInfo() != null
&& manager.getActiveNetworkInfo().isConnectedOrConnecting());
}
}
改变这个:
implementation 'com.google.firebase:firebase-core:10.0.1'
compile 'com.firebaseui:firebase-ui:1.1.1'
到最新版本:
implementation 'com.firebaseui:firebase-ui-auth:3.3.0'
implementation 'com.firebaseui:firebase-ui-database:3.3.0'
implementation 'com.google.firebase:firebase-core:12.0.1'
出现以下错误:
Caused by: android.content.ActivityNotFoundException:
Unable to find explicit activity class {com.myapp.user.chatatwork/com.firebase.ui.auth.KickoffActivity};
have you declared this activity in your AndroidManifest.xml?
准确告诉您问题所在。您正在使用未在 AndroidManifest.xml
文件中声明的名为 KickoffActivity
的 activity。要解决此问题,请在 </activity>
标记之后添加以下代码行。
<activity android:name="com.firebase.ui.auth.KickoffActivity"/>
将 Firebase 和 Firebase-UI 依赖项更新到最新版本,正如 Peter 在他的回答中提到的,这是非常好的做法。
我正在使用此站点构建一个聊天应用程序,仅用于学习目的。 https://code.tutsplus.com/tutorials/how-to-create-an-android-chat-app-using-firebase--cms-27397
不幸的是,我总是以错误告终。我发现了这个问题
这是错误信息:
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myapp.user.chatatwork/com.firebase.ui.auth.KickoffActivity}; have you declared this activity in your AndroidManifest.xml?
我的 AndroidManifest.xml
看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.myapp.user.chatatwork">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
android:supportsRtl="true"
tools:replace="android:value"
>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
</application>
这是我的 gradle(app)
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-core:10.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.firebaseui:firebase-ui:1.1.1'
compile 'com.android.support:design:26.0.0'
}
apply plugin: 'com.google.gms.google-services'
编辑
这是 Firebase 中的 KickoffActivity
class:
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class KickoffActivity extends HelperActivityBase {
private static final String TAG = "KickoffActivity";
private static final String IS_WAITING_FOR_PLAY_SERVICES = "is_waiting_for_play_services";
private static final int RC_PLAY_SERVICES = 1;
private boolean mIsWaitingForPlayServices = false;
public static Intent createIntent(Context context, FlowParameters flowParams) {
return ActivityHelper.createBaseIntent(context, KickoffActivity.class, flowParams);
}
@Override
protected void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
if (savedInstance == null || savedInstance.getBoolean(IS_WAITING_FOR_PLAY_SERVICES)) {
if (isOffline()) {
Log.d(TAG, "No network connection");
finish(ErrorCodes.NO_NETWORK,
IdpResponse.getErrorCodeIntent(ErrorCodes.NO_NETWORK));
return;
}
boolean isPlayServicesAvailable = PlayServicesHelper.makePlayServicesAvailable(
this,
RC_PLAY_SERVICES,
new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
finish(ResultCodes.CANCELED,
IdpResponse.getErrorCodeIntent(
ErrorCodes.UNKNOWN_ERROR));
}
});
if (isPlayServicesAvailable) {
SignInDelegate.delegate(this, mActivityHelper.getFlowParams());
} else {
mIsWaitingForPlayServices = true;
}
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
// It doesn't matter what we put here, we just don't want outState to be empty
outState.putBoolean(ExtraConstants.HAS_EXISTING_INSTANCE, true);
outState.putBoolean(IS_WAITING_FOR_PLAY_SERVICES, mIsWaitingForPlayServices);
super.onSaveInstanceState(outState);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_PLAY_SERVICES) {
if (resultCode == ResultCodes.OK) {
SignInDelegate.delegate(this, mActivityHelper.getFlowParams());
} else {
finish(ResultCodes.CANCELED,
IdpResponse.getErrorCodeIntent(ErrorCodes.UNKNOWN_ERROR));
}
} else {
SignInDelegate delegate = SignInDelegate.getInstance(this);
if (delegate != null) delegate.onActivityResult(requestCode, resultCode, data);
}
}
/**
* Check if there is an active or soon-to-be-active network connection.
*
* @return true if there is no network connection, false otherwise.
*/
private boolean isOffline() {
ConnectivityManager manager =
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
return !(manager != null
&& manager.getActiveNetworkInfo() != null
&& manager.getActiveNetworkInfo().isConnectedOrConnecting());
}
}
改变这个:
implementation 'com.google.firebase:firebase-core:10.0.1'
compile 'com.firebaseui:firebase-ui:1.1.1'
到最新版本:
implementation 'com.firebaseui:firebase-ui-auth:3.3.0'
implementation 'com.firebaseui:firebase-ui-database:3.3.0'
implementation 'com.google.firebase:firebase-core:12.0.1'
出现以下错误:
Caused by: android.content.ActivityNotFoundException:
Unable to find explicit activity class {com.myapp.user.chatatwork/com.firebase.ui.auth.KickoffActivity};
have you declared this activity in your AndroidManifest.xml?
准确告诉您问题所在。您正在使用未在 AndroidManifest.xml
文件中声明的名为 KickoffActivity
的 activity。要解决此问题,请在 </activity>
标记之后添加以下代码行。
<activity android:name="com.firebase.ui.auth.KickoffActivity"/>
将 Firebase 和 Firebase-UI 依赖项更新到最新版本,正如 Peter 在他的回答中提到的,这是非常好的做法。