Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot access DialogStyle

After updating android-support library to 22.2.0 project stopped compiling.

error: cannot access DialogStyle
  class file for android.support.v4.app.DialogFragment$DialogStyle not found
  Consult the following stack trace for details.
  com.sun.tools.javac.code.Symbol$CompletionFailure: class file for android.support.v4.app.DialogFragment$DialogStyle not found

Can't find how to work around this issue.

Previously used version was 22.1.1

like image 754
Martynas Jurkus Avatar asked May 29 '15 10:05

Martynas Jurkus


3 Answers

@takoli's answer works in most cases but if you have other dependencies that silently include support-v4 or if you are too lazy to explicitly exclude support-v4 everywhere here is another solution.

compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:mediarouter-v7:22.2.0'
// Force stable version of support-v4
compile ('com.android.support:support-v4:22.1.1') {
    force = true
}

Update:

AndroidAnnotations released a new version 3.3.2 that resolves this issue. If you are using AndroidAnnotations update to 3.3.2 and use the 22.2.0 support libraries without forcing the old version of support-v4. For more information see this thread

like image 152
Justin Fiedler Avatar answered Dec 04 '22 18:12

Justin Fiedler


Here is a couple workarounds that worked for us:

Workaround 1 (some people see a NPE with this, some don't)

I just found a TEMPORARY workaround... till appcompat fixes this issue:

  1. Create the following package in your project src/main/java

android.support.v4.app

  1. Create the following new file:

DialogFragment$DialogStyle.java

  1. Contents

    package android.support.v4.app;

    // todo remove this file when fixed in appcompat (https://code.google.com/p/android/issues/detail?id=175086)

public @interface DialogFragment$DialogStyle { }

Workaround 2 (bit more ugly, but less potential for a build issue)

I found another work-around.... a bit more ugly... but has gotten us around this issue (including the NPE on the above work-around) till appcompat 22.2 is fixed.

  1. Create the following package in your project src/main/java

android.support.v4.app

  1. Copy the Google v4 FragmentDialog.java code

https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/v4/java/android/support/v4/app/DialogFragment.java

  1. Rename the class (to something like TempFragmentDialog). You will get a "Duplicate" class error if you don't rename the class.

  2. Any FragmentDialog, in your project, that has @Inject will need to extend your copy of the FragmentDialog (example: public class MyFragmentDialog extends TempFragmentDialog)

like image 20
Jeff Campbell Avatar answered Dec 04 '22 19:12

Jeff Campbell


Try this, it resolved my issue:

compile ('com.android.support:appcompat-v7:22.2.0') {
        exclude module: 'support-v4' }
compile ('com.android.support:recyclerview-v7:22.2.0') {
        exclude module: 'support-v4' }
compile ('com.android.support:cardview-v7:22.2.0') {
        exclude module: 'support-v4' }
compile ('com.android.support:design:22.2.0') {
        exclude module: 'support-v4' }
// and exclude support-v4 from other dependencies as well that might include it
// finally add it, but avoid version 22.2.0...
compile ('com.android.support:support-v4:22.1.1')

There is no need to manually add the support-v4 library to your libs directory, the last import ensures that the right version is included in your project.

BTW all of this workaround is not your fault, blame others :)

like image 35
goodKode Avatar answered Dec 04 '22 19:12

goodKode