No known package error. Android 5.0 - java

I've been developing using the Android L preview. Today I've spent all day trying to set up eclipse so that I can develop using the new APIs. I've run into so many problems, and have hashed most out by just making a new workspace.
A persisting problem is the one shown below. These resources are in the R.java file and are in the resource folder. I haven't moved anything or changed anything about the project other that the target build sdk. The error is occurring any time I try to access a resource using the format R.XXX.XXXX. What could the reason be? Any ideas?

EDIT: NEW ANSWER
Something was just bugging out. Not sure what, but after re-downloading the bundle, downloading API 21, restarting laptop etc etc my same project is running just fine. Hopefully this isn't temporary.
Bundle: https://developer.android.com/sdk/index.html?hl=i
PREVIOUS ANSWER: Some of my resources had digits in the filename.
This doesn't seem to be documented. I found this by first trying to start from scratch, building up my app in a new project. This worked until I had to make a big jump, adding lots of activities at the same time due to dependencies, and this caused the same error to occur. I then starting bit by bit stripping down my app. Found that upon deleting those resources, the errors subsided.
I thought that a-z and 0-9 were allowed. Files with these characters worked just fine in previous Android versions, but it seems that updates made when switching to Android 5.0 makes 0-9 invalid.
Can anyone else confirm this?

Related

Android Studio does not reflect my xml changes

When I do any changes in xml layout file, it doesn't reflect with new compilation build although R.java is generated but when I run the application changes doesn't reflect. I need to rebuild the whole project which is taking time. Any help on this?
I guess before it was working fine.
Yes Sometimes it also happens to me. If you are doing changes i right way in the Xml file then those must be appear when you run your app. But if it does not happen, then you need to rebult your application, or clean it several time. if it also does not work to you then do the follwoing :
Close and re-open (Restart) the android studio and try running app again.
If step 1 is also not helpful then Uninstall app from your device , Disconnect and connect device again and rebuilt/Run app directly in your device again.
I hope this will work for you.
Pleas check if you have enabled Power save mode (File -> Power Save Mode) which turn off auto compilation
Android Studio - Auto complete and other features not working
I "touch" AndroidManifest.xml and that forces a build. Does not take nearly as long as rebuilding project or restarting emulator. It's a hack, but hey, it's my hack.
This sounds similar to my situation. I had an extra quote character in my colors.xml file, which caused errors when I tried to run my app. What worked for me was to remove the extra quote in my colors.xml file. Then I saved the file. Then I restarted Android Studio.
You can simply switch to project view and remove the build of the app:
After a few days of fighting this issue, I solved it by deleting all "v26" directories inside the "res" directory, since the activity was using it instead of the usual "layout" directory for accessing the xml.
app/src/main/res/layout-v26/
had to be deleted and you should remain only with
app/src/main/res/layout/
Anyway, I am new to android development and am not sure if this can lead to other issues, so be careful.

Basic Android Project: alternating cannot be resolved or is not a field/R cannot be resolved into a variable errors

I am new to Android Development/Java Programming/Eclipse so please bear with me. I've been going through the Android Developer Training (developer.android.com/training) and the Hello Android book by Ed Burnette and keep running into a problem that is making it difficult to move forward. I'll do my best to describe it and am hoping that the community can help me resolve it.
I began seeing this issue with the Android Developer Training (around Adding the Action Bar -> Adding Action Buttons) and it became impossible to circumvent at Hello Android's 3.3 Creating Opening Screen when I tried adding the Sudoku buttons. The only change I made when going through Hello Android was adding the Android Development Toolkit (ADT) for Eclipse. I don't recall this being a required download going through the Android Developer Training page so I am wondering if its addition could have contributed to the problem.
The issue that I keep running into is that when I go to build the project, Eclipse keeps telling me:
action_settings cannot be resolved or is not a field
activity_sudoku cannot be resolved or is not a field
container cannot be resolved or is not a field
fragment_sudoku cannot be resolved or is not a field
sudoku cannot be resolved or is not a field
I've tried several fixes that I saw on in the forum including deleting the import.android.R from the sudoku.java file in my src folder but that brings up a bunch of errors that say R cannot be resolved into a variable. I've tried cleaning and rebuilding and restarting Eclipse, methods that occasionally worked before Hello Android and the plugin, but keep getting the same errors. I've also tried setting to Android 3.0 and higher thinking that might be an issue but there was no change. Occasionally I get another error regarding not being able to find the path for a container but I've been playing around with the IDE for 15 minutes and can't seem to get it to pop up again.
I could really use some help on this.
Hope to hear from you,
Yusif Nurizade
This solution may, first and foremost, demonastrate how green I am with Android programming but I believe I found the solution.
Initially following the Android Developer Tutorial, I downloaded the latest versions - 18, 19, 20, etc. When I was creating the project, however, I was specifying much early versions for compatibility; all the way down to 7 or 8. I looked into this because I remembered seeing a message from the IDE regarding the Action Bar and how some commands weren't supported on Version X.
I went back and downloaded all the versions down to 7 or 8 and set the compatibility accordingly. The example now works with minimal other changes. I realize that I may be overlooking something but this is the only major change I made and it seems to have done the trick.
Hopefully this will help other newbies!
Yusif Nurizade

