gpt4 book ai didi

android - "Failed to find provider info for com.my.package.urbanairship.provider"怎么解决?

转载 作者:行者123 更新时间:2023-11-29 00:15:44 25 4
gpt4 key购买 nike

我正在尝试在我的 Android 应用程序中使用 Urban AirshipGCM 启用推送通知。我使用给定的说明创建了一个 GCM 帐户 here并在 Urban Airship 上设置一个开发应用程序。然后我从显示的示例应用程序复制代码 here .

现在,当我运行我的应用程序时,我得到了

E/ActivityThread﹕ Failed to find provider info for com.my.package.urbanairship.provider

然后

E/ActivityThread﹕ Failed to find provider info for com.my.package.urbanairship.provider
E/XXXX - UALib﹕ Failed to insert in UrbanAirshipProvider.
java.lang.IllegalArgumentException: Unknown URL content://com.my.package.urbanairship.provider/preferences

我错过了什么?

app/src/main/assets/airshipconfig.properties

developmentAppKey = <my developmentAppKey>
developmentAppSecret = <my developmentAppSecret>
productionAppKey =
productionAppSecret =
gcmSender = <my gcmSender>
inProduction = false
# LogLevel is "VERBOSE", "DEBUG", "INFO", "WARN", "ERROR" or "ASSERT"
developmentLogLevel = DEBUG
productionLogLevel = ERROR
minSdkVersion = 15

app/src/main/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.package" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" /> <!-- Required for Push -->

<!-- Urban airship -->

<permission android:name="com.my.package.permission.UA_DATA" android:protectionLevel="signature" />
<uses-permission android:name="com.my.package.permission.UA_DATA" />
<!-- The two elements above ensure that only this application has access to the Urban Airship provider -->

<!-- GCM -->

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- This app has permission to register with GCM and receive message -->
<!-- MODIFICATION REQUIRED - Replace PACKAGE_NAME with your package name -->
<permission android:name="com.my.package.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.my.package.permission.C2D_MESSAGE" />
<!-- The two elements above ensure that only this application can receive the messages and registration result -->


<application
android:name=".MyApp"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

<!-- Urban Airship and GCM -->

<activity android:name="com.urbanairship.CoreActivity"/>

<!-- OPTIONAL, if you want to receive push, push opened and registration completed intents -->
<!-- Replace the receiver below with your package and class name -->
<receiver android:name=".GCMIntentReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.urbanairship.push.CHANNEL_UPDATED" />
<action android:name="com.urbanairship.push.OPENED" />
<action android:name="com.urbanairship.push.DISMISSED" />
<action android:name="com.urbanairship.push.RECEIVED" />
<!-- MODIFICATION REQUIRED - Use your package name as the category -->
<category android:name="com.my.package" />
</intent-filter>
</receiver>

<!-- REQUIRED for PlayServiceUtils.handleAnyPlayServicesError to handle Google Play services recoverable errors. -->
<activity
android:name="com.urbanairship.google.PlayServicesErrorActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<!-- REQUIRED for Urban Airship Push. The priority is important to be set lower than the
application's push intent receiver in order for the push intent receiver to handle push intents
before the core receiver. This allows the application to launch any activities before Urban
Airship performs any actions or falls back to launching the application launch intent. -->
<receiver android:name="com.urbanairship.CoreReceiver"
android:exported="false">
<intent-filter android:priority="-999">
<action android:name="com.urbanairship.push.OPENED" />
<!-- MODIFICATION REQUIRED - Use your package name as the category -->
<category android:name="com.my.package" />
</intent-filter>
</receiver>

<!-- REQUIRED for GCM -->
<receiver
android:name="com.urbanairship.push.GCMPushReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!-- MODIFICATION REQUIRED - Use your package name as the category -->
<category android:name="com.my.package" />
</intent-filter>
</receiver>

<service android:name="com.urbanairship.push.PushService" android:label="Push Notification Service" />

<!-- ... -->

</application>

</manifest>

app/src/main/java/com/my/package/MyApp

public class MyApp extends Application {

@Override
public void onCreate() {
super.onCreate();

/* ... */

/* Urban Airship */

UAirship.takeOff(this, new UAirship.OnReadyCallback() {
@Override
public void onAirshipReady(UAirship airship) {
// Perform any airship configurations here
// Create a customized default notification factory
DefaultNotificationFactory defaultNotificationFactory = new DefaultNotificationFactory(getApplicationContext());
defaultNotificationFactory.setSmallIconId(R.drawable.ic_launcher);
defaultNotificationFactory.setColor(NotificationCompat.COLOR_DEFAULT);
// Set it
airship.getPushManager().setNotificationFactory(defaultNotificationFactory);
// Enable Push
airship.getPushManager().setPushEnabled(true);
}
});
}
}

app/src/main/java/com/my/package/GCMIntentService

package com.my.package;

import android.content.Context;
import android.util.Log;

import com.urbanairship.push.BaseIntentReceiver;
import com.urbanairship.push.PushMessage;


public class GCMIntentReceiver extends BaseIntentReceiver {
private static final String TAG = "GCMIntentReceiver";
@Override
protected void onChannelRegistrationSucceeded(Context context, String channelId) {
Log.i(TAG, "Channel registration updated. Channel Id:" + channelId + ".");
// Broadcast that the channel updated. Used to refresh the channel ID on the main activity.
//LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(MainActivity.ACTION_UPDATE_CHANNEL));
}
@Override
protected void onChannelRegistrationFailed(Context context) {
Log.i(TAG, "Channel registration failed.");
}
@Override
protected void onPushReceived(Context context, PushMessage message, int notificationId) {
Log.i(TAG, "Received push notification. Alert: " + message.getAlert() + ". Notification ID: " + notificationId);
}
@Override
protected void onBackgroundPushReceived(Context context, PushMessage message) {
Log.i(TAG, "Received background push message: " + message);
}
@Override
protected boolean onNotificationOpened(Context context, PushMessage message, int notificationId) {
Log.i(TAG, "User clicked notification. Alert: " + message.getAlert());
return false;
}
@Override
protected boolean onNotificationActionOpened(Context context, PushMessage message, int notificationId, String buttonId, boolean isForeground) {
Log.i(TAG, "User clicked notification button. Button ID: " + buttonId + " Alert: " + message.getAlert());
return false;
}
@Override
protected void onNotificationDismissed(Context context, PushMessage message, int notificationId) {
Log.i(TAG, "Notification dismissed. Alert: " + message.getAlert() + ". Notification ID: " + notificationId);
}
}

最佳答案

我没有在您的 list 中看到定义的提供商。你应该有这样的东西:

<provider
android:name="provider"
android:authorities="com.my.package.urbanairship.provider"
android:exported="false"/>

关于android - "Failed to find provider info for com.my.package.urbanairship.provider"怎么解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27024390/

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