无法仅在Google Play上实例化活动ComponentInfo

时间:2013-04-22 03:24:06

标签: android exception google-play

我已经构建了一个使用android maps API V2的Android应用程序,它可以和我一起使用。

当我将应用程序提交到Google Play时,我遇到了很多例外情况,人们说应用程序无效。

系统无法找到MainActivity。

StackTrace是

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mostafa.cairometrobeta/com.mostafa.cairometrobeta.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.mostafa.cairometrobeta.MainActivity" on path: /system/framework/com.google.android.maps.jar:/data/app/com.mostafa.cairometrobeta-1.apk
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mostafa.cairometrobeta.MainActivity" on path: /system/framework/com.google.android.maps.jar:/data/app/com.mostafa.cairometrobeta-1.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
... 11 more

和清单文件

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mostafa.cairometrobeta"
    android:versionCode="7"
    android:versionName="1.0.2"
     android:installLocation="auto">

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

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>
    <permission android:name="com.mostafa.cairometrobeta.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
    <uses-permission android:name="com.mostafa.cairometrobeta.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
                <uses-library android:name="com.google.android.maps" />
        <activity
            android:name="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>
        <activity android:name="GuideActivity"></activity>
        <activity android:name="GalleryActivity"></activity>
        <activity android:name="NearbyActivity"></activity>
        <activity android:name="SettingsActivity"></activity>
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="MapKey" />
    </application>

有什么问题?!

1 个答案:

答案 0 :(得分:2)

试试这个:在您的所有活动之前输入您的包名称,如下所示

<activity
            android:name="com.mostafa.cairometrobeta.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>

注意:如果你的应用程序中有不同的包,那么......

像我有两个包 com.test.examplecom.test_new.example


com.test.example中的

有活动名称= Mainactiivty

然后在清单中:android:name="com.test.example.MainActivity"


com.test_new.example中的

有活动名称= New_Mainactiivty

然后在清单中:android:name="com.test_new.example.New_Mainactiivty"