Android log cat displays android.content.pm.packagemanager $namenotfoundexception: app package com.google.android.ba
I'm a newer Android. When I try to run my application in AVD, I find the following exception in the log cat, which shows that unfortunately my application can't run. Please help me
android.content.pm.PackageManager$NameNotFoundException: Application package com.google.android.backup not found
at android.app.ContextImpl.createPackageContextAsUser(ContextImpl.java:2172)
at android.app.ContextImpl.createPackageContext(ContextImpl.java:2148)
at android.content.Contextwrapper.createPackageContext(Contextwrapper.java:671)
at com.google.android.gms.backup.an.<init>(SourceFile:47)
at com.google.android.gms.backup.BackupTransportMigratorService.f(SourceFile:248)
at com.google.android.gms.backup.BackupTransportMigratorService.b(SourceFile:196)
at com.google.android.gms.backup.BackupTransportMigratorService.onHandleIntent(SourceFile:131)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
My android list is as follows
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cornex.criminalintent" >
<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name=".CrimeListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".CrimePagerActivity"
android:label="@string/app_name" >
</activity>
</application>
resolvent:
To create a data backup application, you need to register your application with Google backup service. This is explained in the example. After registration, you must specify its key in androidmanifest.xml
<application
android:allowBackup="true"
android:backupAgent="YOUR_BACKUP_AGENT">
<Meta-data
android:name="com.google.android.backup.api_key"
android:value="YOUR_API_KEY" />
</application>
Android provides the backupagenthhelper class to handle all operations of data backup. To use this class, you must use it to extend your class. Its syntax is as follows: the corresponding backup agent can be implemented, as shown in the following list
import android.app.backup.BackupAgentHelper;
public class YOUR_BACKUP_AGENT extends BackupAgentHelper {
}
The persistent data to be backed up is one of two forms. It can be sharedprefrences or file. Android supports two types of backup in the respective classes of sharedpreferencesbackuphelper and filebackuphelper
To use sharedpereferencebackuphelper, you need to instantiate its object with the name of the sharedpereferences file. Its syntax is as follows -
static final String File_Name_Of_Prefrences = "myPrefrences";
SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, File_Name_Of_Prefrences);
The last thing you need to do is call the addhelper method by specifying the backup key string and helper object. Its syntax is as follows -
addHelper(PREFS_BACKUP_KEY, helper);
The addhelper method automatically adds a helper to the configuration of the agent to a given subset of data
For more information, see this tutorial and this article