You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ionic 3应用构建失败求助:安装admob-free插件后Dex转换报错

Fixing Dex Parsing Error with Admob-Free Plugin in Ionic 3

Hey there, sorry you've been stuck on this for 3 days—let's get this sorted out. That Dex parsing error about class name vs path case mismatch (com/google/android/gms/base/R vs Com/google/android/gms/base/R.class) is a common compatibility issue with old Cordova plugins and Google Play Services libraries. Here are actionable fixes to try:

1. Clean and Rebuild Your Project from Scratch

Cached files often cause these weird case conflicts. Start with a full cleanup:

# Clean Ionic/Cordova build artifacts
ionic cordova clean android

# Remove and reinstall dependencies
rm -rf node_modules package-lock.json
npm install

# Re-add the Android platform (use a stable version for Ionic 3)
ionic cordova platform remove android
ionic cordova platform add android@8.1.0

This resets all cached plugin and platform files, which often resolves the case mismatch issue right away.

2. Force a Unified Google Play Services Version

The error usually stems from conflicting versions of Google Play Services (GMS) pulled in by different plugins. Lock down a consistent version in your config.xml:

<platform name="android">
    <!-- Specify a stable GMS version compatible with Ionic 3 -->
    <preference name="GooglePlayServicesVersion" value="17.0.0" />
    <!-- Enable AndroidX if your plugins require it -->
    <preference name="AndroidXEnabled" value="true" />
</platform>

After adding this, run ionic cordova prepare android to apply the changes.

3. Enable MultiDex Support

If your project has a lot of dependencies, enabling MultiDex can fix parsing errors caused by method count limits and resolve case-related Dex issues:

  1. Open platforms/android/app/build.gradle and add:
    android {
        defaultConfig {
            multiDexEnabled true
        }
    }
    
    dependencies {
        implementation 'com.android.support:multidex:1.0.3'
    }
    
  2. Update your AndroidManifest.xml (in platforms/android/app/src/main/) to use the MultiDex application class:
    <application
        android:name="android.support.multidex.MultiDexApplication"
        <!-- keep your existing application attributes -->
        >
    

4. Switch to a Maintained Admob Plugin

The old cordova-plugin-admob-free is no longer actively maintained, which leads to compatibility issues with newer Android tools. Replace it with the updated cordova-plugin-admob-plus:

# Remove the old plugin
ionic cordova plugin remove cordova-plugin-admob-free
npm uninstall @ionic-native/admob-free

# Install the maintained plugin
ionic cordova plugin add cordova-plugin-admob-plus --save
npm install @ionic-native/admob-plus --save

This plugin fixes many legacy compatibility bugs, including the GMS path case mismatch you're seeing.

Start with step 1 first—it's the fastest fix for most cases. If you're still having trouble, share your Cordova version or other installed plugins, and we can troubleshoot further!

内容的提问来源于stack exchange,提问作者x0t0

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:47:53