使用providerInstaller时java.lang.ClassNotFoundException:在路径上找不到类:DexPathList

时间:2015-03-02 12:39:45

标签: java android eclipse

package com.example.providerinstallertest;

import android.app.Activity;


   import android.content.Intent;
    import android.os.Bundle;
    import android.widget.Toast;

    import com.google.android.gms.common.GooglePlayServicesUtil;
    import com.google.android.gms.security.ProviderInstaller;
    import com.google.android.gms.security.ProviderInstaller.ProviderInstallListener;

    public class MainActivity extends Activity implements ProviderInstallListener {
        /**
         * Updating provider asynchronously.
         */
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            // Update the provider asynchronously
            ProviderInstaller.installIfNeededAsync(this, this);
        }
        /**
         * The provider is already installed and up-to-date.
         */
        @Override
        public void onProviderInstalled() {
            Toast.makeText(this, "Provider Installed.Google play Services are up-to-date", Toast.LENGTH_SHORT).show();
        }
        /**
         * Provider Installation failed. Check errorCode whether it is recoverable
         * or not.
         */
        @Override
        public void onProviderInstallFailed(int errorCode, Intent intent) {
            if (GooglePlayServicesUtil.isUserRecoverableError(errorCode)) {
                // Retry to install update in case of recoverable error.
                ProviderInstaller.installIfNeededAsync(this, this);
            } else {
                // Please update your Google Play Services.
                Toast.makeText(this, "Please update your Google Play Services.", Toast.LENGTH_SHORT).show();
            }
        }
    }

得到以下例外: -

java.lang.ClassNotFoundException: Didn't find class "com.example.providerinstallertest.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.providerinstallertest-2.apk"],nativeLibraryDirectories= [/data/app-lib/com.example.providerinstallertest-2, /vendor/lib, /system/lib]]

此处显示文件:

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.providerinstallertest.MainActivity"
            android:label="@string/app_name" >
            <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>

</manifest>

0 个答案:

没有答案