Exception when I run my application from Eclipse

主宰稳场 提交于 2019-11-29 22:06:13

Try adding one more thing in Manifest file, I am sure you have already tried..

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="[my package]" 
    android:versionCode="1" 
    android:versionName="1.0"
    android:sharedUserId="com.mj.app" > 

It seems like in your project you have multiple PACKAGES, like com.package.p1 , com.package.p2 ,com.package.p3..

And while starting you are in p1 and then moves on to p2 - p3... and at that time you try to run it again..so the Android gives you error.

If you put 13 in your minSdkVersion, it should work.

Either that, or you need to setDisplayHomeAsUpEnabled(false) in the onCreate() of your other activities.

Both those solutions should work.

Starting at API Level 14 according to the documentation, the setHomeButtonEnabled(true) is no longer done for you by default, and it goes on to say that

Setting the DISPLAY_HOME_AS_UP display option will automatically enable the home button.

So we can infer that setDisplayHomeAsUpEnabled(false) works in a similar way as setHomeButtonEnabled(false)

Siddharth

If I am not mistaken, this only happens when we reinstall the app from Eclipse Run->As. So this is unlikely to happen when a user upgrades through Play. I can say this with confidence since I did notice my app too with this exception during reinstall through Eclipse, but nothing on Crittercism.

To fix this, I worked on resolving memory consumption of my app.

  1. If you only have 1 set of drawables, then change that. Create a drawables-mdpi and copy all the file from that 1 drawables folder (drawables, drawable-ldpi). If you have just 1 set, Android will resize it for its use on bigger screens, thus internally taking up too much memory, and cleanup of this kind of memory (bitmap) is bug prone. Sound crazy, but does wonders. Dont believe me, run it under Heap memory usage watch before and after this change, you will notice that your app is taking 25% less memory for a common scenario.
  2. If you are doing any Bitmap operations, you may want to consider downscaling. Atleast when you are setting options you definitely want to downscale it. Check here and here. Search or downscaleing.
  3. Finally dont forget to bitmap.recycle(); bitmap = null; in your onDestroy and before all System.exit(0).

Android does a lot of background work, and reinstallation is a abrupt cleanup expectation from the app. Memory not cleaned up can cause issues. This exception is one of those internal ones. So dont think of it to be straightforward.

You haven't added the period to the names of your activities in manifest's android:name attributes. Perhaps, this causes the problem.

Wait after your application crashes when u run it second time. The app will launch after the crashing again. This happens sometimes with me. If the same is the case with u dont forget to clean your project everytime before u run it.

By inspecting your code I feel you are skipping to set "setContentView(rid)" in LoadDiagramActivity. Please try setting the view in onCreate().

Hope this will help you.

You need to append "." before the activity name in Menifest.

Like this

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk android:minSdkVersion="14" />

<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" >
    <activity 
        android:name=".HomeActivity" 
        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=".LoadDiagramActivity" android:label="Load Diagram"></activity>
    <activity android:name=".BaseDiagramActivity" android:label="Base Diagram"></activity>
</application>

I update your menifest's activity. Please check it...

There is nothing wrong with the code you've given us so far. I just tried it in a new project with the package name com.test and it worked flawlessly. The only thing I added in the files were the package declaration. (And I added the load_diagram_menu.xml, of course.)

If possible, it would be great if you could give us access to the complete project. If the project is working on someone else's computer, it's most likely Eclipse or the Android Eclipse plugin-in that are misbehaving. A clean install of Eclipse would solve that. (Though I understand how being offline could make this difficult. :-) )

For this, be sure to have the "Build Automatically" checked when cleaning the project. (Project -> Build Automatically)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!