无法实例活动抛出java

无法实例活动抛出java

本文介绍了无法实例活动抛出java.lang.ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到下面的错误在开发周期中了几次,现在我刚刚收到错误报告。我不知道是什么导致了这一点。阅读关于这个问题在这个网站类似的问题后,我双重检查我的Andr​​oidManifest,一切看起来没什么问题。什么任何想法可能可能会导致这个异常?

 了java.lang.RuntimeException:无法实例活动ComponentInfo {com.jerrellmardis.ridecta / com.jerrellmardis.ridecta.ui.StopTimesActivity}:抛出java.lang.ClassNotFoundException:com.jerrellmardis .ridecta.ui.StopTimesActivity
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
在android.app.ActivityThread.access $ 600(ActivityThread.java:130)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1195)
在android.os.Handler.dispatchMessage(Handler.java:99)
在android.os.Looper.loop(Looper.java:137)
在android.app.ActivityThread.main(ActivityThread.java:4745)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:511)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:786)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
在dalvik.system.NativeStart.main(本机方法)
抛出java.lang.ClassNotFoundException:引起com.jerrellmardis.ridecta.ui.StopTimesActivity
在dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
在java.lang.ClassLoader.loadClass(ClassLoader.java:501)
在java.lang.ClassLoader.loadClass(ClassLoader.java:461)
在android.app.Instrumentation.newActivity(Instrumentation.java:1053)
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
... 11更多

另外要注意的事情是,我使用的是Android的支持-V4-GOOGLEMAPS在LIB的,让我来嵌入片段的图形页面(与ActionBarSherlock LIB一起)。这个例外似乎是一个依赖的问题,我不知道,如果是涉及到我如何使用上面提到的库。

下面的清单文件:

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.jerrellmardis.ridecta
    安卓的installLocation =internalOnly
    安卓版code =11
    机器人:=的versionName1.0.2>
    <用途-SDK
        安卓的minSdkVersion =10
        机器人:targetSdkVersion =16/>
    <使用许可权的android:NAME =android.permission.INTERNET对/>
    <使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>
    <使用许可权的android:NAME =android.permission.READ_PHONE_STATE/>
    <使用许可权的android:NAME =android.permission.ACCESS_FINE_LOCATION/>
    <使用许可权的android:NAME =android.permission.VIBRATE/>
    <使用许可权的android:NAME =android.permission.WAKE_LOCK/>
    <使用许可权的android:NAME =com.android.vending.BILLING/>
    <使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/>
    <使用许可权的android:NAME =android.permission.RECEIVE_BOOT_COMPLETED/>
    <应用
        机器人:名字=。RideCtaApplication
        机器人:allowBackup =真
        机器人:backupAgent =。backup.RideCtaBackupAgentHelper
        机器人:hardwareAccelerated =真
        机器人:图标=@绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:标志=@绘制/标志>
        <使用库机器人:名字=com.google.android.maps/>
        <活动
            机器人:名字=。ui.HomeActivity
            机器人:configChanges =方向| keyboardHidden |屏幕尺寸
            机器人:标签=@字符串/ APP_NAME
            机器人:主题=@风格/ Theme.RideCta.LogoOnly>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.MAIN/>
                <类机器人:名字=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
        <活动
            机器人:名字=。ui.BusDirectionsActivity
            机器人:标签=@字符串/ APP_NAME
            机器人:主题=@风格/ Theme.RideCta/>
        <活动
            机器人:名字=。ui.StopsActivity
            机器人:标签=@字符串/ APP_NAME
            机器人:主题=@风格/ Theme.RideCta/>
        <活动
            机器人:名字=。ui.StopTimesActivity
            机器人:标签=@字符串/ APP_NAME
            机器人:主题=@风格/ Theme.RideCta.Split
            机器人:uiOptions =splitActionBarWhenNarrow/>
        <活动
            机器人:名字=。ui.TrainDirectionsActivity
            机器人:标签=@字符串/ APP_NAME
            机器人:主题=@风格/ Theme.RideCta/>
        <活动
            机器人:名字=。ui.LiveMapActivity
            机器人:标签=@字符串/ APP_NAME
            机器人:主题=@风格/ Theme.RideCta.Transparent/>
        <活动
            机器人:名字=。ui.ServiceAlertsActivity
            机器人:标签=@字符串/ APP_NAME
            机器人:主题=@风格/ Theme.RideCta/>
        <活动
            机器人:名字=。ui.SearchActivity
            机器人:出口=真
            机器人:launchMode =singleTop
            机器人:主题=@风格/ Theme.RideCta>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.SEARCH/>
                <类机器人:名字=android.intent.category.DEFAULT/>
            &所述; /意图滤光器>
            &所述;元数据
                机器人:名字=android.app.searchable
                机器人:资源=@ XML /搜索/>
        < /活性GT;
        <活动
            机器人:名字=。UI preferenceActivity
            机器人:标签=@字符串/ APP_NAME
            @风格/主题preference:机器人主题= />
        <活动
            机器人:ui.Legacy preferenceActivityNAME =
            机器人:标签=@字符串/ APP_NAME
            @风格/主题preference:机器人主题= />
        <活动
            机器人:名字=com.google.ads.AdActivity
            android:configChanges=\"keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize\"/>
        <接收机器人:名字=。receiver.ReminderAlarmReceiver/>
        <接收机器人:名字=。receiver.ReminderBootReceiver>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.BOOT_COMPLETED/>
            &所述; /意图滤光器>
        < /接收器>
        <接收机器人:名字=net.robotmedia.billing.BillingReceiver>
            &所述;意图滤光器>
                <作用机器人:名字=com.android.vending.billing.IN_APP_NOTIFY/>
                <作用机器人:名字=com.android.vending.billing.RESPONSE_ code/>
                <作用机器人:名字=com.android.vending.billing.PURCHASE_STATE_CHANGED/>
            &所述; /意图滤光器>
        < /接收器>
        <服务机器人。service.ReminderServiceNAME = />
        <服务机器人:名字=net.robotmedia.billing.BillingService/>
        &所述;元数据
            机器人:名字=android.app.default_searchable
            机器人:值=。ui.SearchActivity/>
        &所述;元数据
            机器人:名字=com.google.android.backup.api_key
            机器人:值=<免去>/>
        <供应商
            机器人:名字=。provider.SearchProvider
            机器人:当局=com.jerrellmardis.ridecta.provider.SearchProvider/>
    < /用途>
