Android APK does not contain MainActivity class - android

I have the exact same issue as the following: dex file does not contain MainActivity class
Since I cant ask for extra help on that thread I have to recreate one.
My comment:
"I still have the same issue. Its an copy older Cordova project (which I recently updated for one client, without any issues). I renamed the project; changed up some resource files, and now I keep getting the same issue as the initial thread creator. I tried all the suggestions, None seem to work for me. Any clues on what is happening, would I need to change around more then just the name and bundle id's. The main activity is linked to the correct name, but when the APK is build and I go open the apk in android studio, it does not show me the folder for the app 'name' where the mainactivity should be.
I do not have the 'gen' folder. So I cannot remove that, unless these are special folders you can only see at some point?"
Im getting fairly frustrated, I checked all the project files for the build that is not working and a working build [2]. I tried to reproduce the issue with the old build, but that one just seems to work. If I make an exact copy of that build, change up the bundle id's [1]. It just doesnt work.
[1][2]: https://imgur.com/a/WnyJTVD
EDIT: The fix that worked for me was: Changing the bundle ID; I assume that the name contained something ilegal? The thing I changed in the bundle id was: 'com.companyname.cvs' The thing that broke it was the 'cvs'. As soon as I renamed it, and reproduced the steps I did before, it fixed it.

Related

Generate Annotation files Automatically in Eclipse

I am using Annotations and svn(Version control) in my application. I have created one package inside of my application and some Activities inside of it. Now the application is perfectly running. I just committed the files to svn and tried to checkout files from another one pc. Now my projects contain some errors. The errors happen whenever I use intent for calling new Activity that shows an error. The error says "Summary_ cannot be resolved to a type"(Here I mention summary is my Activity name).
And I just add a space in that java file and save the error is gone. But I can not ask other peoples to do this every time. Because this also happen whenever the eclipse is restarted or when I clean my project . Checkout from svn. Update svn.
I guess the annotation files are not generated. Please anyone help me to solve this issue.
Note : I just added a space(or whatever) in that java file and saved. the error is gone . I want to know why it is happening?

Android accessing wrong resource ... How do I solve this?

Last night my code was working fine, today when I load it up, the raw resource I access in my code is trying to read from an id pointing to a string rather than an xml file in my raw folder.
I have used http://www.statman.info/conversions/hexadecimal.html to track the resource id's and match them to their R hex id's and I can SEE that it should be accessing 0x7f040002 but is accessing 7f060000 for some reason...
I have already looked at :
Accessing wrong raw resource in Android
I have done all of the following:
Clean, Rebuild, Run.
Delete R, Reboot Eclipse, Clean, Rebuild, Run
Delete R, Clean and Rebuild Immediately, Reboot
UmbySlipKnot's idea of deleting Gen Folder + all of the above.
Making sure Android.R is not being used anywhere.
Printed the actual resource id I am expecting to use by calling (returns expected id correctly!):
int resId=con.getResources().getIdentifier("raw_tsn_xml_amina_simple","raw",con.getPackageName());
Also rebuilt the project entirely from scratch. No matter what I do - it's always getting app name as the resource id it references for the Input Stream - source
None of these have worked for me... Does anyone have any ideas what else I can try?
I have also added images to show you what I noticed:
Debug Snippet:
Android R File Snippet:
I had this issue the other day with the wrong image resource ID being used. The only thing that worked for me was renaming the resource and renaming the references to said resource. So try renaming raw_tsn_xml_amina_simple.xml to something else.
Try removing Gen folder and let it regenerate. Then try again.
Apparently the eclipse debugger is not as dependable as I expected.
While I was working with the debugger, I noticed that resource ID is correctly being found, but when I really nitpick into the debugger, the inputStream seemed to be getting built from another source.
I thought that was the reason my code was crashing, but it wasn't.
I use a SIMPLE xml android library - if the xml you pass it is in an unexpected/invalid format, it can't build the data models you create (My XML was invalid - therefore the crash).
I did a roll back to notice that new XML I had added, crashed the run.
The debugger just cranked out... giving me nulls when things weren't null, showing different values even when my logs were printing correct values!
Once I saw this hapenning, I didn't trust the debugger as much as I ususally do.
My advice :
If the simpler solutions on this page have not worked for you - Take the following steps:
Suspect code additions first! If something you added suddenly breaks your working code, it's probably your own error.
If your debugger acts weird, print useful log information (It is much faster) to give you the right information in the right places.
These are the exact steps I took to find the root of the problem.

new Intent loading wrong xml files

