Fixed
Status Update
Comments
am...@google.com <am...@google.com>
ot...@gmail.com <ot...@gmail.com> #2
[Comment deleted]
[Deleted User] <[Deleted User]> #3
[Comment deleted]
[Deleted User] <[Deleted User]> #4
Also of note is the adb error when trying to install bad APK: INSTALL_FAILED_DEXOPT
ma...@gmail.com <ma...@gmail.com> #5
load dex files over 5Gb. -> load dex files over 5Mb.
da...@loylap.com <da...@loylap.com> #6
Same here! Looking forward to a solution :)
Android Studio version: 0.8.12
buildToolsVersion 21.0.1
Gradle 1.11
Android Studio version: 0.8.12
buildToolsVersion 21.0.1
Gradle 1.11
am...@google.com <am...@google.com> #7
There is already an option in dx allowing to force generation of smaller dex files:
--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.
--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.
am...@google.com <am...@google.com> #8
Thanks for your quick response.
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 (https://android.googlesource.com/platform/frameworks/multidex/+/master/library/src/android/support/multidex/MultiDex.java ) but it would seem that ICS is the earliest supported platform. Is this correct?
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 (
lo...@gmail.com <lo...@gmail.com> #9
The option is not documented in --help because it was designed for testing and we're not capable of documenting a reliable way to use it as a workaround of the linearalloc limit.
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 clearerhttps://android-review.googlesource.com/#/c/108023/
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
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
ro...@gmail.com <ro...@gmail.com> #10
for Android studio use:
dexOptions {
additionalParameters = ['--multi-dex', '--set-max-idx-number=40000']
}
dexOptions {
additionalParameters = ['--multi-dex', '--set-max-idx-number=40000']
}
ro...@gmail.com <ro...@gmail.com> #11
I still have this issue and it's driving me nuts
ty...@gmail.com <ty...@gmail.com> #14
This my layout file.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android "
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:paddingTop="24dp"
android:id="@+id/action_button_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/recycler_view"
>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/gray_divider"/>
<Button
android:clickable="true"
android:id="@+id/more_options_button"
style="@style/BigWhiteButton"
android:text="@string/more_options"
android:layout_height="52dp"
/>
</LinearLayout>
</RelativeLayout>
This is how I configure the BottomSheetDialog
@OnClick(R.id.invite_button)
public void onInviteButtonClicked() {
final View view = LayoutInflater.from(getContext()).inflate(R.layout.sharing_options, null);
Button moreSharingOptionsButton = (Button) view.findViewById(R.id.more_options_button);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
GridLayoutManager manager = new GridLayoutManager(getContext(), 3);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(manager);
recyclerView.setAdapter(new SharingOptionsAdapter(getContext(),installedPreferredApps));
moreSharingOptionsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, getString(R.string.invite_your_friends)));
}
});
bsd.setContentView(view);
bsd.show();
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:paddingTop="24dp"
android:id="@+id/action_button_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/recycler_view"
>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/gray_divider"/>
<Button
android:clickable="true"
android:id="@+id/more_options_button"
style="@style/BigWhiteButton"
android:text="@string/more_options"
android:layout_height="52dp"
/>
</LinearLayout>
</RelativeLayout>
This is how I configure the BottomSheetDialog
@OnClick(R.id.invite_button)
public void onInviteButtonClicked() {
final View view = LayoutInflater.from(getContext()).inflate(R.layout.sharing_options, null);
Button moreSharingOptionsButton = (Button) view.findViewById(R.id.more_options_button);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
GridLayoutManager manager = new GridLayoutManager(getContext(), 3);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(manager);
recyclerView.setAdapter(new SharingOptionsAdapter(getContext(),installedPreferredApps));
moreSharingOptionsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, getString(R.string.invite_your_friends)));
}
});
bsd.setContentView(view);
bsd.show();
}
ul...@gmail.com <ul...@gmail.com> #15
Try following workaround (with support library v23.2.0):
public class CustomBottomSheetDialog extends BottomSheetDialog {
public CustomBottomSheetDialog(final Context context) {
super(context);
}
public CustomBottomSheetDialog(final Context context, final int theme) {
super(context, theme);
}
protected CustomBottomSheetDialog(final Context context, final boolean cancelable, final OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
@Override
public void show() {
final View sheetView = findViewById(R.id.design_bottom_sheet);
final CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) sheetView.getLayoutParams();
final BottomSheetBehavior behavior = (BottomSheetBehavior) layoutParams.getBehavior();
super.show();
sheetView.post(new Runnable() {
@Override
public void run() {
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
}
}
public class CustomBottomSheetDialog extends BottomSheetDialog {
public CustomBottomSheetDialog(final Context context) {
super(context);
}
public CustomBottomSheetDialog(final Context context, final int theme) {
super(context, theme);
}
protected CustomBottomSheetDialog(final Context context, final boolean cancelable, final OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
@Override
public void show() {
final View sheetView = findViewById(R.id.design_bottom_sheet);
final CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) sheetView.getLayoutParams();
final BottomSheetBehavior behavior = (BottomSheetBehavior) layoutParams.getBehavior();
super.show();
sheetView.post(new Runnable() {
@Override
public void run() {
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
}
}
[Deleted User] <[Deleted User]> #16
This previous solution fails with "java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.WeakReference.get()' on a null object reference" because "mViewRef" in "BottomSheetBehaviour" is null.
Is there any way to set initial state of BottomSheetDialog to "BottomSheetBehavior.STATE_EXPANDED" ?
No hack worked for me so far, and I tried pretty much every one I found.
Is there any way to set initial state of BottomSheetDialog to "BottomSheetBehavior.STATE_EXPANDED" ?
No hack worked for me so far, and I tried pretty much every one I found.
ng...@gmail.com <ng...@gmail.com> #17
This is what's working for me (23.2.0):
public class ExpandedBottomSheetDialog extends BottomSheetDialog {
public ExpandedBottomSheetDialog(@NonNull Context context) {
super(context);
}
protected ExpandedBottomSheetDialog(@NonNull Context context, boolean cancelable, OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
public ExpandedBottomSheetDialog(@NonNull Context context, @StyleRes int theme) {
super(context, theme);
}
@Override
public void show() {
super.show();
View view = findViewById(R.id.design_bottom_sheet);
view.post (() -> {
BottomSheetBehavior behavior = BottomSheetBehavior.from(view);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
});
}
}
public class ExpandedBottomSheetDialogFragment extends BottomSheetDialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new ExpandedBottomSheetDialog(getActivity(), getTheme());
}
}
public class ExpandedBottomSheetDialog extends BottomSheetDialog {
public ExpandedBottomSheetDialog(@NonNull Context context) {
super(context);
}
protected ExpandedBottomSheetDialog(@NonNull Context context, boolean cancelable, OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
public ExpandedBottomSheetDialog(@NonNull Context context, @StyleRes int theme) {
super(context, theme);
}
@Override
public void show() {
super.show();
View view = findViewById(R.id.design_bottom_sheet);
BottomSheetBehavior behavior = BottomSheetBehavior.from(view);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
});
}
}
public class ExpandedBottomSheetDialogFragment extends BottomSheetDialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new ExpandedBottomSheetDialog(getActivity(), getTheme());
}
}
ra...@gmail.com <ra...@gmail.com> #18
Same issue found.
ar...@gmail.com <ar...@gmail.com> #19
I tried https://code.google.com/p/android/issues/detail?id=201793#c18 and it worked actually. But it has a drawback. When you change something in the bottom sheet when user is interacting, the bottom sheet is not redrawn.
sw...@gmail.com <sw...@gmail.com> #20
public class ExpandedBottomSheetDialog extends BottomSheetDialog {
public ExpandedBottomSheetDialog(@NonNull Context context) {
super(context);
}
protected ExpandedBottomSheetDialog(@NonNull Context context, boolean cancelable, OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
public ExpandedBottomSheetDialog(@NonNull Context context, @StyleRes int theme) {
super(context, theme);
}
@Override
public void show() {
super.show();
final View view = findViewById(R.id.design_bottom_sheet);
view.post (new Runnable() {
@Override
public void run() {
BottomSheetBehavior behavior = BottomSheetBehavior.from(view);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
}
}
this is the actual code that helped me
public ExpandedBottomSheetDialog(@NonNull Context context) {
super(context);
}
protected ExpandedBottomSheetDialog(@NonNull Context context, boolean cancelable, OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
public ExpandedBottomSheetDialog(@NonNull Context context, @StyleRes int theme) {
super(context, theme);
}
@Override
public void show() {
super.show();
final View view = findViewById(R.id.design_bottom_sheet);
@Override
public void run() {
BottomSheetBehavior behavior = BottomSheetBehavior.from(view);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
});
}
}
this is the actual code that helped me
me...@gmail.com <me...@gmail.com> #21
The issues can still be reproduced in material:1.0.0 - in ladscape tablet, you don't get it fully opened, user needs to drag it up.
ng...@gmail.com <ng...@gmail.com> #22
error: package android.support.design.widget does not exist
import android.support.design.widget.BottomSheetDialog;
import android.support.design.widget.BottomSheetDialog;
Description
"While BottomSheetBehavior captures the persistent bottom sheet case, this release also provides a BottomSheetDialog and BottomSheetDialogFragment to fill the modal bottom sheets use case. Simply replace AppCompatDialog or AppCompatDialogFragment with their bottom sheet equivalents to have your dialog styled as a bottom sheet."
So I changed my AppCompatDialog to BottomSheetDialog:
package my.package.ui.dialog;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.BottomSheetDialog;
import my.package.R;
public class AccountActionsDialog extends BottomSheetDialog {
public AccountActionsDialog(Context context) {
super(context);
if (context instanceof Activity) {
setOwnerActivity((Activity) context);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutInflater().inflate(R.layout.dialog_account_actions, null));
}
}
Here is my layout file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff0000"
android:padding="16dp"
android:text="Delete account"
android:textColor="#ffffff" />
</LinearLayout>
Then I use the following code in my Activity:
new AccountActionsDialog(this).show();
My screen becomes dimmed but the content of my dialog is not visible. It works fine when I use AppCompatDialog instead.
I've attached a sample project which demonstrates this behavior.
Device: Nexus 5X