Я пытаюсь включить оптимизацию кода и запутывание с R8 в моем приложении, но это заставляет его сбой.FATAL EXCEPTION: StickyMoteurThread
Process: com.tentaclestudio.fantasyracing.debug, PID: 11086
java.lang.ClassCastException: java.lang.String cannot be cast to com.tentaclestudio.fantasyracing.interfacesMoteurs.mouvements.TypeMouvement
at com.tentaclestudio.fantasyracing.interfacesMoteurs.donneesparties.CaseSelectionnableInformations.toJSON(SourceFile:613)
at com.tentaclestudio.fantasyracing.interfacesMoteurs.sortiesMoteurJeu.ResultatStepJeu.toJSON(SourceFile:1583)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyPartieDebugInfo.(SourceFile:255)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyPartie.addDebugInfos(SourceFile:3555)
at com.tentaclestudio.fantasyracing.moteurdejeu.CalculateurStepDeJeu.jouerStep(SourceFile:1606)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyMoteur.jouerStep(SourceFile:1814)
at com.tentaclestudio.fantasyracing.moteurdejeu.SynchronisateurPartieEnLigne.jouerPartieJusquaInteraction(SourceFile:850)
at com.tentaclestudio.fantasyracing.moteurdejeu.SynchronisateurPartieEnLigne.synchroniserPartieEnLigne(SourceFile:1020)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyMoteur.synchroniserPartieEnLigne(SourceFile:1465)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyMoteur.synchroniserDebutDePartie(SourceFile:1227)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyMoteurHandler.handleMessage(SourceFile:61)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:230)
< /code>
Связанный код: < /p>
JSONObject mvtAutorises = new JSONObject();
if (listeMouvementsAutorises != null) {
for (int i = 0; i < listeMouvementsAutorises.size(); i++) {
Pair infos = listeMouvementsAutorises.get(i);
mvtAutorises.put("mvtAutorise_" + i, infos.first.name() + " - " + infos.second.toString()); //
Listemouvementsautorises - это атрибут класса (ObjectBox): < /p>
@Convert(converter = ListeTypeEtDirectionMouvementConverter.class, dbType = String.class)
List
> listeMouvementsAutorises;
< /code>
преобразователь: < /p>
public static class ListeTypeEtDirectionMouvementConverter implements PropertyConverter {
@Override
public List convertToEntityProperty(String databaseValue) {
Type typeListe = new TypeToken(){}.getType();
Gson gson = new Gson();
List listeresultat = gson.fromJson(databaseValue, typeListe);
return listeresultat;
}
@Override
public String convertToDatabaseValue(List entityProperty) {
Type typeListe = new TypeToken(){}.getType();
Gson gson = new Gson();
return gson.toJson(entityProperty, typeListe);
}
}
< /code>
Я не понимаю ClasscastException, поскольку на линии нет кастинга, где происходит сбой.-keepclassmembers,allowoptimization enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
< /code>
Я также пытался добавить: < /p>
-keep enum com.tentaclestudio.fantasyracing.interfacesMoteurs.mouvements.TypeMouvement {
*;
}
< /code>
К сожалению, это не помогло.-printconfiguration /home/julien/Desktop/Brouillons/full-r8-config.txt
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE
##---------------Begin: proguard configuration for Gson ----------
-keepattributes Signature
-keepattributes *Annotation*
-dontwarn sun.misc.**
-keep class com.google.gson.examples.android.model.** { ; }
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName ;
}
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
##---------------End: proguard configuration for Gson ----------
# For enumeration classes
-keepclassmembers,allowoptimization enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep enum com.tentaclestudio.fantasyracing.interfacesMoteurs.mouvements.TypeMouvement {
*;
}
# Keep native method names
-keepclasseswithmembers,includedescriptorclasses,allowshrinking class * {
native ;
}
< /code>
и выдержка из build.gradle: < /p>
buildTypes {
release {
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ndk.debugSymbolLevel "SYMBOL_TABLE"
}
debug {
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix ".debug"
debuggable true
versionNameSuffix '.debug'
}
}
< /code>
edit: < /strong> < /p>
Я добавил несколько журналов тестирования: < /p>
В конвертер, внутри метода ConverttoEntityProperty (): < /p>
"ListEtypeEtDirectionMouvementConverter:" + DatabaseValue); < /p>
< /li>
< /ol>
Вывод журнала: < /p>
ListeTypeEtDirectionMouvementConverter: [{"first":"DeplacementYPuisX","second":{"directionMouvementHorizontal":"VersLaGauche","directionMouvementVertical":"VersLeBas","valeurPourBDD":11}},{"first":"DeplacementXPuisY","second":{"directionMouvementHorizontal":"VersLaGauche","directionMouvementVertical":"VersLeBas","valeurPourBDD":11}}]
< /code>
Здесь все выглядит хорошо. />mvtautorises.put("mvtautorise_ " + i, infos.first.name () +" - " + Infos.second.tostring ()); < /p>
< /li>
< /ol>
result: < /p>
< /ol>
< /p>
< /ol>
< /p>
< /ol>
< /p>
< /ol>
< /p>
< /li>
< /ol>
< /p>
< /li>
< /ol>
infos: DeplacementYPuisX, {directionMouvementHorizontal=VersLaGauche, directionMouvementVertical=VersLeBas, valeurPourBDD=11.0}
< /code>
На этом этапе все также хорошо.Log.d("DEBUG_JOL", "infos: " + infos.first.name() + ", " + infos.second);
< /code>
Затем исключение возникает во время выполнения этой строки.
То же самое, если используйте toString () вместо name () < /p>
Редактировать #2: < /strong> < /p>
После дальнейшего тестирования кажется, что проблема возникает. Струйный список не содержит тип (которые соответствуют значениям перечисления).
Снимок экрана возвращаемых значений преобразователя
Подробнее здесь: https://stackoverflow.com/questions/795 ... timization
Приложение Android сбои (classcastException) после оптимизации R8 ⇐ Android
Форум для тех, кто программирует под Android
-
Anonymous
1745484795
Anonymous
Я пытаюсь включить оптимизацию кода и запутывание с R8 в моем приложении, но это заставляет его сбой.FATAL EXCEPTION: StickyMoteurThread
Process: com.tentaclestudio.fantasyracing.debug, PID: 11086
java.lang.ClassCastException: java.lang.String cannot be cast to com.tentaclestudio.fantasyracing.interfacesMoteurs.mouvements.TypeMouvement
at com.tentaclestudio.fantasyracing.interfacesMoteurs.donneesparties.CaseSelectionnableInformations.toJSON(SourceFile:613)
at com.tentaclestudio.fantasyracing.interfacesMoteurs.sortiesMoteurJeu.ResultatStepJeu.toJSON(SourceFile:1583)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyPartieDebugInfo.(SourceFile:255)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyPartie.addDebugInfos(SourceFile:3555)
at com.tentaclestudio.fantasyracing.moteurdejeu.CalculateurStepDeJeu.jouerStep(SourceFile:1606)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyMoteur.jouerStep(SourceFile:1814)
at com.tentaclestudio.fantasyracing.moteurdejeu.SynchronisateurPartieEnLigne.jouerPartieJusquaInteraction(SourceFile:850)
at com.tentaclestudio.fantasyracing.moteurdejeu.SynchronisateurPartieEnLigne.synchroniserPartieEnLigne(SourceFile:1020)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyMoteur.synchroniserPartieEnLigne(SourceFile:1465)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyMoteur.synchroniserDebutDePartie(SourceFile:1227)
at com.tentaclestudio.fantasyracing.moteurdejeu.StickyMoteurHandler.handleMessage(SourceFile:61)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:230)
< /code>
Связанный код: < /p>
JSONObject mvtAutorises = new JSONObject();
if (listeMouvementsAutorises != null) {
for (int i = 0; i < listeMouvementsAutorises.size(); i++) {
Pair infos = listeMouvementsAutorises.get(i);
mvtAutorises.put("mvtAutorise_" + i, infos.first.name() + " - " + infos.second.toString()); //
Listemouvementsautorises - это атрибут класса (ObjectBox): < /p>
@Convert(converter = ListeTypeEtDirectionMouvementConverter.class, dbType = String.class)
List
> listeMouvementsAutorises;
< /code>
преобразователь: < /p>
public static class ListeTypeEtDirectionMouvementConverter implements PropertyConverter {
@Override
public List convertToEntityProperty(String databaseValue) {
Type typeListe = new TypeToken(){}.getType();
Gson gson = new Gson();
List listeresultat = gson.fromJson(databaseValue, typeListe);
return listeresultat;
}
@Override
public String convertToDatabaseValue(List entityProperty) {
Type typeListe = new TypeToken(){}.getType();
Gson gson = new Gson();
return gson.toJson(entityProperty, typeListe);
}
}
< /code>
Я не понимаю ClasscastException, поскольку на линии нет кастинга, где происходит сбой.-keepclassmembers,allowoptimization enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
< /code>
Я также пытался добавить: < /p>
-keep enum com.tentaclestudio.fantasyracing.interfacesMoteurs.mouvements.TypeMouvement {
*;
}
< /code>
К сожалению, это не помогло.-printconfiguration /home/julien/Desktop/Brouillons/full-r8-config.txt
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE
##---------------Begin: proguard configuration for Gson ----------
-keepattributes Signature
-keepattributes *Annotation*
-dontwarn sun.misc.**
-keep class com.google.gson.examples.android.model.** { ; }
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName ;
}
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
##---------------End: proguard configuration for Gson ----------
# For enumeration classes
-keepclassmembers,allowoptimization enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep enum com.tentaclestudio.fantasyracing.interfacesMoteurs.mouvements.TypeMouvement {
*;
}
# Keep native method names
-keepclasseswithmembers,includedescriptorclasses,allowshrinking class * {
native ;
}
< /code>
и выдержка из build.gradle: < /p>
buildTypes {
release {
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ndk.debugSymbolLevel "SYMBOL_TABLE"
}
debug {
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationIdSuffix ".debug"
debuggable true
versionNameSuffix '.debug'
}
}
< /code>
edit: < /strong> < /p>
Я добавил несколько журналов тестирования: < /p>
В конвертер, внутри метода ConverttoEntityProperty (): < /p>
"ListEtypeEtDirectionMouvementConverter:" + DatabaseValue); < /p>
< /li>
< /ol>
Вывод журнала: < /p>
ListeTypeEtDirectionMouvementConverter: [{"first":"DeplacementYPuisX","second":{"directionMouvementHorizontal":"VersLaGauche","directionMouvementVertical":"VersLeBas","valeurPourBDD":11}},{"first":"DeplacementXPuisY","second":{"directionMouvementHorizontal":"VersLaGauche","directionMouvementVertical":"VersLeBas","valeurPourBDD":11}}]
< /code>
Здесь все выглядит хорошо. />mvtautorises.put("mvtautorise_ " + i, infos.first.name () +" - " + Infos.second.tostring ()); < /p>
< /li>
< /ol>
result: < /p>
< /ol>
< /p>
< /ol>
< /p>
< /ol>
< /p>
< /ol>
< /p>
< /li>
< /ol>
< /p>
< /li>
< /ol>
infos: DeplacementYPuisX, {directionMouvementHorizontal=VersLaGauche, directionMouvementVertical=VersLeBas, valeurPourBDD=11.0}
< /code>
На этом этапе все также хорошо.Log.d("DEBUG_JOL", "infos: " + infos.first.name() + ", " + infos.second);
< /code>
Затем исключение возникает во время выполнения этой строки.
То же самое, если используйте toString () вместо name () < /p>
Редактировать #2: < /strong> < /p>
После дальнейшего тестирования кажется, что проблема возникает. Струйный список не содержит тип (которые соответствуют значениям перечисления).
Снимок экрана возвращаемых значений преобразователя
Подробнее здесь: [url]https://stackoverflow.com/questions/79586740/android-app-crashes-classcastexception-after-r8-optimization[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия