Getting Started with the facebook sdk for android - android

I have been finished step 3 of "Getting Started with the Facebook SDK for Android" from facebook developers support and this is code from the Sample directory :
package com.facebook.samples.profilepicture;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class ProfilePictureSampleActivity extends FragmentActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile_picture_sample);
}
}
When I try to run ProfilePictureSample there are some errors like this :
"The import android.os.Bundle cannot be resolved"
"The type android.app.Activity cannot be resolved. It is indirectly
referenced from required .class files"
"The hierarchy of the type ProfilePictureSampleActivity is
inconsistent"
So how can I fix them ? It's strange because if I build a simple activity project with android.os.Bundle works fine.

Probably the problem is the holder api version that the application of this code request because I suppose that android.os.Bundle is for api 17 of android sdk. So it can be resolved by go to "android sdk Manager" and download the version of requested api.

Related

error: package com.getcapacitor.community.facebooklogin does not exist error in quasar + capacitor

Package - https://github.com/capacitor-community/facebook-login
Setup - Facebook login for Android in Quasar + Capacitor
So I just followed the instructions from the documentation for android. Everything is working fine in web setup but when I am trying to build using android studio I am getting the error:
error: package com.getcapacitor.community.facebooklogin does not exist
MainActivity.java
package org.mycure.mobile.pxp;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import com.getcapacitor.community.facebooklogin.FacebookLogin;
import java.util.ArrayList;
public class MainActivity extends BridgeActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(FacebookLogin.class);
}});
}
}
Versions
quasar - 1.15.10
#capacitor/core - 2.4.7
#capacitor/android - 2.4.7
Relevant links
I also saw this issue and followed the suggested fixes but non worked. I was hoping maybe I just missed something? Thanks.

New->Android application Project created with a lot of errors(Android 6.0)

So when i create a new android application project with ANDROID 6.0 library i instantly get the a lot of errors in the MainActivity code.
Starting with The import android.support.v7.app cannot be resolved
To The method onCreate(Bundle) of type MainActivity must override or implement a supertype method
When i add the appcompat.v7 library obviously Some of the errors related are gone but other are coming instead. Like:
The type android.support.v4.widget.DrawerLayout$DrawerListener cannot be resolved. It is indirectly referenced from required .class files on the package line.
And still The method onCreateOptionsMenu(Menu) of type MainActivity must override or implement a supertype method.
Ok. So add the v4 jar too. Ok. I added it too to the project properties and no errors!
Wait,but when i run the app now I get a ClassNotFoundException.
So what the hell android 6.0???
Thanks for the help.
EDIT
MainActivity.java:
package com.minyan.get.dl;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
The main reason is that Android Studio is the main IDE now.
Eclipse is no longer supported.
I suggest switching to Android Studio.

Android Testing with Robolectric: not recognizing Facebook SDK

We are trying to use the Robolectric testing framework in Android Studio in order to test the Facebook API. The Facebook Login button works so the Facebook API is working. However, the following test fails:
package com.airportapp.test.Models;
import android.app.Activity;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.Robolectric;
import com.airportapp.test.MyRobolectricTestRunner;
import com.airportapp.LoginActivity;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
#RunWith(MyRobolectricTestRunner.class)
public class LoginActivityTest {
#Before
public void setup() {
//do whatever is necessary before every test
}
#Test
public void testActivityFound() {
Activity activity = Robolectric.buildActivity(LoginActivity.class).create().get();
Assert.assertNotNull(activity);
}
}
And the error is that Android Studio could not find the android.support file when we run the tests. You can see the error here:
The other error that shows up is:
android.view.InflateException: XML file app/src/main/res/layout/activity_login.xml line #-1 (sorry, not yet implemented): Error inflating class com.facebook.widget.LoginButton
So Android Studio is not happy with the facebook login button as well :( But it works... We think that we need to import something, but we don't know where to put it.
The InflateException is because Robolectric cannot find the resources from the Facebook SDK. To solve this, the project.properties file has to be updated to point to the Facebook SDK project. Do this by adding the following line to it:
android.library.reference.1={Path}
{Path} should be a relative path, from the project.properties file to the folder containing the AndroidManifest.xml of the Facebook SDK project. In my case that is ../../build/intermediates/exploded-aar/com.facebook.android/facebook/3.21.0.
Note that this works for all Android Library Projects which contain resources that aren't found by Robolectric. Further reading: here and here. Also, more documentation about project.properties can be found here. Note that in my project the Robolectric tests are located in the Android app project itself. So you could also try placing the project.properties file in the same directory as the AndroidManifest.xml used for testing.
As for your first problem; I have no personal experience with it. But it appears to be because Gradle cannot find the support libraries when compiling the unit tests. The answer from this question should fix it.

android - how to import com.google.android.maps.MapActivity?

I am trying to get google maps to work in my android project. I have already got the md5 key and signed up with google to get the api key, but now when i am trying to display the map, I get an error when importing it. "com.google" has the sqiqly red line under it.
Can anyone help?
Thanks
this is my xml file: (note: i replaced the key with 'my_key' since i didnt want to make it public)
<com.google.android.maps.MapView
android:id="my_map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="my_key"/>
and for the java file:
package com.escortme.basic;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import com.google.android.maps.MapActivity; // ERROR
import com.google.android.maps.MapView; // ERROR
import android.os.Bundle;
public class Police_ViewActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.pol_view);
}
public void quit_button_action(View view){
finish();
}
}
It sounds like you don't have the Google APIs referenced by your project. Assuming you're using Eclipse, view the properties of your project and select Android and check that Google APIs is checked rather than simply an Android version.
You may need to download the Google APIs if you haven't already. You can do this through the Android SDK Manager.

Bundle cannot be resolved to a type

Im trying to finish the first Android lesson and one of the errors I am getting is "Bundle cannot be resolved to a type"
Here is the code:
package com.example.myapp;
import android.app.Activity;
public class DisplayMessageActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
when i view the project properties it has "Android 2.1" by "Android Open Source Project" with platform 2.1 and API level 7. This is checked off as the project build target.
am i using the wrong project build target???
You need to add:
import android.os.Bundle;
to your list of imports.

Categories

Resources