5

我正在应用程序中使用 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);
4

3 回答 3

0

java.lang.ClassNotFoundException:找不到类 “android.support.v7.app.AppCompatViewInflater”

您的build.gradle. 删除其中之一:

implementation "com.android.support:design:$androidSupportVersion"   
implementation "com.android.support:design:$androidSupportVersion"  // Remove this

更新:看起来像一个错误27.1.1。尝试更新到28.0.0

def androidSupportVersion = "28.0.0"  
于 2018-10-04T17:03:43.453 回答
0

查看Google Pay 疑难解答指南可能会有所帮助。

对我来说,这ClassNotFoundException只是一个警告。在注意到 Google 在故障排除页面上的建议后,潜在的错误出现在 logcat 中:

Note: The error only becomes visible in logcat after you've pressed OK to close the alert.

按 OK 后,我收到一条非常具体的错误消息,与我如何组装付款数据 JSON 请求有关。

于 2020-01-31T21:22:32.510 回答
0

确保将 appcompat 支持库添加为 build.gradle 文件中的依赖项。

dependencies {
    implementation 'com.google.android.gms:play-services-wallet:16.0.0'
    implementation 'com.android.support:appcompat-v7:$androidSupportVersion'
}
于 2019-01-06T14:00:02.287 回答