Qt5/Android集成AdMob缺失libproject目录的技术求助
Fixing Missing
google-play-services_lib for Qt5/Android AdMob Integration Hey there, I’ve run into this exact issue before—Google phased out the old libproject structure for Google Play Services a while back, moving everything to the Maven repository (m2repository) instead. Let’s walk through how to extract the necessary library files correctly:
Step 1: Locate the right AAR file in m2repository
Navigate to this path in your Android SDK:
android-sdk/extras/google/m2repository/com/google/android/gms/play-services-ads/
Pick a stable version (match it to the AdMob requirements of your open-source library—stick to recent but non-beta releases for reliability). Inside the version folder, you’ll find a file named play-services-ads-[your-version].aar.
Step 2: Extract the AAR content
- Rename the
.aarfile to.zip(AAR files are just zip archives under the hood). - Unzip it into a folder named
google-play-services_lib(this is the name your open-source library expects).
Step 3: Organize the extracted files
The unzipped folder will have several files/folders. Here’s what you need to keep and structure:
- Create a
libssubfolder insidegoogle-play-services_lib, then move theclasses.jarfile into it. - Keep the
resfolder (contains AdMob’s required resources like strings and drawables) andAndroidManifest.xml(if present) in the root ofgoogle-play-services_lib.
Step 4: Link the library to your Qt project
- Move the fully organized
google-play-services_libfolder to the same directory as your project’sAndroidManifest.xml(usually theandroidsubfolder of your Qt project). - Open Qt Creator, go to your project’s Android settings, and make sure the library is added as a dependency. If Qt doesn’t auto-detect it, you can manually add a reference in your project’s
build.gradlefile under thedependenciesblock:compile project(':google-play-services_lib') - Trigger a Gradle sync (Qt Creator usually prompts this automatically when changes are made) to ensure everything is hooked up correctly.
Quick Notes
- Double-check that you have the Google Repository installed via the Android SDK Manager—this is what populates the
m2repositoryfolder with these libraries. - Always match the
play-services-adsversion to the requirements of your AdMob integration library to avoid compatibility crashes.
内容的提问来源于stack exchange,提问作者Gourmand
相关产品推荐
相关产品推荐

