Android Facebook sdk Session.OpenRequest(myFragment) is undefined? - java

For some reason I cannot see the line of code:
session = new Session.OpenRequest(this).setCallBack(statusCallBack)
It gives me an error that Session.OpenRequest(myFragment) is undefined. Does anyone know why this is and how I can fix it?

Found out what i was doing wrong. It has to be a fragment from the support library. I was extending the regular fragment class.

Apparently, Session.OpenRequest(Fragment fragment) constructor should work. Assuming that you have added Facebook SDK properly in your project, organize the imports in your class to import the Session.OpenRequest class. This constructor seems to be invisible for your code.
If you are using Eclipse IDE organize imports by pressing Ctrl+Shift+O.

Related

Android Studio not recognizing Class "ILineDataSet" from MPAndroid Chart library

I am trying to create a line graph. I found a tutorial from the following site which I have been following:
https://github.com/PhilJay/MPAndroidChart/wiki/Setting-Data
The problem I am having is with this line of code:
List<ILineDataSet> dataSets = new ArrayList<>();
Android studio does not seem to recognize the type "ILineDataSet" and as a result is preventing me from proceeding any further in completing this task.
It has offered solutions to resolve it, which are:
Create Class
Create Enum
Create Inner Class
Create Interface
All of which I do not think will solve the issue as I assume the library has already configured this but for some reason its not being picked up by android studio.
Could someone direct me as to how I can resolve this issue?
Thanks!
I'm so stupid.
Library wasnt updated.
Please ignore this
I was going to ask if you added:
dependencies {
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
}
To your gradle.build

MBTilesRasterDataSource not found from nutiteq SDK?

Recently i just followed the examples of Nutiteq SDK from here.
But unfortunately the MBTilesRasterDataSource is not found. Eclipse shows error on the variable statement on that line. I check inside the package com.nutiteq.rasterdatasources. but found no class using that name. Where does it come from anyway?
The class MBTilesRasterDataSource is part of their advancedlayers library
Looks like in the new version of this library, the class MBTilesRasterDataSource is available under com.nutiteq.datasources.raster
change your import package declaration to com.nutiteq.datasources.raster, the eclipse error should go away.

Android : Activity error in other package

This is my project stricture :
-com.android.test
--com.android.test.activity
---MainActivity.java
---SplashActivity.java
--com.android.test.ui
---ActivityBase.java
I created all activity in com.android.test.activity package and all activities extended from Base activity in com.android.test.ui package
But i don't know , when i creating activities on com.android.test.activity i see .R error in my Eclips , but when i creating activity on com.android.test package ,no need for importing the .R class.
I'm very beginner , please help
When you build an android project, the build tools generate a class called R.java. Because R is a class, it will exist in a package, just like all your other classes. By default, R will be generated in the package you've specified as the project package. For you, this should be com.android.test.
So your package structure is actually like this, even though R is in gen/, not src/.
-com.android.test
--R.java
--com.android.test.activity
---MainActivity.java
---SplashActivity.java
--com.android.test.ui
---ActivityBase.java
In Java, you will require an import statement if a class is not declared inside the package of the current class. So because com.android.test is not contained in com.android.test.activity, you will need to add import com.android.test.R; to MainActivity and SplashActivity, in order to use R in them.
If R is not being generated for you, check out Developing for Android in Eclipse: R.java not regenerating. I would possibly recommend learning to use IntelliJ IDEA, as I've encountered fewer strange build issues than in eclipse, but this is completely optional.
Another possible source of error is if you accidentally imported android.R, which is where the resources of the android SDK are referenced from. This could easily mess you up, since you could write code like R.string.foo and think you are using com.android.test.R.string.foo, but in reality, you are using android.R.string.foo, which may not exist. An easy way to find the problem is to explicitly say in your code, for example:
// you were originally getting an error here
MyActivity.this.getString(R.string.foo);
// try this to get a more obvious error, or see if it fixes it
MyActivity.this.getString(com.android.test.R.string.foo);

Android: Implementing SlidingMenu and ABS

I am trying to implement the SlidingMenu from https://github.com/jfeinstein10/SlidingMenu together with http://actionbarsherlock.com/ and I came across a problem that I could not fix myself that's why I turned to the issues page on SlidingMenu's GitHub. But 2 days and I got no reply so I am gonna ask it here.
Basically on the example project provided by jfeinstein10, I copied the SampleListFragment.java file and I've named it MenuListFragment.java on my project. I've made a couple of changes but those should not be an issue.
I also copied the menu.xml from the layout directory but changed its name attribute to the previous file including the package.
Project builds properly and no errors are encountered. Time to run the project.
Now on my project's main activity, when I call the setMenu(R.layout.menu); statement during runtime, it gives me an error which tells me something about ClassCastException (cannot cast com.dokgu.dota2stats.MenuListFragment to android.app.Fragment).
I've tried a couple of things like change the MenuListFragment.java to extend the android.app.Fragment instead of ListFragment but it didn't solve the problem and more issues came up because of that.
So please, can anyone help me with this please? I really want to make this work.
You can find the issue here as well: https://github.com/jfeinstein10/SlidingMenu/issues/546
Actionbarsherlork supports the lower lever version since android 2.x while the slidingmenu needs android 3.0+.Maybe you can add the android-support-v4.jar ,with some fragment and activity in slidingmenu project extending to.

NoClassDefFoundError Android with ActionBarActivity

I currently have an ActionBarActivity which always returns a NoClassDefFoundError. I've read that it might be a problem with the ADT but I cannot be sure, hence my question. I've imported the ActionBar sample from the Android samples under
android-sdk\samples\android-14\ActionBarCompat
I've labelled the ActionBarCompat project as a library under Project -> Properties but I'm still getting the error.
To reiterator:
public class SearchActivity extends ActionBarActivity { // Doesn't work, yields exception
public class SearchActivity extends Activity { // Works perfectly
Has anyone else experienced a similar error and perhaps found a solution?
Thanks in advance.
http://developer.android.com/tools/support-library/setup.html
The "Adding libraries with resources" section may help
since this is not in the most common v4 support library
include only android-support-v4.jar is not enough
Ended up using ActionBarSherlock instead and added a project reference under Project Properties as well as in the Build Path. Seems to have fixed all errors relating to my question.
Just this morning, Google released Android 4.3. They also updated its support library that allows ActionBar to be implemented on lower versions. Just have to extend ActionBarActivity. See guidelines here and tutorial here.
I've got the same problem. I solved it getting the android-support-v7-appcompat.jar library.
See here http://developer.android.com/tools/support-library/setup.html#using-apis how to install it.
I recommend focus on "Adding libraries without resources" instead "Adding libraries with resources" for the sake of simplicity.
When you do it, don't forget to import the this library into your Activity Java source. You can do it declaring import android.support.v7.app.ActionBarActivity;
I solved this problem like so, when you add the library make sure it does not have the android-support-v4 along with it (in libs folder of the library un-check android dependencies and android-support-v4), that's in the case where your project already have the android-support-v4, that's why you can't find class ActionBarActivity
This Link
may help you.
This library is located in the /extras/android/support/v7/appcompat/ directory.
Include in eclipse and add as library. This will solve your problem.

Categories

Resources