unity google ads plugin problem CommandInvokationFailure: Failed to re-package resources - android

I'm facing a problem in building my game to apk after I implemented unity google ads plugin. Before adding the plugin the build worked.
The problem is the error mentioned below:
CommandInvokationFailure: Failed to re-package resources.
CommandInvokationFailure: Failed to re-package resources.
C:\Users\Hamid Red\AppData\Local\Android\Sdk\build-tools\29.0.2\aapt.exe package --auto-add-overlay -v -f -m -J "gen" -M "AndroidManifest.xml" -S "res" -I "C:/Users/Hamid Red/AppData/Local/Android/Sdk\platforms\android-29\android.jar" -F bin/resources.ap_ --extra-packages android.arch.lifecycle:androidx.arch.core:androidx.asynclayoutinflater:androidx.browser:androidx.coordinatorlayout:androidx.core:androidx.cursoradapter:androidx.customview:androidx.documentfile:androidx.drawerlayout:androidx.fragment:androidx.interpolator:androidx.legacy.coreui:androidx.legacy.coreutils:androidx.lifecycle.livedata:androidx.lifecycle.livedata.core:androidx.lifecycle:androidx.lifecycle.viewmodel:androidx.loader:androidx.localbroadcastmanager:androidx.print:androidx.slidingpanelayout:androidx.swiperefreshlayout:androidx.versionedparcelable:androidx.viewpager:android.support.compat:android.support.coreui:android.support.coreutils:android.support.fragment:android.support.mediacompat:android.support.v4:com.google.android.gms.ads.impl:com.google.android.gms.ads_base:com.google.android.gms.ads_identifier:com.google.android.gms.ads:com.google.android.gms.common:com.google.android.gms.gass:com.google.firebase.measurement:com.google.android.gms.measurement_base:com.google.firebase.measurement_impl:com.google.android.gms.measurement.sdk:com.google.android.gms.measurement.sdk.api:com.google.android.gms.stats:com.sglib.easymobile.androidnative:com.google.unity:com.google.unity.ads:com.unity3d.ads -S

Follow the picture and resolve dependencies:
If it still doesn't work then it can be due to outdated android sdk.
https://github.com/unity-plugins/Unity-Admob/issues/70
https://forum.unity.com/threads/solved-still-commandinvokationfailure-failed-to-re-package-resources-after-updating-android-sdk.496425/
Might help you.

Related

Switch from aapt to aapt2 for native app packaging

