Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The library doesn't work #37

Closed
KChernenko opened this issue Dec 25, 2014 · 12 comments
Closed

The library doesn't work #37

KChernenko opened this issue Dec 25, 2014 · 12 comments

Comments

@KChernenko
Copy link

Hello! I have some problems with the library.
Firstly, I've used gradle for adding yours library to my project:

compile 'com.github.fengdai:alertdialogpro-theme-material:0.2.0'
compile 'com.github.fengdai:alertdialogpro-core:0.2.0'

After that I've added into my style.xml:

<item name="alertDialogProTheme">@style/Theme.AlertDialogPro.Material</item>

Then I've used this example of code in my class:

AlertDialogPro.Builder builder = new AlertDialogPro.Builder(getContext());
builder.setIcon(R.drawable.icon).
setTitle("Title").
setMessage("Message Body").
setNeutralButton("Neutral", null).
setPositiveButton("Positive", null).
setNegativeButton("Negative", null).
show();

But I 'm getting an Exception when I'm trying to run the project:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Android\Releases\MealControl\app\build\intermediates\dex\debug --input-list=C:\Android\Releases\MealControl\app\build\intermediates\tmp\dex\debug\inputList.txt

Error Code: 2

Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)

When I'm trying to use version 0.1.0:

compile 'com.github.fengdai:alertdialogpro-theme-material:0.1.0'
compile 'com.github.fengdai:alertdialogpro-core:0.1.0'

I'm getting an Exception:

android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1131)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2327)
at android.content.res.Resources.getLayout(Resources.java:947)
at android.view.LayoutInflater.inflate(LayoutInflater.java:395)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:297)
at com.alertdialogpro.internal.AlertController.installContent(AlertController.java:193)
at com.alertdialogpro.AlertDialogPro.onCreate(AlertDialogPro.java:166)
at android.app.Dialog.dispatchOnCreate(Dialog.java:369)
at android.app.Dialog.show(Dialog.java:270)
at com.alertdialogpro.AlertDialogPro$Builder.show(AlertDialogPro.java:774)
at bitfrom.me.mealcontrol.views.RationFragment$1.onClick(RationFragment.java:53)
at com.gc.materialdesign.views.Button.makeCircle(Button.java:123)
at com.gc.materialdesign.views.ButtonRectangle.onDraw(ButtonRectangle.java:128)

When I leave only core:

compile 'com.github.fengdai:alertdialogpro-core:0.2.0'

I'm getting the same android.content.res.Resources$NotFoundException: Resource ID #0x0 Exception.

Thank you for attention.

@fengdai
Copy link
Owner

fengdai commented Dec 26, 2014

Hi @KChernenko, If you want a material design dialog, you only need to add:

compile 'com.github.fengdai:alertdialogpro-theme-material:0.2.0'

Doing like below (your first try) is also okay:

compile 'com.github.fengdai:alertdialogpro-theme-material:0.2.0'
compile 'com.github.fengdai:alertdialogpro-core:0.2.0'

I think the reason of your first exception is that you may include a nineoldandroids.jar lib to your project. If so, you should remove it. Because alertdialogpro-theme-material also depends on nineoldandroids. And Gradle can automatically resolve this dependency. You don't need to include it manually.

@fengdai
Copy link
Owner

fengdai commented Dec 26, 2014

Hi @KChernenko, How about now?

@KChernenko
Copy link
Author

Thank you for your answer! Yes, you are right - I use another library which used nineoldandroids. Therefore, there is a conflict. I'm trying to slove it.

@KChernenko
Copy link
Author

Hello @fengdai! I've sloved problem with the nineoldandroids library. But I still have android.content.res.Resources$NotFoundException: Resource ID #0x0 exception.
I've added compile 'com.github.fengdai:alertdialogpro-theme-material:0.2.0' dependency to my build.gradle.
And used <item name="alertDialogProTheme">@style/Theme.AlertDialogPro.Material</item> in my style.xml.

@fengdai
Copy link
Owner

fengdai commented Dec 29, 2014

Where did you use the alertDialogProTheme attribute. Can you post the code?

@KChernenko
Copy link
Author

Here is my style.xml:

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">#000000</item>
<item name="colorPrimaryDark">#000000</item>
<item name="colorAccent">#ffd10f21</item>
<item name="windowActionBar">false</item>
<item name="alertDialogProTheme">@style/Theme.AlertDialogPro.Material.Light</item>
</style>
</resources>

@fengdai
Copy link
Owner

fengdai commented Dec 29, 2014

Your code is correct. I don't know what the reason of this exception... Did you apply this style to <application> or <activity> in your AndroidManifest.xml?

@fengdai
Copy link
Owner

fengdai commented Dec 29, 2014

Oh. Did you use getContext() to supply a context? It should be an Activity.

@KChernenko
Copy link
Author

I use getActivity().getApplicationContext(), because I'm calling dialog from a fragment.

@fengdai
Copy link
Owner

fengdai commented Dec 30, 2014

Use getActivity().

@KChernenko
Copy link
Author

Yep, it works. Thank you very much!

@fengdai
Copy link
Owner

fengdai commented Dec 30, 2014

You're welcome.

@fengdai fengdai closed this as completed Dec 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants