Using library project, "Sorry! The application... stopped unexpectedly" - android

I’m having trouble using Eclipse ADT projects as libraries. I have three projects in eclipse: ToolProject, AppProject, DevProject.
The ToolProject contains classes I use in several apps (I actually have AppProject_2, as well, something completely different). In Properties, Android -> IsLibrary is ticked.
The AppProject contains the top-level app code, Activity, manifest, etc. It works – I can run it on my phone (IsLibrary ticked or unticked – both fine). Properties -> Android Library references ToolProject. The BuildPath does not reference ToolProject, in any tab.
The DevProject is so I can download and run the lastest draft on my phone, without clobbering the existing AppProject that’s running there. I have created a new project, different launcher icon, different package. The Activity just subclasses AppProject’s Activity.
I can’t get DevProject to run on my phone. The console shows the normal messages. Logcat shows nothing for the launch. On the phone, I quickly get the “Sorry! The application DevProject (…) has stopped unexpectedly. Please try again.” Nothing – no screen – from the app appears.
AppProject is marked as a library. I’ve tried DevProject with Library-reference to both AppProject and DevProject, and to just AppProject. Neither are in DevProject’s BuildPath tabs.
Can someone tell me where to go and what to do there? I’m sorry for such a vague question, but I don’t know what to tweak. Pointers to the relevant documentation or previous questions would be great.
Disclaimer: I have searched for discussions. I have read Android’s Manifest documentation. But I remain unenlightened.

The app startup, in onCreate, used files from the assets/ folder. I had forgotten to copy these from AppProject to DevProject.
Problem solved.

Related

can't change action menu icon in android app

It's less than I can't change it, (Since I already did), and more and issue that I can't change it BACK.
So I'm using eclipse to learn android app development. In one of the tuts on the android developer website, it says you have to add your own ic_action_search.png file for the action bar to find. (Else it won't compile). So I made my own goofy looking icon. I added it, and it's there. Ok.
So Afterwards, I found the Android Design Icon pack from google. It looks much better and decided to plug that back in. I thought that would be easy. I took the new file, (With the EXACT same names), and plugged them back into the source folder where the others were. It OVERWROTE the other files and I have confirmed that the correct icons are now in there.
When I run the program using USB debugging on my phone though, the OLD icon is still there.
I tried refreshing the folders inside eclipse. I tried uninstalling the app from my phone and then re-installing fresh using USB debugging in eclipse. Still no go.
I'm worried that my device stored those images somewhere in my phone and isn't overriding them on the new install. Really need help with this here.
Any ideas?
Refresh your project F5
Go to
Project > Clean
if that doesn't work delete /gen and /bin folders of your project to recreate all the references of your resources.
probably you are uploading an .apk file with the old resources

Android ActionBarCompat Not working from the start

OK, I have been wanting to try the new ActionBarCompat, however, I am not able to run my programs in the emulator.
I have been trying to implement the following: http://antonioleiva.com/actionbarcompat-how-to-use.
and have been stuck on basically the first part. However, working with the author of that content, I was able to get further as I was not adding the project under sdk\extras\android\support\v7\appcompat folder like stated. However, I still think that might be the reason I cannot do this...
More detail can be found here: http://antonioleiva.com/actionbarcompat-how-to-use/#comment-43
Basically, on my first attempt, I just created an Android project, and changed the source code as indicated. Code would not run on the emulator. So I went back to the original code, and that ran on the emulator.
Checked online, found out I might need to add the \extras\android\support\v7\appcompat folder as a library to the project I am building. So I added that and a new android project was created. There were build errors from the start, but I failed at trying to add it as a library to my project, and deleted it....thinking this was way overboard.
After back and forth chats with author of linked website, I found out I had to do that overboard thing.
So I tried the following link to the T: (I cannot post more than 2 links due to low repuation...I will add this link as a comment below)
However, Eclipse would not allow me to add the appcompat Existing Android Project...but it did allow me to add the appcompat Existing (General) Project. I think this may be some of the problems??
Right now, I cannot run the project at all. Eclipse is showing a red exclamation mark on the project folder, but all the code seems to be fine. So I don't know what to do now...I recreated this project several times over, and this one was the one where I knew what to do...and I am still getting problems
So...
I decided to move to Android Studio...updated the IDE, updated the SDK manager to include the new support library, and other things. Created a new project, added to the build.gradle file as shown in the link provided below in the comment. I ran the ant build, and then built the project...tried to import the right things to allow ActionBarActivity, but I could not get that far.
I can import
"android.support.v7.*"
"android.support.vy.R" // and all folders within
but nothing allows me to add ActionBarActivity, and I don't know why.
FYI, I guess I would prefer a solution to Ecplise, as it seems like I actually got somewhere with it.
The best example to use is from here, and I would follow it closely. I had similiar issues when I first came across this. Problem was I misunderstood what I needed to do
http://developer.android.com/tools/support-library/setup.html#libs-with-res

Android application problems in Eclipse

I'm a .NET developer but I like JAVA so in my free time I play around with that. I don't normally use Eclipse but I installed the ADT eclipse plugin and Andriod SDK and I started learning and I made a new project with a TableLayout and it kinda looks good, and it runs ok on the emulator.
However... there a few things that drive me absolutely catatonic and perhaps I am doing something wrong so please help me out.
Firstly, if I change the main.xml file in whatever way, even by adding what is supposedly a correct parameter, it will start freaking out and will generate an error that just says "error" without specifying what that is, it will then generate a main.out.xml and then report an error that the main.out.xml is empty. It later won't let me delete that and will start generating a main.out.out.xml and so forth, even after I correct that original xml that caused the error.
The only way to get things going is to delete the bin folder, restart Eclipse, delete all the out xml files and then sometimes it will run the application or some other times it will start generating those 'out' files again and the loop goes on.
That way it takes hours to run a simple app even one without errors that used to run before.
Surely that was NOT how they intended it to work, is it??
Also.. there is no "Rebuild" button that will flush all files out automatically, or is it hidden somewhere? I am tired of manually deleting those automatically generated files and the build folder and all those out.xml files.
Also, while I'm at it, I also want to point out that the designer view sometimes disappears and there is nothing on earth that will bring it back, the only way is to create a new project and copy the main.xml to it and then it shows up again. Another bug?
I have the latest eclipse version:
Version: Indigo Service Release 2
Build id: 20120216-1857
If you have any clues how to get this to work, I will appreciate it!
Many thanks in advance
When you click the Run button with an XML file selected, Eclipse is running an XSL Transformation on that XML and producing the .out.xml file as the result. This is a feature of the Eclipse Web Tools feature, which you'll have if you installed the Eclipse for Java EE Developers package (it may be included in other packages, too).
As others have said above in the comments, to run your Android app, select the Project, right-click, and choose Run As > Android App. Once you've done that once, it will create a Launch Configuration that you can launch from the Run or Debug toolbar buttons (pressing the small down-arrow on the Run or Debug buttons brings up a list of Launch Configurations that you can select from, as well as an option to manage them).
There is a Preference that will make Eclipse always launch the last thing you ran or debugged, instead of trying to be smart about what is currently selected. Open the Preferences and navigate to Run/Debug > Launching; there you'll find the option under Launch Operation at the bottom of the window.

Eclipse: How to limit displayed errors/warnings to currently open files?

I'm just getting started with eclipse and android development. One thing which is driving me crazy in eclipse is the problems panel with error/warning messages. It displays errors and warning from every project that I have added to eclipse. I only want to see feedback from the project (or ideally individual file) that I am currently working on).
For example, I have two android projects added to my eclipse workspace: HelloAndroid (a sample app) and SMSTest (an SMS2Toast example). Even with no files open, I see warning messages from both projects! Why is this!?! I shouldn't see any output unless I actually have a file open...or is this just the way eclipse works? Should I be using a different workspace for each project?
Thanks for any help anyone can give me.
This will get mostly what you want:
Open the "Problems" view (Shift-Alt-X-Q)
In the right hand corner there is a drop down arrow
Select "Configure contents"
Then pay attention to the "Scope" options
I also highly recommend in that same menu "Group by" -> Java problem type.
Right-click the unwanted projects and click "Close Project" you shouldn't get notifications from them at that point.
Other than that I'd recommend fixing most errors before moving away from them. If you're not prepared to complete various functions at any given time just put a stub in them that satisfies conditions with a quick //TODO: statement telling you to fix it later.
If you're talking about working on a page in general and the errors are combersome and annoying then try double-clicking on the tab for the file you're coding (above the code window) and it should become "fullscreen" hiding the other portions of eclipse.
As far as I know, this is the way eclipse works. It makes sense in that if you make a change in one file, and it causes a compilation error in another file that you don't have open you would still want to know about it.
You CAN configure which situations are considered WARN, and which are IGNORE in Preferences > Java > Compiler > Errors/Warnings.
Also, if you only want warnings from one project you can CLOSE the other project, which would keep you from having to reconfigure a new workspace for each.

Library based application installs 2 APK files, not one - Why?

I am trying to restructure an existing app so that, except for a few override-able methods in a derived activity, all code will reside in a library. This still doesn't work for some reason, but in the process of attempting to troubleshoot this, I discovered much to my dismay that there are two .apk files installed, not one (when I run a debug session from eclipse):
The first (and larger file) is
having the original library name.
The second (only 20KB in size) is
having the derived application name.
Why is that and where can I learn more about this?
Could that explain the ClassNotFoundException problem I am having?
I found the answer myself. It turns out that I had 2 critical settings in the Properties of both projects not set correctly:
In the library project, "Is Library"
was not checked for some reason. I
could swear that I checked it, but
knowing how whimsical the Android
development environment under
Eclipse can be, I suspect that it
was unchecked by Eclipse (or the ADT
plugin) as a result of some glitch.
In the application project, I
neglected to add my library project
as a reference via the Add...
button. (how dumb could I be?)
Hoping this can be useful for other newbies to come.

Categories

Resources