Android:无法实例化应用程序错误

时间:2014-09-20 11:16:31

标签: java android eclipse

运行我的apk时出现此错误:

09-20 14:08:57.052: E/AndroidRuntime(5430): FATAL EXCEPTION: main
09-20 14:08:57.052: E/AndroidRuntime(5430): java.lang.RuntimeException: Unable to instantiate application com.soinfit.serverAndServices.ErrorReport: java.lang.ClassNotFoundException: Didn't find class "com.soinfit.serverAndServices.ErrorReport" on path: DexPathList[[zip file "/data/app/com.soinfit-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.soinfit-1, /system/lib]]
09-20 14:08:57.052: E/AndroidRuntime(5430):     at android.app.LoadedApk.makeApplication(LoadedApk.java:509)
09-20 14:08:57.052: E/AndroidRuntime(5430):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4417)

我已经在stackoverflow上阅读了有关此问题的所有主题,没有人帮助过我。

  • 我清理了我的项目
  • 已检查订单并导出

我的应用程序项目是这个类:

package serverAndServices;

import org.acra.ACRA;
import org.acra.ReportField;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;

import serverAndServices.ServerUtilities;
import android.app.Application;

import com.soinfit.R;

@ReportsCrashes(formKey = "dGVacG0ydVHnaNHjRjVTUTEtb3FPWGc6MQ",

customReportContent = { ReportField.APP_VERSION_CODE,
        ReportField.APP_VERSION_NAME, ReportField.ANDROID_VERSION,
        ReportField.PHONE_MODEL, ReportField.CUSTOM_DATA, ReportField.BUILD,
        ReportField.STACK_TRACE, ReportField.LOGCAT, ReportField.DEVICE_ID }, formUri = ServerUtilities.ERROR_REPORT_FILE, mode = ReportingInteractionMode.TOAST, forceCloseDialogAfterToast = false, // optional,
                                                                                                                                                                                                            // default
                                                                                                                                                                                                            // false
resToastText = R.string.error_happned)

public class ErrorReport extends Application {

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

        // The following line triggers the initialization of ACRA
        ACRA.init(ErrorReport.this);
    }

}

在我的清单中,我有这段代码:

  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.soinfit"
    android:versionCode="36"
    android:versionName="1.16" >

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <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="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

    <permission
        android:name="com.soinfit.gcm.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.soinfit.gcm.permission.C2D_MESSAGE" />

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="20" />

    <application
        android:name=".serverAndServices.ErrorReport"
        android:allowBackup="true"
        android:configChanges="orientation|keyboardHidden|screenSize|locale"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:debuggable="false"      
        android:theme="@style/AppTheme" >
        <activity
            android:name="soInFitMain.SplashScreen"
            android:configChanges="keyboardHidden|orientation"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="soInFitMain.ProgramPlay" >
        </activity>
        <activity android:name="soInFitMain.SocialPage" >
        </activity>
        <activity android:name="soInFitMain.RegisterPage" >
        </activity>
        <activity android:name="soInFitMain.FinishProgramPage" >
        </activity>
        <activity android:name="soInFitMain.ProgramBuilder" >
        </activity>
        <activity android:name="soInFitMain.BuildProgramScreen" >
        </activity>
        <activity android:name="soInFitMain.ChooseProgramType" >
        </activity>
        <activity android:name="soInFitMain.SettingChoosePage" >
        </activity>
        <activity android:name="soInFitMain.ProfilePage" >
        </activity>
        <activity android:name="soInFitMain.PersonalDetails" >
        </activity>
        <activity android:name="soInFitMain.PrivacyPage" >
        </activity>
        <activity android:name="soInFitMain.HomePage" >
        </activity>
        <activity android:name="soInFitMain.ProgramSettings" >
        </activity>
        <activity android:name="soInFitMain.QandA" >
        </activity>
        <activity android:name="soInFitMain.SentProgramsPage" >
        </activity>
        <activity android:name="soInFitMain.MyGymPage" >
        </activity>
        <activity android:name="soInFitMain.UsersInClass" >
        </activity>
        <activity android:name="soInFitMain.GymMessages" >
        </activity>
        <activity android:name="soInFitMain.PrivateTrains" >
        </activity>
        <activity android:name="soInFitMain.TrainerClasses" >
        </activity>
        <activity android:name="soInFitMain.TrainersInMyGym" >
        </activity>
        <activity android:name="soInFitMain.ChallengesPage" >
        </activity>


        <receiver
            android:name="serverAndServices.ChallengesActionReceiver"
            android:enabled="true" >

             <intent-filter>
            <action android:name="com.soinfit.utilities.CHALLENGE_CLICK" />     
               </intent-filter>

        </receiver>

        <receiver
            android:name="serverAndServices.GcmBroadcastReceiver"
            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.GCM_RECEIVED_ACTION" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="com.soinfit" />
            </intent-filter>
        </receiver>

        <service android:name="serverAndServices.GcmIntentService" />
        <service android:name="serverAndServices.OnTheWayCounterService" />
        <service android:name="serverAndServices.ProgramTimeCounterService" />
        <service android:name="serverAndServices.SetRestTimeCounterService" />

        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/app_id" />

        <activity android:name="com.facebook.LoginActivity" />

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

        <activity
            android:name="org.acra.CrashReportDialog"
            android:excludeFromRecents="true"
            android:finishOnTaskLaunch="true"
            android:launchMode="singleInstance"
            android:theme="@android:style/Theme.Dialog" />

    </application>

</manifest> 

我的项目包

enter image description here

1 个答案:

答案 0 :(得分:1)

自定义应用程序中的包是serverAndServices。使您的类serverAndServices.ErrorReport。 Android正在寻找com.soinfit.serverAndServices.ErrorReport。您在清单中声明的​​名称是什么。两者应该匹配。