2014-03-26 56 views
0

上找到類,模擬器告訴我,它不幸已停止。我以前有過同樣的錯誤,然後我修復了它,但添加了飛濺活動後,我又遇到了這個問題。引起:java.lang.ClassNotFoundException:在啓動我的應用程序後沒有在路徑

03-24 15:14:21.180: E/AndroidRuntime(857): FATAL EXCEPTION: main 
03-24 15:14:21.180: E/AndroidRuntime(857): Process: com.gosha.bux, PID: 857 
03-24 15:14:21.180: E/AndroidRuntime(857): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.gosha.bux/com.gosha.bux.perv}: java.lang.ClassNotFoundException: Didn't find class "com.gosha.bux.perv" on path: DexPathList[[zip file "/data/app/com.gosha.bux-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.gosha.bux-2, /system/lib]] 
03-24 15:14:21.180: E/AndroidRuntime(857): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121) 
03-24 15:14:21.180: E/AndroidRuntime(857): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
03-24 15:14:21.180: E/AndroidRuntime(857): at android.app.ActivityThread.access$800(ActivityThread.java:135) 
03-24 15:14:21.180: E/AndroidRuntime(857): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
03-24 15:14:21.180: E/AndroidRuntime(857): at android.os.Handler.dispatchMessage(Handler.java:102) 
03-24 15:14:21.180: E/AndroidRuntime(857): at android.os.Looper.loop(Looper.java:136) 
03-24 15:14:21.180: E/AndroidRuntime(857): at android.app.ActivityThread.main(ActivityThread.java:5017) 
03-24 15:14:21.180: E/AndroidRuntime(857): at java.lang.reflect.Method.invokeNative(Native Method) 
03-24 15:14:21.180: E/AndroidRuntime(857): at java.lang.reflect.Method.invoke(Method.java:515) 
03-24 15:14:21.180: E/AndroidRuntime(857): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
03-24 15:14:21.180: E/AndroidRuntime(857): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
03-24 15:14:21.180: E/AndroidRuntime(857): at dalvik.system.NativeStart.main(Native Method) 
03-24 15:14:21.180: E/AndroidRuntime(857): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.gosha.bux.perv" on path: DexPathList[[zip file "/data/app/com.gosha.bux-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.gosha.bux-2, /system/lib]] 
03-24 15:14:21.180: E/AndroidRuntime(857): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 
03-24 15:14:21.180: E/AndroidRuntime(857): at java.lang.ClassLoader.loadClass(ClassLoader.java:497) 
03-24 15:14:21.180: E/AndroidRuntime(857): at java.lang.ClassLoader.loadClass(ClassLoader.java:457) 
03-24 15:14:21.180: E/AndroidRuntime(857): at android.app.Instrumentation.newActivity(Instrumentation.java:1061) 
03-24 15:14:21.180: E/AndroidRuntime(857): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112) 
03-24 15:14:21.180: E/AndroidRuntime(857): ... 11 more 
03-24 15:14:43.061: I/Process(857): Sending signal. PID: 857 SIG: 9 

清單

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

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

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" 
    android:debuggable="true" 
    > 
    <activity 
     android:name="com.gosha.bux.perv" 
     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="com.gosha.bux.MainActivity" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="com.gosha.bux.MAINACTIVITY" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
</application> 

飛濺活動

public class perv extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     setContentView(com.gosha.bux.R.layout.pervy); 
     Thread timer = new Thread(){ 
      public void run(){ 
       try{ 
        sleep(5000); 
       } 
      catch (InterruptedException e){ 
       e.printStackTrace(); 
      } 
       finally { 
        Intent openMainActivity = new Intent("com.gosha.bux.MAINACTIVITY"); 
        startActivity(openMainActivity); 
       } 
      } 

     }; 
    } 

    } 
+0

你正在做的包名的錯誤或manifest.xml的 – Android

+0

賺不到目標的活動進入extends MultiDexApplication

添加此清潔你的應用程序/項目 –

+0

你有答案嗎?因爲現在我也面臨同樣的問題... –

回答

1

只要做到這一點

Intent i = new Intent(getapplicationcontext(), 
          TARGET_Activity.class); 
        startActivity(i); 

和清單

<activity 
      android:name="com.your.packagename.TARGET_Activity" 

      android:screenOrientation="portrait" > 
     </activity> 
0
Intent openMainActivity = new Intent("com.gosha.bux.MAINACTIVITY"); 
       startActivity(openMainActivity); 

是錯誤的,而是使用:

Intent openMainActivity = new Intent(this, YourMainActivity.class); 
0

在你寫這個公共類PERV:

的setContentView(com.gosha.bux.R .layout.pervy);

你寫pervy,而不是PERV,這將有可能導致此錯誤

-1

在你要看編譯:

'com.android.support:multidex:1.0.0' 

,並設置multiDexEnabled true

YourApplication:在AndroidManifest聲明

@Override 
    protected void attachBaseContext(Context base) { 
     super.attachBaseContext(base); 
     MultiDex.install(this); 
    } 

最後:android:name=".MyApplication"

+0

請先看看[如何回答](https://stackoverflow.com/help/how-to-answer) 這個問題之前得到了回答,顯然,你可以在這裏添加你的答案。但是在回答之前你需要了解一些觀點。首先,不要添加之前添加了相同代碼或建議的答案。其次,如果用戶非常具體地詢問了問題以及他需要解決什麼問題,請不要添加過於複雜的答案。第三,如果您想就回答或問題提出任何建議,您可以添加評論。 –

+0

這不提供問題的答案。一旦你有足夠的[聲譽](https://stackoverflow.com/help/whats-reputation),你將可以[對任何帖子發表評論](https://stackoverflow.com/help/privileges/comment);相反,[提供不需要提問者澄清的答案](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-c​​an- I-DO-代替)。 - [來自評論](/ review/low-quality-posts/16767502) – fantaghirocco

相關問題