Eclipse SDK android : The declared package does not match the expected package - android

I've read through similar errors however I'm confused as to how to avoid this error when working with the ADT plugin for eclipse.
I'm attempting to follow this tutorial on how to create a Grid view of images:
http://developer.android.com/guide/topics/ui/layout/gridview.html
Step five simply states open Open HelloGridView.java, however I'm not sure if I should just create a new class, or activity.
"Step five:
Create a new class called ImageAdapter that extends BaseAdapter:
I've tried both creating a new class and creating a new activity. When i created an activity I made com.example.HelloGridView the hierarchy. But I don't think this is right and I don't think these should be activities. and I receive this error:
The declared package "" does not match the expected package "com.example.hellogridview"
in the HelloGridView.java and ImageAdapter.java
What I really want to know is how should I create a new class like in step four and step 5?
(also I'm very new to android I've gone through the android training "get started" but still feel slightly clueless, Where should I go from here?)
Any help would be greatly appreciated!!

Your new class HelloGridView need to must be under your application package com.example.hellogridview.

I get this error when my code path does not match the package name.
For example, if your package name is com.whatever.myapplication, then the class should be under /yourworkspacedirectory/com/whatever/myapplication folder.

Related

Unable to instantiate fragment error after renaming android package

enter image description hereI renamed my android package from com.example.remote to com.mqtttools.com and my app did not work after that so I tried changing it back but is still does not work. I was following a stackowerflow answer that worked for many people.
I'm getting this "Unable to instantiate fragment mqtttools.remote.FirstFragment: make sure class name exists" error but the thing is that my package name is com.example.com and not mqtttools.remote.
Have you defined the fragment in XML?
If yes then please check the Fully classified class name in XML.
You need to update the package in the XML to resolve this error.
I was able to figure out the cause of the problem but not the solution. Something bad happened while renaming the package name across the myriad of files and it became corrupted. The only way that I was able to fix it is by creating a whole new project and copy/pasting all of the code.
Hope it saves the time for some of you who encounter the same problem.

Unity ScriptableObject is missing on mobile build

I have a MonoBehaviour class that has a property referencing another class which is ScriptableObject.
I've created several prefabs of my first class and created several ScriptableObjects of my second class, I've referenced them in the first class respectively.
In the editor everything works fine, except sometimes my so are shown in the Inspector as Missing Script and in property reference as NameOfSO (), don't know what causing this, but again, Play in the Editor is working just fine.
If build my game for Android and connect to the Debug, to see what's going on, I can clearly see, that's ScriptableObject reference is null. Why? Don't know, came here to ask a question.
Thanks!
I figured it out, turns out this was happening because of the weird thing with namings.
Allow me to explain, when I first created a class from ScriptableObject I used, lets say, MyClas name, I've created several instances of that class, but then I saw the error in the name of the class, I've changed it to the MyClass but only in the file itself, not the actual .cs file, so, this was happening. All I had to do is to ensure that my class and my file names are the same, delete old instances of ScriptableObject and create new ones from scratch and... Voila!
Sorry.

What is the meaning of putting class name inside the brackets?

While observing an existing android application, I encountered this line of code:
((StoredVariables)this.getApplication()).getId
Why we are using this? What is the outcome of the code? Does it returns previously stored values from sharedPreference? No documentation found on internet to get an idea about it. Please explain.
You are probably a little newbie in Java also
I'm not sure about what is "this" in this.getApplication() and what the StoredVariable is, since it is not an android class...
But here are recommendations for you:
Look for StoredVariable in your class in imports section. You can find something like import my.project.StoredVariable;
Open the class (I'm 80% sure it will be interface) to see the class (this is already answer to your question)
See getId() method there
To know more about usage of StoredVariables. If this line of code is placed inside class that extends some Activity (e.g. AppCompatActivity, Activity e.t.c.)
Open AndroidManifest.xml and look into <application> tag to find android:name in there. Open class with that name (ctrl + click or cmd + click on class name)
This class is extending Application class (or subclass) and implementing StoredVariables interface, or it is directly StoredVariable class

Hello world android - creation with errors

I'm trying to create my first app with Android but I've encountered some problems.
Following a tutorial and making:
new android application -> blank activity
The default result should be:
With MainActivity.java and R.Java inside it.
But instead I've got this:
There are a lot of errors and the R.Java file is missing.
I can obtain a result similar to the tutorial one (with no errors), creating a new android application and unchecking create activity, but this time MainActivity.java under src is totally missing.
Maybe I could copy the MainActivity.java of the first project and put into the second one, but I prefer understand why it doesn't work.
Thanks for the help.
Best regards.
its import library problem
Right click on you application----->Android
under library view ,
check if you have this red error then remove the library and add it again

SelectionFragment class missing - Android based Facebook development

I've created a project where I want to have a list of friends returned. I'm following this tutorial and at section 2c I have realized that my build does not contain a SelectionFragment class. Where online could I download this class, or does anyone have the code for this class? Thank you.
maybe here SelectionFragment.java on github
My guess this class needed to be created a little bit earlier in tutorial.
Choose "Step 1b" link in right column of a page.
https://developers.facebook.com/docs/android/scrumptious/authenticate#step1b
It says like:"Create a new fragment class in your package for the authenticated UI. Name this class ''SelectionFragment'' and make its superclass Fragment."

Categories

Resources