在Unity

时间:2016-03-22 12:12:51

标签: android unity3d admob unity5

我正在尝试在Unity项目中添加AdMob服务。对于iOS设备,它运行良好。但对于Android设备,它输出编译错误。

我做的是

(1)获得AdMob单元ID并将其粘贴到源代码(C#)。

(2)将AdmMob Unity插件导入Unity。

(3)将google-play-services_lib导入Asset / Plugins / Android文件夹。

我试图删除并重新导入包并删除临时文件夹。但它还没有奏效。

我该如何解决这个问题?

这是日志。

CommandInvokationFailure: Failed to re-package resources. See the Console for details.

/Users/kazuhiko/Library/Android/sdk/build-tools/23.0.2/aapt package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "/Users/kazuhiko/Library/Android/sdk/platforms/android-23/android.jar" -F bin/resources.ap_ --extra-packages com.google.unity:android.support.v7.appcompat:com.google.android.gms:com.google.android.gms.ads:com.google.android.gms:android.support.v4 -S "/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res" -S "/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res" -S "/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/play-services-ads-8.4.0/res" -S "/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/play-services-basement-8.4.0/res" -S "/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/support-v4-23.1.1/res"

stderr[

/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/abc_alert_dialog_button_bar_material.xml:18: note: removing attribute http://schemas.android.com/apk/res/android:layoutDirection from <android.support.v7.widget.ButtonBarLayout>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/abc_alert_dialog_button_bar_material.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/abc_alert_dialog_button_bar_material for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/abc_alert_dialog_material.xml:48: note: removing attribute http://schemas.android.com/apk/res/android:textAlignment from <android.support.v7.widget.DialogTitle>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/abc_alert_dialog_material.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/abc_alert_dialog_material for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/abc_dialog_title_material.xml:29: note: removing attribute http://schemas.android.com/apk/res/android:textAlignment from <TextView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/abc_dialog_title_material.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/abc_dialog_title_material for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/abc_screen_toolbar.xml:27: note: removing attribute http://schemas.android.com/apk/res/android:touchscreenBlocksFocus from <android.support.v7.widget.ActionBarContainer>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/abc_screen_toolbar.xml: note: using v21 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/abc_screen_toolbar for configuration v21.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/abc_search_view.xml:47: note: removing attribute http://schemas.android.com/apk/res/android:layoutDirection from <LinearLayout>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/abc_search_view.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/abc_search_view for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_big_media.xml:42: note: removing attribute http://schemas.android.com/apk/res/android:layoutDirection from <LinearLayout>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_big_media.xml:34: note: removing attribute http://schemas.android.com/apk/res/android:layout_marginStart from <include>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_big_media.xml:34: note: removing attribute http://schemas.android.com/apk/res/android:layout_toStartOf from <include>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_big_media.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/notification_template_big_media for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_big_media_narrow.xml:60: note: removing attribute http://schemas.android.com/apk/res/android:layout_toEndOf from <ImageView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_big_media_narrow.xml:46: note: removing attribute http://schemas.android.com/apk/res/android:layout_toEndOf from <LinearLayout>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_big_media_narrow.xml:46: note: removing attribute http://schemas.android.com/apk/res/android:layoutDirection from <LinearLayout>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_big_media_narrow.xml:38: note: removing attribute http://schemas.android.com/apk/res/android:layout_marginStart from <include>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_big_media_narrow.xml:38: note: removing attribute http://schemas.android.com/apk/res/android:layout_toStartOf from <include>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_big_media_narrow.xml:30: note: removing attribute http://schemas.android.com/apk/res/android:layout_alignParentEnd from <include>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_big_media_narrow.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/notification_template_big_media_narrow for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_lines.xml:18: note: removing attribute http://schemas.android.com/apk/res/android:paddingEnd from <LinearLayout>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_lines.xml:77: note: removing attribute http://schemas.android.com/apk/res/android:layout_marginStart from <LinearLayout>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_lines.xml:96: note: removing attribute http://schemas.android.com/apk/res/android:paddingStart from <TextView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_lines.xml:64: note: removing attribute http://schemas.android.com/apk/res/android:layout_marginStart from <TextView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_lines.xml:27: note: removing attribute http://schemas.android.com/apk/res/android:layout_marginStart from <LinearLayout>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_lines.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/notification_template_lines for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_media.xml:43: note: removing attribute http://schemas.android.com/apk/res/android:layout_marginEnd from <include>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_media.xml:33: note: removing attribute http://schemas.android.com/apk/res/android:layoutDirection from <LinearLayout>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_media.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/notification_template_media for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_part_chronometer.xml:18: note: removing attribute http://schemas.android.com/apk/res/android:paddingStart from <Chronometer>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_part_chronometer.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/notification_template_part_chronometer for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_part_time.xml:18: note: removing attribute http://schemas.android.com/apk/res/android:paddingStart from <DateTimeView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/notification_template_part_time.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/notification_template_part_time for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/layout/place_autocomplete_item_powered_by_google.xml:28: note: removing attribute http://schemas.android.com/apk/res/android:layout_toEndOf from <ImageView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/layout/place_autocomplete_item_powered_by_google.xml:28: note: removing attribute http://schemas.android.com/apk/res/android:layout_marginStart from <ImageView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/layout/place_autocomplete_item_powered_by_google.xml:8: note: removing attribute http://schemas.android.com/apk/res/android:layout_marginStart from <View>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/layout/place_autocomplete_item_powered_by_google.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/place_autocomplete_item_powered_by_google for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/layout/place_autocomplete_item_prediction.xml:52: note: removing attribute http://schemas.android.com/apk/res/android:layout_toEndOf from <TextView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/layout/place_autocomplete_item_prediction.xml:35: note: removing attribute http://schemas.android.com/apk/res/android:layout_toEndOf from <TextView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/layout/place_autocomplete_item_prediction.xml:8: note: removing attribute http://schemas.android.com/apk/res/android:layout_alignParentStart from <include>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/layout/place_autocomplete_item_prediction.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/place_autocomplete_item_prediction for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/layout/place_autocomplete_progress.xml:2: note: removing attribute http://schemas.android.com/apk/res/android:indeterminateTint from <ProgressBar>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/layout/place_autocomplete_progress.xml:2: note: removing attribute http://schemas.android.com/apk/res/android:indeterminateTintMode from <ProgressBar>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/layout/place_autocomplete_progress.xml: note: using v21 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/place_autocomplete_progress for configuration v21.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/select_dialog_multichoice_material.xml:18: note: removing attribute http://schemas.android.com/apk/res/android:paddingStart from <CheckedTextView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/select_dialog_multichoice_material.xml:18: note: removing attribute http://schemas.android.com/apk/res/android:paddingEnd from <CheckedTextView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/select_dialog_multichoice_material.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/select_dialog_multichoice_material for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/select_dialog_singlechoice_material.xml:18: note: removing attribute http://schemas.android.com/apk/res/android:paddingStart from <CheckedTextView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/select_dialog_singlechoice_material.xml:18: note: removing attribute http://schemas.android.com/apk/res/android:paddingEnd from <CheckedTextView>
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/appcompat-v7-23.1.1/res/layout/select_dialog_singlechoice_material.xml: note: using v17 attributes; synthesizing resource com.kazzzstudio.androidadmobtest:layout/select_dialog_singlechoice_material for configuration v17.
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/values/admob_ads_attrs.xml:10: error: Attribute "adSize" has already been defined
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/values/admob_ads_attrs.xml:17: error: Attribute "adSizes" has already been defined
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/values/admob_ads_attrs.xml:20: error: Attribute "adUnitId" has already been defined
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/values/common_attrs.xml:13: error: Attribute "imageAspectRatioAdjust" has already been defined
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/values/common_attrs.xml:22: error: Attribute "imageAspectRatio" has already been defined
/Volumes/Time Machine/Dev/Unity/AndroidAdMobTest/Temp/StagingArea/android-libraries/google-play-services_lib/res/values/common_attrs.xml:27: error: Attribute "circleCrop" has already been defined

]
stdout[
Configurations:
 (default)

Files:
  AndroidManifest.xml
    Src: () AndroidManifest.xml

Resource Dirs:
Including resour<message truncated>

1 个答案:

答案 0 :(得分:0)

我可以解决这个问题。现在它可以通过构建阶段并安装android模拟器(但是当我启动应用程序时,它总是崩溃)。 我正在做的是从Asset / Plugins / Android /文件夹中删除5个文件。

  • 程序兼容性-v7-23.1.1.aar
  • 播放服务的广告,8.4.0.aar
  • 播放服务,地下室8.4.0.aar
  • 支持的注解-23.1.1.jar
  • 支持-v4-23.1.1.aar

它是由Unity自动生成的,删除这些文件并不容易。当我删除这些文件时,Unity会再次生成这些文件。所以我在做的是将平台切换到iOS并删除文件。我再次将平台切换到Android。它运作良好。我不知道这个程序是否正确。因为它不聪明。感谢您对我的友好支持。