Unity proguard: сбой при выполнении задачи ': transformClassesAndResourcesWithProguardForRelease' - PullRequest
0 голосов
/ 11 мая 2019

Я использую Unity 2018.1.6f1 с сервисами Google Play и Startapp SDK. Теперь мне нужно интегрировать Admob. Но я не могу сделать сборку.

Я переключился на Proguard в настройках сборки, так как столкнулся с ограничением DEX, и это было рекомендовано Admob.

Фрагмент консольного сообщения Unity:

stderr[
Note: there were 269 duplicate class definitions.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task 
':transformClassesAndResourcesWithProguardForRelease'.

А потом длинный список Примечание: дублированное определение класса программы

Как мне изменить файлы 'mainTemplate.gradle' или 'proguard-user.txt', чтобы сделать сборку? Или я?

1 Ответ

0 голосов
/ 11 мая 2019

при сборке для выпуска с включенным minify вам нужно поместить исключения в файл proguard.Эти исключения полностью зависят от реализаций, которые вы используете в файле Gradle сборки приложения.Например, эта реализация:

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'

//added these 2 lines to remove All com.android.support libraries must use the exact
// same version specification warning; from 26 to 28
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'

implementation 'com.google.android.gms:play-services-maps:16.1.0'

//implementation 'com.google.android.gms:play-services-location:16.0.0'
//implementation 'com.google.android.gms:play-services-places:16.0.0'

implementation 'com.google.android.libraries.places:places-compat:1.1.0'

// Google
//implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'


// Firebase
implementation 'com.google.firebase:firebase-analytics:16.3.0'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-config:16.1.3'
implementation 'com.google.firebase:firebase-appindexing:17.1.0'
implementation 'com.google.firebase:firebase-crash:16.2.1'

implementation 'com.google.android.gms:play-services-appinvite:16.1.0'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.android.gms:play-services-ads:17.1.3'


// Firebase UI
implementation 'com.firebaseui:firebase-ui-database:3.0.0'
implementation 'de.hdodenhof:circleimageview:1.3.0'

// firebase needs this needs to be version 1.1.1 firebase depends on
// a mismatch - 1.0.0 & 1.1.1
implementation 'android.arch.lifecycle:extensions:1.1.1'

// retrofit, gson
implementation 'com.squareup.okio:okio:1.13.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'


testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

implementation 'com.github.amlcurran.showcaseview:library:5.4.3'

//from the quick start
implementation 'com.google.android.gms:play-services-auth:16.0.1'

implementation('com.google.api-client:google-api-client-android:1.25.0') {
    exclude group: 'org.apache.httpcomponents'
}

implementation('com.google.apis:google-api-services- 
sheets:v4-rev553-1.25.0') {
    exclude group: 'org.apache.httpcomponents'
}
implementation "org.jetbrains.kotlin:kotlin-stdlib- 
jdk7:$kotlin_version"

}

Это необходимо в файле proguard для создания релиза:

 # my stuff below
 -dontnote retrofit2.Platform
 # Platform used when running on Java 8 VMs. Will not be 
  used at runtime.
 -dontwarn retrofit2.Platform$Java8
 # Retain generic type information for use by reflection by 
 converters and adapters.
 #-keepattributes Signature
 # Retain declared checked exceptions for use by a Proxy 
 instance.
 #-keepattributes Exceptions

 -dontwarn okio.**

 # Needed by google-api-client to keep generic types and 
 @Key annotations accessed via reflection
 -keepclassmembers class * {
 @com.google.api.client.util.Key <fields>;
 }

 #-keepattributes 
 Signature,RuntimeVisibleAnnotations,AnnotationDefault

 #-dontnote org.apache.**
 #-dontwarn java.lang.**

 -dontwarn com.google.errorprone.annotations.**

 -keep public class com.google.common.** { public *; }
 -dontwarn com.google.common.**

 -dontnote android.net**
 -dontwarn com.google.firebase.appindexing.internal.**

Итак, нужно найти дубликаты и записи в журнале.и добавьте запись proguard для каждого предупреждения в журнале

...