I followed the Facebook tutorial for integrating the SDK, and just after I added the Log in to Facebook button in my .xml file.
When I run my app, then my app is showing an error like below.
I'm working on fully updated Android Studio.
Also I have added Facebook app id and in string.xml file, and I have added metadata in the manifesto file.
Why am I getting this error?
Please help me.
Logcat:
FATAL EXCEPTION: AsyncTask #2
Process: com.example.venkat.sampleapplication, PID: 23130
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:772)
at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:800)
at com.facebook.internal.Utility.queryAppSettings(Utility.java:802)
at com.facebook.login.widget.LoginButton$1.doInBackground(LoginButton.java:502)
at com.facebook.login.widget.LoginButton$1.doInBackground(LoginButton.java:499)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
AndroidMenifesto file:-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.venkat.sampleapplication">
<uses-permission android:name="android.permission.INTERNET"/>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
string.xml
<resources>
<string name="app_name">SampleApplication</string>
<string name="action_settings">Settings</string>
<string name="facebook_app_id">xxxxxxxxxxx</string>
</resources>
MainActivity:-
public class MainActivity extends AppCompatActivity {
// Create, automatically open (if applicable), save, and restore the
// Active Session in a way that is similar to Android UI lifecycles.
private LoginButton loginButton;
private CallbackManager callbackManager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(this.getApplicationContext());
setContentView(R.layout.content_main);
callbackManager = CallbackManager.Factory.create();
loginButton = (LoginButton) findViewById(R.id.loginFaceBook_button);
List<String> permissionNeeds = Arrays.asList("user_photos", "email", "user_birthday", "public_profile");
loginButton.setReadPermissions(permissionNeeds);
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
System.out.println("onSuccess");
}
#Override
public void onCancel() {
System.out.println("onCancel");
}
#Override
public void onError(FacebookException exception) {
Log.v("LoginActivity", exception.getCause().toString());
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
}
Your Meta Data tag Should be inside Application Tag of Manifest.
Change as this.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id"/>
</application>
Related
I'm disovering ORMlite. So, I have this DAO Factory class
public class DtoFactory extends Application {
private SharedPreferences preferences;
private DatabaseHelper databaseHelper = null;
private Dao<ReleveEntity, Integer> releveDAO = null;
#Override
public void onCreate() {
super.onCreate();
preferences = PreferenceManager.getDefaultSharedPreferences(this);
databaseHelper = new DatabaseHelper(this);
}
public SharedPreferences getPreferences() {return preferences;}
public Dao<ReleveEntity, Integer> getReleveDao() throws SQLException, java.sql.SQLException {
if (releveDAO == null) {
releveDAO = databaseHelper.getDao(ReleveEntity.class);
}
return releveDAO;
}
#Override
public void onTerminate() {
super.onTerminate();
if (databaseHelper != null) {
OpenHelperManager.releaseHelper();
databaseHelper = null;
}
}
}
And in the Main, I'll show just this lines where I have the problem :
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
dtoFactory = (DtoFactory) getApplication();
And the manifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.exercice.ftouzi.ReleveActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.exercice.ormdatabase.DtoFactory" >
</activity>
</application>
The message error is :
E/AndroidRuntime(19672): FATAL EXCEPTION: main
E/AndroidRuntime(19672): java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.formation.adapter/com.exercice.ftouzi.ReleveActivity}:
java.lang.ClassCastException: android.app.Application cannot be cast to
com.exercice.ormdatabase.DtoFactory
Can you please help me to resolve this ?
You need to specify your custom Application (i.e., DtoFactory) in the AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:name="com.exercice.ormdatabase.DtoFactory">
<activity
android:name="com.exercice.ftouzi.ReleveActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
when i write this code why the color of mFacebookCallbackManager changes to red saying cannot resolve symbol mFacebookCallbackManager
public class signin extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
mFacebookCallbackManager = CallbackManager.Factory.create();
setContentView(R.layout.activity_signin);
}
}
Manifest File
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Kindly help me out to solve the problem
You did not declare the variable mFacebookCallbackManager.
I am trying to create the login with facebook in android and I am running into this issue. I am not sure what else I am failing to see or set.
I tried setting app toke / client secret but it keeps failing.
Below is my code:
Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.test.app">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".SplashScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".FacebookLoginActivity">
<intent-filter>
<action android:name="android.intent.action.FACEBOOK_LOGIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
tools:replace="android:theme" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
FacebookLoginActivity
package com.test.app;
public class FacebookLoginActivity extends AppCompatActivity {
private TextView info;
private LoginButton loginButton;
private CallbackManager callbackManager;
#Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
setContentView(R.layout.facebook_login);
info = (TextView) findViewById(R.id.info);
loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
info.setText(
"User ID: "
+ loginResult.getAccessToken().getUserId()
+ "\n" +
"Auth Token: "
+ loginResult.getAccessToken().getToken()
);
}
#Override
public void onCancel() {
info.setText("Login attempt canceled.");
}
#Override
public void onError(FacebookException error) {
info.setText("Login attempt failed.");
}
});
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
}
ERROR
Caused by: java.lang.IllegalStateException: No Client Token found, please set the Client Token.
at com.facebook.internal.Validate.hasClientToken(Validate.java:162)
at com.facebook.login.DeviceAuthDialog.startLogin(DeviceAuthDialog.java:178)
at com.facebook.login.DeviceAuthMethodHandler.showDialog(DeviceAuthMethodHandler.java:51)
at com.facebook.login.DeviceAuthMethodHandler.tryAuthorize(DeviceAuthMethodHandler.java:42)
at com.facebook.login.LoginClient.tryCurrentHandler(LoginClient.java:254)
at com.facebook.login.LoginClient.tryNextHandler(LoginClient.java:216)
at com.facebook.login.LoginClient.authorize(LoginClient.java:121)
at com.facebook.login.LoginClient.startOrContinueAuth(LoginClient.java:102)
at com.facebook.login.LoginFragment.onResume(LoginFragment.java:153)
at android.support.v4.app.Fragment.performResume(Fragment.java:2230)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1343)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1523)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1585)
at android.support.v4.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:2842)
at android.support.v4.app.FragmentController.dispatchResume(FragmentController.java:223)
at android.support.v4.app.FragmentActivity.onResumeFragments(FragmentActivity.java:509)
at android.support.v4.app.FragmentActivity.onPostResume(FragmentActivity.java:498)
at android.app.Activity.performResume(Activity.java:6807)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3406)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3469)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2732)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
You'll need to add your app client token to your AndroidManifest like this:
<meta-data
android:name="com.facebook.sdk.ClientToken"
android:value="#string/facebook_client_token"/>
You can find your app client token in facebook dashboard -> settings -> advanced (in the security section)
in the login button cross check
<com.facebook.login.widget.LoginButton -> this is right
<com.facebook.login.widget.DeviceLoginButton -> this is wrong
I am developing an Android app. In my app, I am integrating Facebook Login. I have done developing Facebook Login once before. When I develop this time, Facebook callback functions are not called. I cannot check the error as well. I have no idea with what is wrong.
I installed Facebook SDK using Gradle
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
Then I generated key hash and set in the Facebook developer settings as follows:
This is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tonightfootballreport.com.tfr" >
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name="tonightfootballreport.model.TfrApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<activity
android:configChanges="orientation|screenSize"
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:configChanges="orientation|screenSize"
android:name=".FacebookConfigActivity"
android:label="Facebook"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="tonightfootballreport.com.tfr.FacebookConfigActivity"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:label="#string/app_name" />
<provider android:authorities="com.facebook.app.FacebookContentProvider1817380365215100"
android:name="com.facebook.FacebookContentProvider"
android:exported="true" />
</application>
</manifest>
As you can see Facebook Login is not in main activity and so I set FacebookConfigActivity in Developer Settings.
Then when I click a button in MainActivity, FacebookConfigActivity will be opened and perform Facebook Login. Below is the code.
public class FacebookConfigActivity extends AppCompatActivity {
private CallbackManager callbackManager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext(), AppConfig.FACEBOOK_REQUEST_CODE);
AppEventsLogger.activateApp(this);
setContentView(R.layout.activity_facebook);
setUpCallBack();
loginInToFacebook();
}
private void loginInToFacebook()
{
LoginManager.getInstance().logInWithReadPermissions(FacebookConfigActivity.this,Arrays.asList("public_profile"));
}
private void setUpCallBack()
{
callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
//show share alert
//then share
Log.i("LOGIN_SUCCESS","LOGIN_SUCCESS");
}
#Override
public void onCancel() {
Toast.makeText(getBaseContext(), "Operation canceled", Toast.LENGTH_SHORT).show();
finish();
}
#Override
public void onError(FacebookException error) {
Toast.makeText(getBaseContext(), "Error in connecting to Facebook", Toast.LENGTH_SHORT).show();
finish();
}
});
}
}
As you can see, it is just simple Facebook Login. So when I click login button, I enter credentials to the Facebook Login form you can see below.
Then after I click OK in the next step, FacebookConfigActivity is displayed and no callback function is called. If I click cancel, Facebook Cancel callback is not called as well. What is the possible error?
You forgot to put listener in onActivityResult()
put below code in onActivityResult method of activity:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
I'm trying to implement Facebook login button, but i'm receiving these errors when trying to run app:
Error:
FATAL EXCEPTION: AsyncTask #4
Process: , PID: 4633
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:746)
at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:774)
at com.facebook.internal.Utility.queryAppSettings(Utility.java:825)
at com.facebook.login.widget.LoginButton$1.run(LoginButton.java:489)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
com.android.vlada.sportisa E/GoogleApiAvailability: Google Play services is invalid. Cannot recover.
Code:
public class MainActivity extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener {
private Button buttonRegistrujSe, buttonPrijaviSeKaoGost, buttonPrijavaRegistrovaniKorisnik;
private LoginButton loginButton;
private CallbackManager callbackManager;
private TextView info;
#Override
protected void onCreate(Bundle savedInstanceState) {
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_main);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FacebookSdk.sdkInitialize(getApplicationContext());
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
buttonRegistrujSe = (Button) (findViewById(R.id.button_registruj_se));
buttonRegistrujSe.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, RegistrationActivity.class);
startActivity(i);
}
});
buttonPrijaviSeKaoGost = (Button) (findViewById(R.id.button_prijavi_se_kao_gost));
buttonPrijaviSeKaoGost.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i2 = new Intent(MainActivity.this, LoginGostActivity.class);
startActivity(i2);
}
});
buttonPrijavaRegistrovaniKorisnik = (Button) (findViewById(R.id.button_prijava_registrovani_korisnik));
buttonPrijavaRegistrovaniKorisnik.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i3 = new Intent(MainActivity.this, LoginActivity.class);
startActivity(i3);
}
});
callbackManager = CallbackManager.Factory.create();
setContentView(R.layout.activity_main);
info = (TextView)findViewById(R.id.info);
loginButton = (LoginButton)findViewById(R.id.connectWithFbButton);
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
info.setText(
"User ID: "
+ loginResult.getAccessToken().getUserId()
+ "\n" +
"Auth Token: "
+ loginResult.getAccessToken().getToken()
);
}
#Override
public void onCancel() {
info.setText("Login attempt canceled.");
}
#Override
public void onError(FacebookException e) {
info.setText("Login attempt failed.");
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
callbackManager.onActivityResult(requestCode, resultCode, data);
}
#Override
protected void onDestroy() {
super.onDestroy();
System.exit(0);
}
#Override
public void onConnectionFailed(#NonNull ConnectionResult connectionResult) {
}
}
Layout Code
<com.facebook.login.widget.LoginButton
android:id="#+id/connectWithFbButton"
style="#style/com_facebook_loginview_default_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_above="#+id/sign_in_button"
android:layout_centerHorizontal="true"
android:layout_marginBottom="43dp" />
Update: after i deleted duplicate code in MainActivity i'm still receiving the same errors when trying to ran app. I'm attaching Manifest code also as requested so maybe that would help? Thanx
<?xml version="1.0" encoding="utf-8"?>
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<permission
android:name="com.android.vlada.sportisa.Entiteti.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.android.vlada.sportisa.Entiteti.maps.permission.MAPS_RECEIVE" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAVb2JuN-5nbaVkGODivuXPJOF5OeRekzo" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_login" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name=".MainActivity" />
<activity android:name=".SplashActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegistrationActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".BiranjeAktivnosti" />
<activity
android:name=".Trazim"
android:label="#string/title_activity_trazim"
android:theme="#style/AppTheme" />
<activity
android:name=".Organizujem"
android:label="#string/title_activity_organizujem"
android:theme="#style/AppTheme" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
</application>
Add metadata inside application tag before activities.
What you have now is:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAVb2JuN-5nbaVkGODivuXPJOF5OeRekzo" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_login" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name=".MainActivity" />
<activity android:name=".SplashActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
...
</application>
Move metadata inside application tag like this:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAVb2JuN-5nbaVkGODivuXPJOF5OeRekzo" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_login" />
<activity android:name=".MainActivity" />
<activity android:name=".SplashActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
...
</application>
Have you added this code in manifest file.
You also need to add the application id like this:
<application android:label="#string/app_name" ...>
...
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
...
</application>
Don't what, but there's an issue with either FacebookActivity name or the support for Gradle Version 2.3.0 is removed. I faced the same issue and with the following I got rid of this.
Replaced <activity> tag
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
with the <meta> tag.
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/fb_id" />
EDIT
Also, I have placed this <meta> tag at the bottom of the file below, all the activities, above the closing tag.