< /清单>


解决方案

它看起来像我已经不使用了android支持-V4-GOOGLEMAPS LIB固定的问题。我改变了我的应用程序使用地图的ImageView的一个片段,然后一个普通的老MapActivity一旦用户点击地图图像。因为这样做,我还没有发现任何RuntimeExceptions。

I've seen the following error a few times during the development cycle and now I just received an error report. I have no idea what's causing this. After reading similar questions on this site regarding this issue, I double checked my AndroidManifest and everything looks fine to me. Any ideas on what could possibly be causing this exception?

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.jerrellmardis.ridecta/com.jerrellmardis.ridecta.ui.StopTimesActivity}: java.lang.ClassNotFoundException: com.jerrellmardis.ridecta.ui.StopTimesActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.jerrellmardis.ridecta.ui.StopTimesActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
... 11 more

Another thing to note is that I'm using the android-support-v4-googlemaps lib found at https://github.com/petedoyle/android-support-v4-googlemaps which allows me to embed a MapView in a Fragment (along with the ActionBarSherlock lib). This exception seems like a dependency issue and I'm not sure if it's related to how I'm using the above mentioned libs.

Here's the manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.jerrellmardis.ridecta"
    android:installLocation="internalOnly"
    android:versionCode="11"
    android:versionName="1.0.2">
    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="16"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="com.android.vending.BILLING"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <application
        android:name=".RideCtaApplication"
        android:allowBackup="true"
        android:backupAgent=".backup.RideCtaBackupAgentHelper"
        android:hardwareAccelerated="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:logo="@drawable/logo">
        <uses-library android:name="com.google.android.maps"/>
        <activity
            android:name=".ui.HomeActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta.LogoOnly">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.BusDirectionsActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta"/>
        <activity
            android:name=".ui.StopsActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta"/>
        <activity
            android:name=".ui.StopTimesActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta.Split"
            android:uiOptions="splitActionBarWhenNarrow"/>
        <activity
            android:name=".ui.TrainDirectionsActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta"/>
        <activity
            android:name=".ui.LiveMapActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta.Transparent"/>
        <activity
            android:name=".ui.ServiceAlertsActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.RideCta"/>
        <activity
            android:name=".ui.SearchActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/Theme.RideCta">
            <intent-filter>
                <action android:name="android.intent.action.SEARCH"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
            <meta-data
                android:name="android.app.searchable"
                android:resource="@xml/searchable"/>
        </activity>
        <activity
            android:name=".ui.PreferenceActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.Preference"/>
        <activity
            android:name=".ui.LegacyPreferenceActivity"
            android:label="@string/app_name"
            android:theme="@style/Theme.Preference"/>
        <activity
            android:name="com.google.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
        <receiver android:name=".receiver.ReminderAlarmReceiver"/>
        <receiver android:name=".receiver.ReminderBootReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
            </intent-filter>
        </receiver>
        <receiver android:name="net.robotmedia.billing.BillingReceiver">
            <intent-filter>
                <action android:name="com.android.vending.billing.IN_APP_NOTIFY"/>
                <action android:name="com.android.vending.billing.RESPONSE_CODE"/>
                <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED"/>
            </intent-filter>
        </receiver>
        <service android:name=".service.ReminderService"/>
        <service android:name="net.robotmedia.billing.BillingService"/>
        <meta-data
            android:name="android.app.default_searchable"
            android:value=".ui.SearchActivity"/>
        <meta-data
            android:name="com.google.android.backup.api_key"
            android:value="<REMOVED>"/>
        <provider
            android:name=".provider.SearchProvider"
            android:authorities="com.jerrellmardis.ridecta.provider.SearchProvider"/>
    </application>
</manifest>
解决方案

It looks like I've fixed the issue by not using the android-support-v4-googlemaps lib. I changed my app to use an ImageView of Map in a Fragment and then a plain old MapActivity once the user clicks on the Map image. Since doing this I haven't noticed any RuntimeExceptions.

这篇关于无法实例活动抛出java.lang.ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 07:07