We have a great build system, so we're not looking to use gradle. Right now, we use appt to build an APK and it works great and the APK runs well. I see that aapt2 is the future, though, and so we'd like to move to it before we're forced to.
What we currently do:
We have a simple icon in res/mipmap/our_icon.png
We have our ./AndroidManifest.xml file
We have our libMyApp.so stored in apk/lib/armeabi-v7a/libMyApp.so
We build using the following command: aapt package -f -M AndroidManifest.xml -S ./res -I /opt/android-sdk/platforms/android-28/android.jar -F my app-unsigned.apk apk/
We then zipalign and sign using apksigner and the app loads just fine. As you can see, all very simple and gives us just what we need.
I've tried the following with aapt2, but of course it is incorrect:
aapt2 compile ./res/mipmap/our_icon.png -o ./compiled
aapt2 link -v -I /opt/android-sdk/platforms/android-28/android.jar -I compiled/mipmap_our_icon.png.flat --manifest AndroidManifest.xml -o MyApp-unsigned.apk
note: including compiled/minmap_our_icon.png.flat.
error: failed to open APK: Invalid file.
You're trying to provide the resources the way you'd provide an APK (e.g. android.jar):
-I compiled/mipmap_our_icon.png.flat
To pass compiled resources use the -R flag (per each resource or use the wildcard * if you want to pass the whole directory, e.g. compiled/*).
You can find more info on differences between aapt and aapt2 in my old answer here.

Android Error building Player: CommandInvokationFailure: Failed to re-package resources

I am getting this error when i try to build my game for android.
What I've tried
I have looked at all the other answers on Stack Overflow but nothing seems to work
I have deleted the 24.0.0 Build tools
I have tried different jdk
I always get the same error trying to build for android.
I am using Unity 5.3.8 and Mac Yosemite
Error details
CommandInvokationFailure: Failed to re-package resources. See the
Console for
details./Users/admin/Library/Android/sdk/build-tools/android-4.4W/aapt
package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S
"res" -I
"/Users/admin/Library/Android/sdk/platforms/android-26/android.jar" -F
bin/resources.ap_ --extra-packages
com.google.unity:android.support.v7.appcompat:com.facebook.android:com.google.android.gms:com.google.android.gms.ads.impl:com.google.android.gms.ads:com.google.android.gms.base:com.google.android.gms:com.google.android.gms.clearcut:com.google.android.gms.gass:com.google.android.gms.tasks:android.support.v4
-S "/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res"
-S "/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/facebook/res"
-S "/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/google-play-services_lib/res"
-S "/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/play-services-ads-10.0.1/res"
-S "/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/play-services-ads-lite-10.0.1/res"
-S "/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/play-services-base-10.0.1/res"
-S "/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/play-services-basement-10.0.1/res"
-S "/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/play-services-clearcut-10.0.1/res"
-S "/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/play-services-gass-10.0.1/res"
-S "/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/play-services-tasks-10.0.1/res"
-S "/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/support-v4-24.0.0/res"stderr[/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/google-play-services_lib/res/values/admob_ads_attrs.xml:10: error: Attribute "adSize" has already been
defined/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/google-play-services_lib/res/values/admob_ads_attrs.xml:17: error: Attribute "adSizes" has already been
defined/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/google-play-services_lib/res/values/admob_ads_attrs.xml:20: error: Attribute "adUnitId" has already been
defined/Users/admin/Desktop/game/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/values/values.xml:110:
error: Attribute "theme" has already been
defined]stdout[Configurations

CommandInvokationFailure error when building APK?

I'm getting the following error when I build my APK:
CommandInvokationFailure: Failed to re-package resources. See the Console for details.
C:\Users\Me\AppData\Local\Android\sdk\build-tools\24.0.0\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Users/Me/AppData/Local/Android/sdk\platforms\android-24\android.jar" -F bin/resources.ap_ --extra-packages
I wish to integrate "Leaderboards" in my app using Google Play Services. What should I do to fix this?
What I've tried:
Reinstalling the Google Play Services plugin.
Updating SDK: See here. (tell me if I did it properly).
Made sure I have latest versions of "Extras/Android Support Repository" and "Extras/Google Repository".
Installed everything in SDK Manager. See here.
Updating Unity.
Restarting.
Few minor changes.
This absolutely will fix your problem.
Download the google_play_services from this link below :
https://dl-ssl.google.com/android/repository/google_play_services_8298000_r28.zip
Then unzip it.
after unzip copy the file to :
android-sdk/extras/google/google_play_services/
Find version.xml file at the zip file:
android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/res/values/
and copy it to :
Assets/Plugins/Android/res/values/
At unity folder
This is work for me.
To fix this error, you have to copy the version.xml file from
android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/res/values/
into
Assets/Plugins/Android/res/values/
of your Unity project's folder.

Maven Android build error

My Maven based project is executing the following command resulting in the error that follows:
Command
/bin/sh -c cd /Users/conor/Repositories/Dev/MyPosLogger/samples/HelloMyPosLogger && /Users/conor/Library/Android/sdk/build-tools/22.0.1/aapt package -f --no-crunch -I /Users/conor/Library/Android/sdk/platforms/android-19/android.jar -M /Users/conor/Repositories/Dev/MyPosLogger/samples/HelloMyPosLogger/target/filtered-manifest/AndroidManifest.xml -S /Users/conor/Repositories/Dev/MyPosLogger/samples/HelloMyPosLogger/src/main/res -S /Users/conor/Repositories/Dev/MyPosLogger/samples/HelloMyPosLogger/target/unpacked-libs/android.support_compatibility-v7-appcompat_apklib_22.0.0/res -m -J /Users/conor/Repositories/Dev/MyPosLogger/samples/HelloMyPosLogger/target/generated-sources/r --output-text-symbols /Users/conor/Repositories/Dev/MyPosLogger/samples/HelloMyPosLogger/target --auto-add-overlay
Error
/Users/conor/Repositories/Dev/MyPosLogger/samples/HelloMyPosLogger/target/unpacked-libs/android.support_compatibility-v7-appcompat_apklib_22.0.0/res/values-v21/styles_base.xml:75: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
Why is this and how do I fix it please?
I am using Android Maven Plugin v3.8.2
I have faced this error before and i solved it by the followin
Open Android sdk and make sure latest version of support library is installed or not. If not then install it also check compile pi version for your project is latest or not i.e. 21.
2.After installing just mvn clean install.
This will solve the issue.

Android Manifest file error after adding AdMob

I have gone through the below link for integrating AdMob
http://fastegggames.com/blog/2013/3/30/tutorial-admob
and Follwing is the error when i tried to build my .apk to test AdMob :
Error building Player: CommandInvokationFailure: Failed to re-package resources. See the Console for details.
C:\android-sdk-windows1\build-tools\19.0.1\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/android-sdk-windows1/platforms/android-19\android.jar" -F bin/resources.ap_ --extra-packages -S "C:\Users\avisingh.TAGS\Desktop\ONE_07\ONE_07\Temp\StagingArea\android-libraries\facebook\res"
stderr[
C:\Users\avisingh.TAGS\Desktop\ONE_07\ONE_07\Temp\StagingArea\android-libraries\facebook\res\values\strings.xml: error: Duplicate file.
res\values\strings.xml: Original is here.
]
stdout[
Processing raw dir 'C:\Users\avisingh.TAGS\Desktop\ONE_07\ONE_07\Temp\StagingArea\android-libraries\facebook\res'
]
I tried to build in API18 and API19 but still the same error. Can any one please help me through

Categories

Resources