Status Update
Comments
bi...@google.com <bi...@google.com> #2
sg...@google.com <sg...@google.com> #3
bi...@google.com <bi...@google.com> #4
bi...@google.com <bi...@google.com> #5
ga...@google.com <ga...@google.com> #6
Android Studio version: 0.8.12
buildToolsVersion 21.0.1
Gradle 1.11
ch...@google.com <ch...@google.com> #7
--set-max-idx-number=<value>
Unfortunately changing the default is not a solution since the linearAlloc limit can be reached at very different levels depending on the classes hierarchy and other criteria.
In addition for most applications, moving to multidex will only help to workaround the linearalloc limit for the installation. But the application will still crash against the same limit at execution. The only working use case where I know multidex can help with linearalloc is when the apk does not contains one application but distinct pieces running in separate process.
bi...@google.com <bi...@google.com>
bi...@google.com <bi...@google.com> #8
It's nice to know about that command line option. I do not see it in the output of 'dx --help', might be good to add that.
I'm not very familiar with the 'linearAlloc limit' issue outside of the context of the dexopt step. My sample app is able to run once the lower idx value is set, although I do not actually call into any of the library code that is bundled with the app. I assume it's undefined when/if the 'linearAlloc limit' will be hit in a large application on gb.
I'm a bit confused as to the platform compatibility of multidex given the 'linearAlloc limit' bug. What specific versions of Android are supported? The multidex code implies back to v4 (
bi...@google.com <bi...@google.com> #9
The linearalloc limit is reached when loading classes. At install time dexopt is loading all classes contained in the dex so it's facing the limit immediately. At execution the limit may be reached after some delay dependending of the usage you have of the packaged classes. If you face it at install time but not at execution, this means you never trigger the loading of some classes. In a real application those never loaded classes should have been shrinked away manually or by Proguard. The exception is when there are different groups of classes in the dex files used in separate process.
About multidex library supported versions I've merged recently a change to try to be clearer
The summary is that the library should work down to API 4 (Donut), but below ICS applications will probably be hit by the linearalloc limit
bi...@google.com <bi...@google.com> #10
dexOptions {
additionalParameters = ['--multi-dex', '--set-max-idx-number=40000']
}
sg...@google.com <sg...@google.com> #11
bi...@google.com <bi...@google.com> #14
fixed with change Iee631c0faa8ac1b32579732dfd82f96921082672
[Deleted User] <[Deleted User]> #15
How do we experience this function(Don't add ignorewarnings )at AGP 4.2.2.
I wish you provide the 4.2.3 version to support it.
ey...@gmail.com <ey...@gmail.com> #16
I just updated to 8.0.0 alpha and started getting these errors:
ERROR:R8: Missing class android.support.v4.app.FragmentActivity (referenced from: void leakcanary.internal.AndroidSupportFragmentDestroyWatcher.invoke(android.app.Activity))
Missing class android.support.v4.app.FragmentManager$FragmentLifecycleCallbacks (referenced from: void leakcanary.internal.AndroidSupportFragmentDestroyWatcher$fragmentLifecycleCallbacks$1.<init>(leakcanary.internal.AndroidSupportFragmentDestroyWatcher) and 2 other contexts)
Missing class android.support.v4.app.FragmentManager (referenced from: void leakcanary.internal.AndroidSupportFragmentDestroyWatcher.invoke(android.app.Activity))
Missing class androidx.asynclayoutinflater.view.AsyncLayoutInflater$OnInflateFinishedListener (referenced from: void com.mapbox.maps.ViewAnnotationManagerImpl.addViewAnnotation(int, com.mapbox.maps.ViewAnnotationOptions, androidx.asynclayoutinflater.view.AsyncLayoutInflater, kotlin.jvm.functions.Function1))
Missing class androidx.asynclayoutinflater.view.AsyncLayoutInflater (referenced from: void com.mapbox.maps.ViewAnnotationManagerImpl.addViewAnnotation(int, com.mapbox.maps.ViewAnnotationOptions, androidx.asynclayoutinflater.view.AsyncLayoutInflater, kotlin.jvm.functions.Function1) and 1 other context)
Missing class androidx.work.multiprocess.RemoteListenableWorker (referenced from: leakcanary.internal.RemoteHeapAnalyzerWorker)
Do I just need to add the dontwarn
commands that are generated to my config, or should I report these somewhere (here, or the library that is mentioned)?
sg...@google.com <sg...@google.com> #17
The missing classes are from leakcanary
(Square) and com.mapbox.maps
(mapbox). If you don't have any control over these libraries adding the -dontwarn
is one option. Another option will be to add more dependencies to your project with the missing classes. The missing classes are in code which R8 did not remove, but of course that can still be code which will never be hit at runtime.
I suggest that you also report this to the library authors, so they can update their libraries to avoid consumers getting these errors. On the library side they can either 1) add more dependencies or 2) add the -dontwarn
to the library consumer keep rules. There can be good reasons for a library having missing classes if it has code which checks for different supported dependencies. E.g. leakcanary might work with both old support library and new Jetpack (androidx) libraries, so you chose the dependency and leakcanary will work with both.
Description
For AGP 8.0 we should remove the injection of -ignorewarnings , and make missing classes an error.