site
site

Reputation: 247

Error: A valid Facebook app id must be set in the AndroidManifest.xml

I follow this video. This app I run in a mobile devixe Xiaomi Redmi 4A. Install succesfully and show this error. I can't understand why? I can't use Facebook in this code.

Error:

Successfully synced application org.nativescript.pushnotify on device 8066aa497d24. ActivityManager: Start proc 26158:org.nativescript.pushnotify/u0a238 for activity org.nativescript.pushnotify/com.tns.NativeScriptActivity caller=null 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.callJSMethodNative(Native Method) 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101) 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.callJSMethodImpl(Runtime.java:983) 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.callJSMethod(Runtime.java:970) 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.callJSMethod(Runtime.java:954) 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.callJSMethod(Runtime.java:946) 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.callJSMethodNative(Native Method) 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101) 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.callJSMethodImpl(Runtime.java:983) 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.callJSMethod(Runtime.java:970) 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.callJSMethod(Runtime.java:954) 07-06 12:21:32.247 26158 26158 E AndroidRuntime:
com.tns.Runtime.callJSMethod(Runtime.java:946) 07-06 12:21:32.247 26158 26158 E AndroidRuntime: at com.tns.Runtime.callJSMethodNative(Native Method) 07-06 12:21:32.247 26158 26158 E AndroidRuntime: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101) 07-06 12:21:32.247 26158 26158 E AndroidRuntime: at com.tns.Runtime.callJSMethodImpl(Runtime.java:983) 07-06 12:21:32.247 26158 26158 E AndroidRuntime: at com.tns.Runtime.callJSMethod(Runtime.java:970) 07-06 12:21:32.247 26158 26158 E AndroidRuntime: at com.tns.Runtime.callJSMethod(Runtime.java:954) 07-06 12:21:32.247 26158 26158 E AndroidRuntime: at com.tns.Runtime.callJSMethod(Runtime.java:946) System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.pushnotify/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: System.err: Calling js method onCreate failed System.err: System.err: Error: A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk. System.err: com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:276) System.err:
com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:232) System.err: com.tns.Runtime.callJSMethodNative(Native Method) System.err:
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101) System.err: com.tns.Runtime.callJSMethodImpl(Runtime.java:983) System.err: com.tns.Runtime.callJSMethod(Runtime.java:970) System.err: com.tns.Runtime.callJSMethod(Runtime.java:954) System.err: com.tns.Runtime.callJSMethod(Runtime.java:946) System.err:
com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:18) System.err: android.app.Activity.performCreate(Activity.java:6875) System.err:
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) System.err:
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659) System.err:
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767) System.err:
android.app.ActivityThread.-wrap12(ActivityThread.java) System.err:
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1514) System.err: android.os.Handler.dispatchMessage(Handler.java:102) System.err: android.os.Looper.loop(Looper.java:163) System.err:
android.app.ActivityThread.main(ActivityThread.java:6221) System.err: java.lang.reflect.Method.invoke(Native Method) System.err:
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) System.err:
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794) System.err: File: "file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/nativescript-plugin-firebase/firebase.js, line: 331, column: 41 System.err: System.err: StackTrace: System.err: Frame: function:'runInit', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/nativescript-plugin-firebase/firebase.js', line: 331, column: 42 System.err: Frame: function:'Observable.notify', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 110, column: 23 System.err: Frame: function:'notifyLaunch', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 870, column: 17 System.err: Frame: function:'ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 803, column: 28 System.err: Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 677, column: 14 System.err: Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/tns-core-modules/ui/frame/activity.js', line: 20, column: 25 System.err: System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2706) System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767) System.err: at android.app.ActivityThread.-wrap12(ActivityThread.java) System.err:
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1514) System.err: at android.os.Handler.dispatchMessage(Handler.java:102) System.err:
at android.os.Looper.loop(Looper.java:163) System.err: at android.app.ActivityThread.main(ActivityThread.java:6221) System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794) System.err: Caused by: com.tns.NativeScriptException: System.err: Calling js method onCreate failed System.err: System.err: Error: A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk. System.err:
com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:276) System.err:
com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:232) System.err: com.tns.Runtime.callJSMethodNative(Native Method) System.err:
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101) System.err: com.tns.Runtime.callJSMethodImpl(Runtime.java:983) System.err: com.tns.Runtime.callJSMethod(Runtime.java:970) System.err: com.tns.Runtime.callJSMethod(Runtime.java:954) System.err: com.tns.Runtime.callJSMethod(Runtime.java:946) System.err:
com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:18) System.err: android.app.Activity.performCreate(Activity.java:6875) System.err:
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) System.err:
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659) System.err:
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767) System.err:
android.app.ActivityThread.-wrap12(ActivityThread.java) System.err:
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1514) System.err: android.os.Handler.dispatchMessage(Handler.java:102) System.err: android.os.Looper.loop(Looper.java:163) System.err:
android.app.ActivityThread.main(ActivityThread.java:6221) System.err: java.lang.reflect.Method.invoke(Native Method) System.err:
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) System.err:
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794) System.err: File: "file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/nativescript-plugin-firebase/firebase.js, line: 331, column: 41 System.err: System.err: StackTrace: System.err: Frame: function:'runInit', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/nativescript-plugin-firebase/firebase.js', line: 331, column: 42 System.err: Frame: function:'Observable.notify', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/tns-core-modules/data/observable/observable.js', line: 110, column: 23 System.err: Frame: function:'notifyLaunch', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 870, column: 17 System.err: Frame: function:'ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 803, column: 28 System.err: Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 677, column: 14 System.err: Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/org.nativescript.pushnotify/files/app/tns_modules/tns-core-modules/ui/frame/activity.js', line: 20, column: 25 System.err: System.err: at com.tns.Runtime.callJSMethodNative(Native Method) System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101) System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:983) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:970) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:954) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:946) System.err: at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:18) System.err: at android.app.Activity.performCreate(Activity.java:6875) System.err:
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659) System.err: ... 9 more System.err: Caused by: A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk. System.err: at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:276) System.err: at com.facebook.FacebookSdk.sdkInitialize(FacebookSdk.java:232) System.err: ... 19 more ActivityManager: report kill process: killerPid is:26158, killedPid is:26158 ActivityManager: Process org.nativescript.pushnotify (pid 26158) has died: fore TS ActivityManager: cleanUpApplicationRecord -- 26158

Can you ask me any idea please? How to solution this?

Upvotes: 0

Views: 4466

Answers (1)

Florian Thuin
Florian Thuin

Reputation: 950

Your AndroidManifest should contain this line <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

Here is a partial AndroidManifest.xml containing it

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="__PACKAGE__"
      android:versionCode="10017"
      android:versionName="1.17">
...
    <application android:name="com.tns.NativeScriptApplication"
             android:allowBackup="true"
             android:icon="@drawable/icon"
             android:label="@string/app_name"
             android:theme="@style/AppTheme">
        ...
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
    </application>
</manifest>

And in your App_Resources/Android/src/main/res/values/strings.xml, set the facebook application ID starting with fb

<resources>
    ...
    <string name="facebook_app_id">fb{{ facebook_app_id }}</string>
</resources>

Upvotes: 5

Related Questions