Getting the below exception on the release version but working fine on debug build.
navigation version which is used
implementation "androidx.navigation:navigation-compose:2.5.3"
Fatal Exception: java.lang.IllegalArgumentException: navigation destination screen_dashboard is not a direct child of this NavGraph
at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.kt:72)
at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.kt:49)
at androidx.navigation.NavController.navigateInternal(NavController.kt:260)
at androidx.navigation.NavController.navigate(NavController.kt:1719)
at androidx.navigation.NavController.onGraphCreated(NavController.kt:1161)
at androidx.navigation.NavController.setGraph(NavController.kt:1086)
at androidx.navigation.NavController.setGraph(NavController.kt:100)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:118)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:67)
tried to update the proguard-rules.pro but still getting the exception
-keep class androidx.navigation.** { *; }
Related
i get this message error when i build my app in release mode.
No pending exception expected: java.lang.NoSuchFieldError: no "Ljava/lang/String;" field "amplitudes" in class "Llinc/com/amplituda/AmplitudaResultJNI;" or its superclasses.
But app correctly works on Dev build. What should i do?
gradle file
implementation 'com.github.lincollincol:amplituda:2.1.2'
proguard-rules.pro
-keep class linc.com.amplituda.** { *; }
Thanks
I have enabled Proguard and configured the rules
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
For GSON I used these rules
added my models to exceptions (-keep class my.package.model.** { *; })
Also used other rules for various libraries
I have this error -> Registering an InstanceCreator with Gson for this type may fix this problem.
the error occurred when switching to kotlin 1.6.0 and 1.6.10.
There is no error on version Kotlin 1.5.21!
Error (I have a bug only on Kotlin 1.6.0/1.6.10. There is no error on kotlin 1.5.21) --->
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.project.main, PID: 2943
java.lang.RuntimeException: Unable to invoke no-args constructor for class com.project.main.domain.entity.MyEntityClass. Registering an InstanceCreator with Gson for this type may fix this problem.
at com.google.gson.internal.c$e.a(SourceFile:228)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(SourceFile:212)
at com.google.gson.Gson.h(SourceFile:963)
at com.google.gson.Gson.j(SourceFile:928)
at com.google.gson.Gson.l(SourceFile:877)
at com.project.main.data.cache.converter.MyEntityClassConverter.toMyEntityClass(SourceFile:14)
at com.project.main.data.cache.dao.MyProjectDao_Impl$21.call(SourceFile:947)
at com.project.main.data.cache.dao.MyProjectDao_Impl$21.call(SourceFile:889)
at k1.c$a$a$a$a.invokeSuspend(SourceFile:128)
at uh.a.resumeWith(SourceFile:33)
at uk.z0.run(SourceFile:106)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.UnsupportedOperationException: Abstract class can't be instantiated! Class name: com.project.main.domain.entity.MyEntityClass
at com.google.gson.internal.l.a(SourceFile:120)
at com.google.gson.internal.l$a.c(SourceFile:49)
at com.google.gson.internal.c$e.a(SourceFile:225)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(SourceFile:212)
at com.google.gson.Gson.h(SourceFile:963)
at com.google.gson.Gson.j(SourceFile:928)
at com.google.gson.Gson.l(SourceFile:877)
at com.project.main.data.cache.converter.MyEntityClassConverter.toMyEntityClass(SourceFile:14)
at com.project.main.data.cache.dao.MyProjectDao_Impl$21.call(SourceFile:947)
at com.project.main.data.cache.dao.MyProjectDao_Impl$21.call(SourceFile:889)
at k1.c$a$a$a$a.invokeSuspend(SourceFile:128)
at uh.a.resumeWith(SourceFile:33)
at uk.z0.run(SourceFile:106)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
I have rules for this error.
-keep class com.project.main.domain.entity.MyEntityClass { ; }
but I'm adding the whole package
-keep class com.project.main.domain.entity.* { *; }
I also have all the other rules for GSON -> rules
#TypeConverter
fun toMyEntityClass(value: String): MyEntityClass =
gson.fromJson(value, object : TypeToken<MyEntityClass>() {}.type) //Error
I also tried to prescribe just one rule. The rule helps to run the project on 1.5.21 and works. But it doesn't work on 1.6.0 - 1.6.10. I don't want to create an Instance Creator. I have too many models and I will waste a lot of time.
-keep class ** { *; }
For any classes that interact with GSON you have to keep as follow :
-keep class "MODEL CLASSES"
for your issue you can do like :
-keep class com.project.main.domain.entity.** { *; }
It will keep all classes under the entity package.
The problem was solved by itself, after updating the libraries
gson 2.9.0
and kotlin 2.6.21
I didn't do anything, just updated to these versions
I haven't checked 1.6.0 and 1.6.10 works in tandem with gson 2.9.0 but gson didn't work with the previous release version
As a result, I upgraded Kotlin from 1.5.21 -> 1.6.21
I'm facing a crash after setting minifyEnabled true in my app/build.gradle.
implementation ('com.google.android.gms:play-services-location:17.0.0') {
exclude group:'com.android.support', module: 'support-v4'
}
implementation 'com.google.firebase:firebase-messaging:18.0.0'
implementation 'com.google.firebase:firebase-analytics:16.5.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
These are the Firebase libraries i use. This crash only arises if set minifyEnabled true.
I've tried enabling Multidex too, still unable to resolve the issue.
Crash log:
Process: proto.inventa.cct.com.inventaapp, PID: 30410
java.lang.NoSuchMethodError: No static method checkHandlerThread(Landroid/os/Handler;Ljava/lang/String;)V in class Lcom/google/android/gms/common/internal/Preconditions; or its super classes (declaration of 'com.google.android.gms.common.internal.Preconditions' appears in /data/app/proto.inventa.cct.com.inventaapp-hunIIikgxzy10RXjTw7TYA==/base.apk!classes4.dex)
at com.google.android.gms.common.internal.GmsClientEventManager.onConnectionSuccess(Unknown Source:20)
at com.google.android.gms.common.api.internal.zaaw.zab(Unknown Source:292)
at com.google.android.gms.common.api.internal.zaak.zaaq(Unknown Source:125)
at com.google.android.gms.common.api.internal.zaak.onConnected(Unknown Source:105)
at com.google.android.gms.common.api.internal.zabe.onConnected(Unknown Source:101)
at com.google.android.gms.common.api.internal.zaq.onConnected(Unknown Source:6)
at com.google.android.gms.common.internal.zaf.onConnected(Unknown Source:2)
at com.google.android.gms.common.internal.BaseGmsClient$PostInitCallback.handleServiceSuccess(Unknown Source:130)
at com.google.android.gms.common.internal.BaseGmsClient$zza.deliverCallback(Unknown Source:60)
at com.google.android.gms.common.internal.BaseGmsClient$zza.deliverCallback(Unknown Source:2)
at com.google.android.gms.common.internal.BaseGmsClient$CallbackProxy.deliverCallback(Unknown Source:51)
at com.google.android.gms.common.internal.BaseGmsClient$zzb.handleMessage(Unknown Source:270)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6977)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:528)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:910)
You'd need to keep these classes (there may be more):
-verbose
-keep,includedescriptorclasses class com.google.android.gms.** { *; }
-keep,includedescriptorclasses class com.google.android.gms.internal.** { *; }
-keep class com.google.android.gms.internal.** {com.google.android.gms.internal.** initialize(android.content.Context);}
-keep class com.google.android.gms.iid.** {com.google.android.gms.iid.** get(java.lang.String);}
-keep,includedescriptorclasses class com.google.android.** { *; }
You seem to have a dependency conflict.
play-services-location:17.0.0 depends on play-services-basement:17.0.0 and play-services-base:17.0.0
But
firebase-messaging:18.0.0 depends on play-services-basement:16.0.1
It may be that you have play-services-base:17.0.0 but play-services-basement:16.0.1, which won't work if play-services-base:17.0.0 is trying to use APIs introduced in play-services-basement:17.0.0.
Try updating your firebase-messaging dep to at least version 19.0.0, which does depend on play-services-basement:17.0.0.
Similarly, try updating firebase-analytics to at least version 17.0.0
Also consider checking out the strict version matcher plugin, which will give you an error message if a conflict is detected instead of Gradle's default strategy which just chooses one and if it makes the wrong choice may give odd error messages like this.
https://developers.google.com/android/guides/versioning#strict_version_matching.
Also I highly encourage against -keeping all of the com.google.android packages. That will keep all the code in the SDK, even the parts you don't use, drastically reducing how much benefit shrinking will give.
When invoking FirebaseFunctions.getInstance(FirebaseApp.getInstance()) an NPE is thrown. FirebaseApp.initializeApp(this); is called inside extended App class onCreate before calling any other firebase functionality.
This is the stacktrace:
Fatal Exception: java.lang.NullPointerException
at com.google.firebase.functions.internal.Preconditions.checkNotNull(Unknown Source:876)
at com.google.firebase.functions.FirebaseFunctions.<init>(Unknown Source:77)
at com.google.firebase.functions.FirebaseFunctions.getInstance(Unknown Source:141)
at com.google.firebase.functions.FirebaseFunctions.getInstance(Unknown Source:159)
The exception is thrown only when building the application with release configuration, this means the code gets obfuscated with DexGuard but all firebase classes have been excluded from the obfuscation, below my dexguard config:
...
-keep class com.google.** { *; }
-keep class android.** { *; }
-keep class com.firebase.** { *; }
-keep class com.android.** { *; }
...
I'm using:
com.google.firebase:firebase-functions:12.0.1 (also all other firebase libraries use the same version)
DexGuard version 8.1.15
classpath 'com.google.gms:google-services:4.0.1'
When using debug configuration everything works like charm, any idea how to solve this?
Already checked this similar question but it's outdated: Error with Firebase callable functions
EDIT - New configuration
I tried updating both DexGuard dependency and Firebase one with the ones below:
com.google.firebase:firebase-functions:16.1.1 (all other firebase and gms dependencies are updated to the latest one, except for play-services-ads that is 16.0.0)
DexGuard version 8.2.20
classpath 'com.google.gms:google-services:4.0.1'
This is the new stacktrace:
Fatal Exception: java.lang.NullPointerException: null reference
at com.google.firebase.functions.a.a.a(Unknown Source:30)
at com.google.firebase.functions.FirebaseFunctions.(Unknown Source:77)
at com.google.firebase.functions.FirebaseFunctions.getInstance(Unknown Source:141)
at com.google.firebase.functions.FirebaseFunctions.getInstance(Unknown Source:154)
For the ones who may face the same problem, it was caused by the "projectId" field being null when the FirebaseOptions were initialised by the sdk using FirebaseOptions.fromResource(Context) and the app was protected with DexGuard
FirebaseOptions {
applicationId = ***********************,
apiKeyapiKey = ***********************,
databaseUrl = ***********************,
gcmSenderId = ***********************,
storageBucket = ***********************,
projectId = null
}
The problem has been solved by adding the following line to the DexGuard config file:
-keepresources string/project_id
I updated my dex classes with amigo library (it's changing one apk for another apk with the same key and signature, all is working except JSOUP)
Error:
FATAL EXCEPTION: Thread-1567
Process: com.smedic.tubtub, PID: 26102
java.lang.ExceptionInInitializerError
at org.jsoup.nodes.Document$OutputSettings.(Document.java:372)
at org.jsoup.nodes.Document.(Document.java:19)
at org.jsoup.parser.TreeBuilder.initialiseParse(TreeBuilder.java:32)
at org.jsoup.parser.TreeBuilder.parse(TreeBuilder.java:42)
at org.jsoup.parser.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:56)
at org.jsoup.parser.Parser.parseInput(Parser.java:32)
at org.jsoup.helper.DataUtil.parseByteData(DataUtil.java:104)
at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:666)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:225)
at com.power.mati.VideosAdapter$4.run(VideosAdapter.java:177)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalStateException: Could not read resource
entities-xhtml.properties. Make sure you copy resources for
org.jsoup.nodes.Entities
at org.jsoup.nodes.Entities.load(Entities.java:289)
at org.jsoup.nodes.Entities.access$000(Entities.java:25)
at org.jsoup.nodes.Entities$EscapeMode.(Entities.java:48)
Any idea how to fix it?
I am using jars and maven, same situation.
I saw something similar and my solution is in proguard
-keep class org.jsoup.**
Update the library, use this one :
implementation 'org.jsoup:jsoup:1.13.1'
Your problem will be resolved...
add Jsoup library in libs folder and add -keep class org.jsoup.** in your proguard-rules.pro file.
Then it will work.
in my case, my problem is solved by turning minifyEnabled to false in the app's build.gradle, this will keep all classes in the final release apk.
android {
....
buildTypes {
...
release {
minifyEnabled false
}
}
}