我正在应用程序中使用 Google Pay 实现 Braintree Drop-in UI,并且在选择 google pay 时开始出现错误,该对话框显示消息“意外的开发人员错误,请稍后再试”,以下是错误:
Failed to instantiate custom view inflater
android.support.v7.app.AppCompatViewInflater. Falling back to default.
java.lang.ClassNotFoundException: android.support.v7.app.AppCompatViewInflater
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at android.support.v7.app.AppCompatDelegateImpl.a(:com.google.android.gms@13280020@13.2.80 (040406-211705629):1)
at android.support.v7.app.AppCompatDelegateImpl.onCreateView(:com.google.android.gms@13280020@13.2.80 (040406-211705629):1)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.DecorView.onResourcesLoaded(DecorView.java:1911)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2579)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2652)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2066)
at android.support.v7.app.AppCompatDelegateImpl.n(:com.google.android.gms@13280020@13.2.80 (040406-211705629):8)
at android.support.v7.app.AppCompatDelegateImpl.a(:com.google.android.gms@13280020@13.2.80 (040406-211705629):48)
at dip.findViewById(Unknown Source:4)
at arru.a(:com.google.android.gms@13280020@13.2.80 (040406-211705629):5)
at arrt.onCreate(:com.google.android.gms@13280020@13.2.80 (040406-211705629):1)
at com.google.android.gms.wallet.ib.IbChimeraActivity.onCreate(:com.google.android.gms@13280020@13.2.80 (040406-211705629):8)
at com.google.android.chimera.Activity.publicOnCreate(Unknown Source:0)
at diu.onCreate(:com.google.android.gms@13280020@13.2.80 (040406-211705629):6)
at odi.onCreate(:com.google.android.gms@13280020@13.2.80 (040406-211705629):2)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2775)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2897)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1598)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:251)
at android.app.ActivityThread.main(ActivityThread.java:6572)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatViewInflater" on path: DexPathList[[zip file "/system/framework/com.android.location.provider.jar", zip file "/system/framework/com.android.media.remotedisplay.jar", zip file "/data/app/com.google.android.gms-nZjkHiOnxKIKJV7GOxW-nQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.google.android.gms-
nZjkHiOnxKIKJV7GOxW-nQ==/lib/arm64, /data/app/com.google.android.gms-
nZjkHiOnxKIKJV7GOxW-nQ==/base.apk!/lib/arm64-v8a, /system/lib64,
/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at android.support.v7.app.AppCompatDelegateImpl.a(:com.google.android.gms@13280020@13.2.80 (040406-211705629):1)
at android.support.v7.app.AppCompatDelegateImpl.onCreateView(:com.google.android.gms@13280020@13.2.80 (040406-211705629):1)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.DecorView.onResourcesLoaded(DecorView.java:1911)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2579)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2652)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2066)
at android.support.v7.app.AppCompatDelegateImpl.n(:com.google.android.gms@13280020@13.2.80 (040406-211705629):8)
at android.support.v7.app.AppCompatDelegateImpl.a(:com.google.android.gms@13280020@13.2.80 (040406-211705629):48)
at dip.findViewById(Unknown Source:4)
at arru.a(:com.google.android.gms@13280020@13.2.80 (040406-211705629):5)
at arrt.onCreate(:com.google.android.gms@13280020@13.2.80 (040406-211705629):1)
at com.google.android.gms.wallet.ib.IbChimeraActivity.onCreate(:com.google.android.gms@13280020@13.2.80 (040406-211705629):8)
at com.google.android.chimera.Activity.publicOnCreate(Unknown Source:0)
at diu.onCreate(:com.google.android.gms@13280020@13.2.80 (040406-211705629):6)
at odi.onCreate(:com.google.android.gms@13280020@13.2.80 (040406-211705629):2)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2775)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2897)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1598)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:251)
at android.app.ActivityThread.main(ActivityThread.java:6572)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
以下是我在 gradle 中添加的依赖项:
def androidSupportVersion = "27.1.1"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:cardview-v7:$androidSupportVersion"
implementation "com.android.support:recyclerview-v7:$androidSupportVersion"
implementation "com.android.support:support-v4:$androidSupportVersion"
implementation "com.android.support:design:$androidSupportVersion"
implementation "com.android.support:design:$androidSupportVersion"
implementation "com.google.android.gms:play-services-wallet:16.0.0"
implementation "com.android.support:customtabs:$androidSupportVersion"
implementation "com.android.support.constraint:constraint-layout:1.1.3"
implementation 'com.braintreepayments.api:drop-in:3.+'
Braintree Google Pay 集成代码:
GooglePaymentRequest googlePaymentRequest = new GooglePaymentRequest()
.transactionInfo(TransactionInfo.newBuilder()
.setTotalPrice(priceString)
.setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
.setCurrencyCode("GBP")
.build())
.billingAddressRequired(true)
.uiRequired(true);