I noticed today in one of my apps that when I loaded a new Intent for a certain few classes(these classes are determined from the click of an object on a Spinner), the layouts appear and they are like the original plain layouts I started with in my project, not the ones I updated and changed to make look better.
I checked all my code and everything, there are no xml files for what it's loading(they are old ones that I had used before). I don't understand why these old, non existing xml files are even loading. It should be loading the current ones I have in my project but it doesn't... Can someone help me with this problem? Thanks
If you're using eclipse, you can try doing Project > Clean, and then Refresh your project. This should make sure you are building with the latest resources.

R.java file not updating with UI element's id

I added some UI elements to the main.xml file in the res\layout folder and when I try to access them through the call, R.layout.my_uielement, the UI element that I created is not there. Even when I add a new xml file with UI elements, it still doesn't show up in the R.layout class. I have made checked the ids on them and they have the correct format (I think): android:id="#+id/my_button". What could be the problem? Do I need to compile the code first?
UPDATE:
I have already tried adb kill-server then adb start-server. It doesn't seem to help. I have also tried R.id.my_uielement, it doesn't register either.
This may not be the case for you, but sometimes when I use something from the android.R package (default android resources) and I use it in my class before making reference to anything from my own resource package, Eclipse adds the import android.R; statement in my imports. This will conflict with the default behavior of implicitly looking in your package's resources.
Check your import statements for import Android.R;. If it's there, remove it. And, if you're using anything from android.R, fully qualify it when you use it in code.
Clean project works fine. In Eclipse if you just change some xml components, it doesn't always generate a new R file. Cleaning does it.
Use R.id.your_ui_element, not R.layout.your_element
I faced this problem too. The R.java was neither generated nor updated.
If R.java is not generated when you create the project, run your 'empty` project. An R.java with references to resources will be automatically generated.
If R.java is not getting updated, Check for updates in Help -> Check for Updates
in Eclipse and update your SDK and ADT if required.
After 2 days I found a way to fix it...
I had saved half done project in my mail, so when R.java vanished i just replaced it with the old R.java file, this fixed a lot of errors, then made necessary changes and built the project(build it not clean)...I do not know whether clean and build performs the same job or not..but everytime i cleaned it , R.java used to go invisible...
Clean is working because it BUILD the project after cleaning. So the problem is ( at least it was in my case, because I switched off the Automatic Build a few days earlier ) that after you add an item or anything in a .xml file, the eclipse doesn't build it and can't refresh the R.java .
I've noticed that my R.java file is not always being properly updated when I add items to my strings.xml file or elsewhere. If I use a new value I added like R.string.newString the actual integer value might still be pointing to R.string.oldString or whatever (it seems to usually be the element directly above or below the new element in strings.xml but I haven't nailed down the pattern for sure yet).
You're not supposed to modify the R.java file, but it doesn't say anything about deleting it (not that I've seen, anyway). I've found that deleting R.java usually fixes my resource-related problems because Eclipse immediately regenerates the file with the integer values properly assigned.
Please note, I'm very much a beginner at Eclipse so I may not understand the consequences of deleting R.java but it seems to be working well for me so far. If what I'm doing is very bad, please let me know.
None of these worked for me!
The only way i can access an #+id/foo is by myPackage.R.id.foo.

Refresh list of drawables in Eclipse?

When I add drawable resources to my project they do not show up in the list of drawables in the Reference Chooser. I checked the R file and there are references for the files.
I have tried refreshing the project, cleaning the project, and fixing project properties and nothing seems to help. Sometimes a couple will randomly show up in there, but not all of them.
The only consistent way I can get them to show up is to restart Eclipse.
Any ideas?
Thanks
Edit: Further findings:
After some trials, I found an other inconvenient work around to he issue. Turns out when importing multiple files into the project at once, Eclipse will only add the last one imported into the reference chooser. So when I imported my images one at a time, they all show up properly!
Like I said, inconvenient considering the amount of images I have left to import, but maybe with this new information it may help nail down where the issue may be and a possible fix.
I too faced the same problem. I added an image to the res/drawable-hdpi folder, cleaned the project and was able to see the name of the image in the left pane in Eclipse. But when I tried to use this image using Reference Chooser and looked under Drawable, I didn't find it.
I simply exited from Eclipse, and started it again. It was there! Like many things in computers, problems can be resolved simply by restarting!
The only way I found to fix this is to include the generated R class itself.
I found out some new info again.
Since I am doing a port from Blackberry, almost all of my images' filenames have uppercase letters in them, so I end up importing them all and then having to rename all the images after they are imported into the project.
I tried renaming all of my images before importing them all into the project. To my delight, all of the images showed up right away in the reference chooser! So it seems there is a problem when you import files and they cause errors with your project and allowing all of them to show up in the reference chooser.
So if you have to rename files, do it before import!
I'm just not entirely sure that this is the only cause for this issue but it has solved the problem for me.

Categories

Resources