我有一个使用分析和Theme.AppCompat.Dialog 的应用程序,因此,我需要 Xamarin.Android.Support.v7.AppCompat
该应用程序正常运作。
现在,我想添加Google广告。 "包nuget:Xamarin.GooglePlayServices.Ads"包括 Xamarin.Android.Support.v4 我做了另一个测试项目并且有效。
但是,当我将其添加到我的真实项目中时,我无法构建应用程序。
我有这个错误:" java.exe"退出代码1。 在输出中:
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2118,3): error MSB6006: "java.exe" exited with code 1.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
我阅读了我在论坛中看到的与该错误相关的所有内容,但我没有修复。有什么建议吗?
答案 0 :(得分:0)
@ Fran_gg7 是的!我发现了真正的原始问题和解决方案。
问题在于ProGuard。如果您因某种原因而不喜欢有效的ProGuard。 在我的情况下,如果我禁用ProGuard,该项目完美无缺。 但ProGuard应该通过减轻apk,代码混淆等方式来激活......
1。在您的Android项目中,您必须创建一个文件: proguard.txt
并编写此代码:
-keep class * extends java.util.ListResourceBundle {
protected java.lang.Object[][] getContents();
}
# Keep SafeParcelable value, needed for reflection. This is required to support backwards
# compatibility of some classes.
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
# Keep the names of classes/members we need for client functionality.
-keep @interface com.google.android.gms.common.annotation.KeepName
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
# Needed for Parcelable/SafeParcelable Creators to not get stripped
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
# Needed when building against pre-Marshmallow SDK.
-dontwarn android.security.NetworkSecurityPolicy
# Keep metadata about included modules.
-keep public class com.google.android.gms.dynamite.descriptors.** {
public <fields>;
}
# Keep the implementation of the flags api for google-play-services-flags
-keep public class com.google.android.gms.flags.impl.FlagProviderImpl {
public <fields>; public <methods>;
}
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**