Release App Bundle中Truecaller SDK无法工作的问题求助
Truecaller登录在App Bundle中报错错误码3(PartnerKey错误)问题
我给应用集成了Truecaller登录实现手机号验证功能,签名后的Release APK可正常运行,但生成签名App Bundle时,SDK会调用onFailureProfileShared()并返回错误码3(PartnerKey错误)。使用Debug SHA1时,Debug APK正常但Debug App Bundle失效;使用Release SHA1时,Release APK正常但Release App Bundle仍无法运行。App Bundle中定位等其他功能均正常,仅Truecaller登录功能异常。我已尝试更换PartnerKey、调整依赖等多种方案,但问题仍未解决。
MainActivity.java
package com.amitor.kotlintrue; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.EditText; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import com.truecaller.android.sdk.ITrueCallback; import com.truecaller.android.sdk.TrueError; import com.truecaller.android.sdk.TrueProfile; import com.truecaller.android.sdk.TruecallerSDK; import com.truecaller.android.sdk.TruecallerSdkScope; public class MainActivity extends AppCompatActivity { private static final String TAG = MainActivity.class.getSimpleName(); EditText editTextName, mobileNumber; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); editTextName = findViewById(R.id.editTextName); mobileNumber = findViewById(R.id.mobileNumberText); (findViewById(R.id.button)).setOnClickListener((View v) -> { //check if TrueCaller SDk is usable if(TruecallerSDK.getInstance().isUsable()){ TruecallerSDK.getInstance().getUserProfile(this); }else{ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.setMessage("Truecaller App not installed."); dialogBuilder.setPositiveButton("OK", (dialog, which) -> { Log.d(TAG, "onClick: Closing dialog"); dialog.dismiss(); } ); dialogBuilder.setIcon(R.drawable.ic_launcher_background); dialogBuilder.setTitle(" "); AlertDialog alertDialog = dialogBuilder.create(); alertDialog.show(); } }); // customisation of TrueCaller function like color , text can be done here TruecallerSdkScope trueScope = new TruecallerSdkScope.Builder(this, sdkCallback) .consentMode(TruecallerSdkScope.CONSENT_MODE_BOTTOMSHEET) .loginTextPrefix(TruecallerSdkScope.LOGIN_TEXT_PREFIX_TO_GET_STARTED) .loginTextSuffix(TruecallerSdkScope.LOGIN_TEXT_SUFFIX_PLEASE_VERIFY_MOBILE_NO) .ctaTextPrefix(TruecallerSdkScope.CTA_TEXT_PREFIX_USE) .buttonShapeOptions(TruecallerSdkScope.BUTTON_SHAPE_ROUNDED) .privacyPolicyUrl("https://tagle.in") .termsOfServiceUrl("https://tagle.in") .footerType(TruecallerSdkScope.FOOTER_TYPE_NONE) .consentTitleOption(TruecallerSdkScope.SDK_CONSENT_TITLE_LOG_IN) .build(); TruecallerSDK.init(trueScope); } private final ITrueCallback sdkCallback = new ITrueCallback() { @Override public void onSuccessProfileShared(@NonNull final TrueProfile trueProfile) { Toast.makeText(MainActivity.this,trueProfile.firstName, Toast.LENGTH_LONG ).show(); Log.i(TAG, trueProfile.firstName + " " + trueProfile.lastName); launchHome(trueProfile); } @Override public void onFailureProfileShared(@NonNull final TrueError trueError) { Toast.makeText(MainActivity.this,TrueError.ERROR_TYPE, Toast.LENGTH_LONG ).show(); // Log.i(TAG, trueError.toString()); } @Override public void onVerificationRequired(@Nullable final TrueError trueError) { Toast.makeText(MainActivity.this,trueError.getErrorType(), Toast.LENGTH_LONG ).show(); Log.i(TAG, "onVerificationRequired"); } }; @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == TruecallerSDK.SHARE_PROFILE_REQUEST_CODE) { TruecallerSDK.getInstance().onActivityResultObtained(this, requestCode, resultCode, data); } } private void launchHome(TrueProfile trueProfile) { editTextName.setText(trueProfile.firstName); mobileNumber.setText(trueProfile.phoneNumber); // startActivity(new Intent(getApplicationContext(), HomeActivity.class) // .putExtra("profile", trueProfile)); // finish(); } }
build.gradle(Module级别)
plugins { id 'com.android.application' } android { signingConfigs { debug { storeFile file('/Users/moden/key_store.jks') storePassword '189556' keyAlias 'key0' keyPassword '189556' } release { storeFile file('/Users/moden/key_store.jks') storePassword '123456' keyAlias 'key0' keyPassword '123456' } } namespace 'com.amitor.kotlintrue' compileSdk 33 defaultConfig { applicationId "com.amitor.kotlintrue" minSdk 21 targetSdk 33 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { signingConfig signingConfigs.release minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:2.0.4' implementation 'com.truecaller.android.sdk:truecaller-sdk:2.7.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' }
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <uses-sdk tools:overrideLibrary="com.truecaller.android.sdk" /> <uses-permission android:name="android.permission.READ_CALL_LOG"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.ANSWER_PHONE_CALLS"/> <uses-permission android:name="android.permission.INTERNET" /> <application android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" android:fullBackupContent="@xml/backup_rules" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.Kotlintrue" tools:targetApi="31"> <activity android:name=".MainActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <meta-data android:name="android.app.lib_name" android:value="" /> </activity> <meta-data android:name="com.truecaller.android.sdk.PartnerKey" android:value="3sBRy9fe254fbac0541b5988fb6b085190ed4" /> </application> </manifest>
内容的提问来源于stack exchange,提问作者Irshad Programmer
相关产品推荐
相关产品推荐

