I've just recently implemented NDK, and everything seems to work fine. Now.. I'm not sure on how to use the c method in the manifest, I managed to use it in some section of my code by creating an object which load the cpp library:
object ApiKeyRetriever {
init{
System.loadLibrary("api-keys")
}
external fun getGoogleKey():String
external fun getFacebookToken():String
external fun getDatabase():String
external fun getFacebookProtocolScheme():String
}
But now, I need it in the manifest for the facebook meta-data
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="${fbLoginProtocolScheme}" />
<meta-data
android:name="com.facebook.sdk.ClientToken"
android:value="${facebookClientToken}" />
Currently I'm using these two variables that I have stored in (Android view) Gradle Scripts -> local.properties, which is the old way I used to store key, just to prevent them from being uploaded on github. (by using id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin').
CodePudding user response:
I found out that with the newer Facebook SDK there no need anymore to specifically set meta-data in the manifest (we can just remove them) and that you can do it via code like this:
class LoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
FacebookSdk.setApplicationId(ApiKeyRetriever.getFacebookApplicationID())
FacebookSdk.setClientToken(ApiKeyRetriever.getFacebookToken())
FacebookSdk.sdkInitialize(applicationContext)
}
}
Where FacebookApplicationID returns the AppID you can see from the Facebook DEV portal. And getFacebookToken is the facebook token.
these three methods must be called before any usage of the facebookLogin methods