R.java file isn't being generated if I add the Facebook SDK to my app (that uses Parse)

I am working on an android project and wanted to integrate FB into it.
Using the FB SDK tutorial, I imported the FB SDK into my workspace along with a sample project. The sample project seems to have no problem with the FB library. But when I try to go to stick the library into my app, my app refuses to generate R.java. If I remove it, the R.java gets generated again.
I did a lot of googling and tried the common tricks like cleaning my project, checking for XML errors, etc.
I am now thinking it might be a problem with having both Facebook and Parse. Parse used to have Facebook SDK integrated, but they changed that recently and they now want you to import the Facebook SDK. I tried both not updating and updating Parse, but either way still not generating R.java.
I have set it so my min SDK is level 8 and the max is level 17. I tried raising and lowering the max, but it made no difference.
I have been working on this for the whole day but cannot figure out what is going on. Anyone having similar issues or have insight into the problem, I would very much appreciate feedback.
Edit: I do get this on the console: WARNING: unable to write jarlist cache file /Users/.../facebook-android-sdk-3.6.0/facebook/bin/jarlist.cache
Edit 2: I think I figured out the reason: http://www.reddit.com/r/androiddev/comments/1xajcp/too_many_methods_for_dalvik_help/

replace android studio project and keep signature

I've been working on this project for months, and when I started out I knew nothing about android dev, gradle or signatures. Since Android studio was also quite new when I started in June, and updates often brought errors in the gradle, the code is a bit messy.
Now, I've been trying to get the new support library imported into my project - without success. Re-importing the project seems to fix this nice and easy, but this means I have to replace the old project(package anomaly). My question is, since this app is already deployed, will I loose the old signature and with it the possibility to update the app on Google Play store?
Hope to hear from ye! Thanks.
[EDIT]
Yep, worked like a charm :) Thank you Samuel!
If I am answering the question I think you are asking, can you change the package name and still upload the application as "updates" to one that is already in the market the answer is no.
Once an application is uploaded to the market, pretty much everything can change except the key and the package.
As long as you still use the same signature and key then you should be able to compile with different things and still upgrade successfully. I highly suggest compiling what you have now and trying to upgrade it in the app market and that will very quickly determine whether or not it is possible. If you do this post back on this post if it worked or not for everyone else to see

Class not found exception after adding a new image to the resource folder

The app works perfectly fine on the simulator and on the device. After adding a new set of images, it started to show on every run, on the simulator and on the device, a class not found exception.
When trying to delete some images to find the cause, I get different classes not found when running. Compiling and packaging the application generates no warning or error. They even get signed. Some of the "classes not found exception" I get:
java.lang.stringbuilder
net.rim.device.api.ui.uiapplication
I am guessing it has something to do with the total image size. The size of each image ranges from 100KB to 300KB, and we are talking of only 25 to 30 images in total. Adding the image outside of the 'res' folder doesn't generate the error, but the image isn't added to the final files. Deleting the images, the ones just added resolved the issue, but I need those images...
Also, this application is not big, but when compiling, and packaging the app, it generates and signes 125 cod files. Is that normal?
I am using Eclipse 3.6(Helios), and BlackBerry Eclipse Plugin SDK 5.0.0.25 on Win 7
Any help will be appreciated. Thanks.
Each .cod file is limited to about 64K. If your 25-30 images average about 200K, the 125 cod files doesn't surprise me.
The error messages sound like rapc is getting very confused. After you add your images, try refreshing the project or even exiting and restarting Eclipse, then clean and build the project from scratch.
Including large amounts of media is generally not a good app design for the BB. There's a good discussion here about alternative ways to handle this.
It turns out this issue was caused because of the total size of my images, which in turn created more then 127 .cod files. Total number of siblings .cod files is 127, my app had that limit, and this is why some essential classes were not included. I still think the blackberry plugin should warn about this, because it showed no error when compiling, packaging and signing the application. Here is the link from the BlackBerry developer support forums where I got this information:
http://supportforums.blackberry.com/t5/Testing-and-Deployment/The-maximum-size-of-a-BlackBerry-smartphone-application/ta-p/502534
Since I am used to the iOS world, where I can add whatever I want to the app, and it has virtually no limit on the resources I can add, except to consider that the user would have to wait a good amount of time downloading the app, and the 2GB application size, which, really is a lot for 99% of the apps.
So for this app what I did was I added only the essential images as compiled resources in the app, and the rest of the images are downloaded automatically when the application launches the first time.

Categories