我正在尝试在设备上运行我的应用,但它在第一个活动时崩溃了。这是登录活动,似乎我的应用程序根本无法连接到Firebase,它会导致问题。 Logcat说:
E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
我已经google了很多,似乎问题在于清单文件。我尝试过复制粘贴很多东西,但没有任何作用。这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.elise.besafe">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="Bincle"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<service android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false"/>
<receiver android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.measurement.UPLOAD" />
</intent-filter>
</receiver>
<activity android:name="activities.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="activities.RegisterActivity" />
<activity
android:name="activities.ProfileVolunteerActivity"
android:label="@string/title_activity_profile_volunteer"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="activities.ProfileDisabledActivity"
android:label="@string/title_activity_profile_disabled"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name="activities.RegisterDisabledActivity" />
<activity
android:name="activities.GetHelpActivity"
android:label="@string/title_activity_get_help"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name="activities.BasicDisActivity"
android:label="@string/title_activity_basic_dis"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name="activities.HelpSbActivity" />
<activity android:name="activities.PointsActivity"> />
</application>
</manifest>
答案 0 :(得分:0)
就我而言,我通过将以下属性放在onCreate部分中来解决了这个问题:
setContentView(R.layout.activity_main);
FirebaseOptions.Builder builder = new FirebaseOptions.Builder()
.setApplicationId(1:0123456789012:android:0123456789abcdef")
.setApiKey("your_api_key")
.setDatabaseUrl("https://your-app.firebaseio.com")
.setStorageBucket("your-app.appspot.com");
FirebaseApp.initializeApp(this, builder.build());
我对每个键都使用字符串文件,例如:
(String.valueOf(R.string.setApplicationId))
这些属性或键可以在您的Json google-services文件中找到,也可以直接从firebase控制台中找到。希望我能帮上忙。