Code Monkey home page Code Monkey logo

Comments (43)

gregkorossy avatar gregkorossy commented on June 2, 2024

What do your gradle files look like?

from android-support-preference-v7-fix.

proninyaroslav avatar proninyaroslav commented on June 2, 2024

I don't quite understand the question. I use the last version of gradle, which download Studio. I tried a sample app, but there I encountered the same problem.

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

I'm curious about your targetSdkVersion, the build tool version and the dependencies. This problem happens if you use different versions of dependent libraries and/or the build tool is old (and buggy, like the v23).

from android-support-preference-v7-fix.

proninyaroslav avatar proninyaroslav commented on June 2, 2024
compileSdkVersion 24
buildToolsVersion "24.0.1"
targetSdkVersion 24

dependencies:

compile 'com.github.aakira:expandable-layout:1.5.1@aar'
compile 'com.github.clans:fab:1.6.3'
def ANDROID_SUPPORT_VERSION='24.2.0'
compile 'com.android.support:support-v4:' + ANDROID_SUPPORT_VERSION
compile 'com.android.support:appcompat-v7:' + ANDROID_SUPPORT_VERSION
compile 'com.android.support:design:' + ANDROID_SUPPORT_VERSION
compile 'com.android.support:cardview-v7:' + ANDROID_SUPPORT_VERSION

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

Even with your dependencies copied, it works perfectly for me. Try clean & rebuild. Also, check if you have any appcompat .jar files in your libs folder.

from android-support-preference-v7-fix.

proninyaroslav avatar proninyaroslav commented on June 2, 2024

I cleared project and .gradle dir, but it didn't help. Also I tried a sample app, but there I encountered the same problem.

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

What's your Android Studio and gradle version?

from android-support-preference-v7-fix.

proninyaroslav avatar proninyaroslav commented on June 2, 2024

Studio 2.1.3, gradle 3.0 (prev. 2.14.1), gradle Android plugin 2.1.3

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

Is this a library or an application project?

from android-support-preference-v7-fix.

proninyaroslav avatar proninyaroslav commented on June 2, 2024

This is an app.

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

Well, I'm out of ideas. It seems to be working for everyone with probably the same configuration. If there are no .jar files in your lib or libs folder, nothing I can do. This seems like a local problem. Try copying only the sources (and resources of course) to a new project, then gradually upgrade the .gradle files to see, what causes the problem.

from android-support-preference-v7-fix.

proninyaroslav avatar proninyaroslav commented on June 2, 2024

Ok, I'll try to run it on another computer.

from android-support-preference-v7-fix.

anpaza avatar anpaza commented on June 2, 2024

Same problem happens here.
Duplicate annotation 'android.support.annotation.IntDef'; for signature: 'com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers divPrefFlags' in the file /home/zap/electronics/projects/xpd/android/app/build/intermediates/exploded-aar/com.takisoft.fix/preference-v7/25.0.1.0/annotations.zip!/com/takisoft/fix/support/v7/preference/annotations.xml

And since it's a opensource project, I can give you a direct link to the whole project:
https://sourceforge.net/p/xpd-ebike/code/HEAD/tree/trunk/android/

Just open it in Android Studio, and this message appears in the status bar.

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

@anpaza The problem is that you use different versions of support library components. I navigated into your app/build.gradle file and there are a couple problems. First of all, to use v25.x.y, you need buildToolsVersion and compileSdkVersion set to 25 or above. Another problem is that you should use the same version of support lib components and since the current version of the library fix is meant for 25.0.1, instead of

compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'

use

compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:support-v4:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'

Please do keep in mind that I'll make the 25.1.0 compatible version available soon, so if you want to upgrade to that later, you'll need to change the other components' support lib version too.

from android-support-preference-v7-fix.

anpaza avatar anpaza commented on June 2, 2024

Thank you for help! This is my first android program ever, so no wonder I still do childish errors :)
I disabled automatic updates because it had no sources for API Level 25. Now it has.
It took a while to update & test, but everything seems fine now.

from android-support-preference-v7-fix.

Mygod avatar Mygod commented on June 2, 2024

from android-support-preference-v7-fix.

anpaza avatar anpaza commented on June 2, 2024

I was wrong. Still get same error from time to time, can't understand what causes it, but happens pretty often.
Same message:

0:15:55 Duplicate annotation 'android.support.annotation.IntDef'; for signature: 'com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers divPrefFlags' in the file /home/zap/electronics/projects/xpd/android/xpd/build/intermediates/exploded-aar/com.takisoft.fix/preference-v7/25.0.1.0/annotations.zip!/com/takisoft/fix/support/v7/preference/annotations.xml: Duplicate annotation 'android.support.annotation.IntDef'; for signature: 'com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers divPrefFlags' in the file /home/zap/electronics/projects/xpd/android/xpd/build/intermediates/exploded-aar/com.takisoft.fix/preference-v7/25.0.1.0/annotations.zip!/com/takisoft/fix/support/v7/preference/annotations.xml

Switched all libs to 25.0.1, but doesn't help. The updated sources are still available by the link above.

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

Did you try cleaning the project before building? Might be some residual files in cache.

from android-support-preference-v7-fix.

anpaza avatar anpaza commented on June 2, 2024

I tried to clean the project, then restart the Android Studio and the error appears again.
I even tried to remove 'build' subdirectories from everywhere in project tree (while Android Studio was not running). Nothing helps. I get exception in "Android Support" IDE plugin with the following content:

The Comments tab:
Duplicate annotation 'android.support.annotation.IntDef' [...] same like above

The Details tab:
Duplicate annotation 'android.support.annotation.IntDef'; for signature: 'com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers divPrefFlags' in the file /home/zap/electronics/projects/xpd/android/xpd/build/intermediates/exploded-aar/com.takisoft.fix/preference-v7/25.0.1.0/annotations.zip!/com/takisoft/fix/support/v7/preference/annotations.xml
java.lang.Throwable
at com.intellij.diagnostic.LogMessageEx.error(LogMessageEx.java:136)
at com.intellij.codeInsight.ExternalAnnotationsManagerImpl.duplicateError(ExternalAnnotationsManagerImpl.java:709)
at com.intellij.codeInsight.BaseExternalAnnotationsManager$DataParsingSaxHandler.endElement(BaseExternalAnnotationsManager.java:468)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
...

The Attachment tab:
(the content of your annotations.xml from com.takisoft.fix/preference-v7/25.0.1.0/annotations.zip)

Unfortunately, I know little about annotations, so I can't understand what's wrong here :(
You can try to download the project from the link above (it does not need any extras), I think the problem will reproduce.

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

I downloaded a snapshot from your repo, extracted it, then Android Studio -> File -> New -> Import project..., and selected the android folder. After finishing the import, I opened up an API 23 emulator and hit run, and it did run. So I can't reproduce the error, sorry.

What version of Java do you use?
(Open the Terminal tab inside Android Studio and type javac -version.)

from android-support-preference-v7-fix.

anpaza avatar anpaza commented on June 2, 2024

Android Studio 2.2.3
javac 1.8.0_111

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

Is that for javac -version (mind the c at the end)?
Anyways, it works for me with your project. What if you try and import it as a new project from the version controlled source?

from android-support-preference-v7-fix.

anpaza avatar anpaza commented on June 2, 2024

The above is result of "javac --version" command. My OS is Fedora 25.
javac is a symlink to the javac binary from package java-1.8.0-openjdk-devel-1.8.0.111-3.b16.fc24.x86_64


Yes, I managed to reproduce the problem with a fresh svn checkout. But the problem appeared only after some manipulations, not instantly.
The following sequence did it:

  1. Checkout a fresh copy somewhere
  2. Run Android Studio, open it. It says gradle is not configure, I hit OK.
  3. Open some source, I open xpd/ActivityMain.
  4. Build -> Clean Project
  5. Quit Android Studio
  6. Launch Android Studio, wait until it finishes reloading everything
  7. Build -> Rebuild Project
  8. Quit Android Studio
  9. Relaunch Android Studio
  10. Repeat steps 4-10 a few times, and the problem appears during project load after Android Studio launch. A popup shows in top-right corner, and a red exclamation sign icon flashes to the left of "Event Log" button in lower-right corner.

After that the error happens any time you reload Android Studio or do clean, rebuild etc...

Well, it looks like this is an Android Studio and/or Gradle bug, so I think we should drop this...

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

Interesting. I met the same problem earlier in a different project, but it was caused by the different versions of the support libraries resulting in multiple versions of the same class, so the Android Studio (or rather Gradle) couldn't merge them.

One thing you can do is to check out this project and modify the PreferenceFragmentCompatDividers class so that you remove the IntDef part. It has only semantical meaning but it helps one in the IDE by allowing auto-complete on the divider settings. Then you can add the dependency to that project instead of the jcenter one. Of course, this also means that you'd have to do the update / merge process when a new version is available.

Or you can try something like this with the configuration exclusions, but I'm not sure it would fix it and not just mess up the whole thing.

from android-support-preference-v7-fix.

anpaza avatar anpaza commented on June 2, 2024

I understand I can patch your library to remove annotations, but usually I don't like such 'fixes'.

I also tried the suggestion with Gradle, notably I've changed the line requesting compiling of com.takisoft.fix to:

compile ('com.takisoft.fix:preference-v7:25.0.1.0') {
exclude module: 'support-annotations'
}

but unfortunately, this does not work. The above was done by intuition and some reading of Gradle docs, but Gradle is still pretty much dark magic to me :(

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

@anpaza What happens if you try File -> Invalidate Caches / Restart... ?

from android-support-preference-v7-fix.

BuhTigRunner avatar BuhTigRunner commented on June 2, 2024

I have the same problem. Android Studio 2.2.3.
File -> Invalidate Caches / Restart - did't help

classpath 'com.android.tools.build:gradle:2.2.3'

compileSdkVersion 25
buildToolsVersion '25.0.2'

Duplicate annotation 'android.support.annotation.IntDef'; for signature: 'com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers divPrefFlags' in the file /home/AndroidStudioProjects/constraint-layout/ContactSearch/app/build/intermediates/exploded-aar/com.takisoft.fix/preference-v7/25.1.0.1/annotations.zip!/com/takisoft/fix/support/v7/preference/annotations.xml: Duplicate annotation 'android.support.annotation.IntDef'; for signature: 'com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers divPrefFlags' in the file /home/denis/AndroidStudioProjects/constraint-layout/ContactSearch/app/build/intermediates/exploded-aar/com.takisoft.fix/preference-v7/25.1.0.1/annotations.zip!/com/takisoft/fix/support/v7/preference/annotations.xml

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

@BuhTigRunner Could you create a new project (if yours is not public) that reproduces the problem? I couldn't reproduce it, so I can't really come up with a fix...
Also, what operating system do you use?

from android-support-preference-v7-fix.

BuhTigRunner avatar BuhTigRunner commented on June 2, 2024

@Gericop In new project work fine. But in my project - error.

But i fix it adding compile 'com.android.support:design:25.1.0'
Without this - Error: No resource found that matches the given name (at 'layout_behavior' with value '@string/appbar_scrolling_view_behavior')

Sorry to trouble you, it seems the problem is not the library, and my scattering

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

@BuhTigRunner Are you sure? If you check the build.gradle file of both the sample app and the lib itself, none of them includes it as a dependency, yet the sample app works perfectly. Do you have compile "com.android.support:appcompat-v7:25.1.0" in your build.gradle?

from android-support-preference-v7-fix.

BuhTigRunner avatar BuhTigRunner commented on June 2, 2024

@Gericop Sorry to trouble you, it seems the problem is not the library, and my scattering. When I adding your lib, casually replaced compile 'com.android.support:design:25.1.0'

from android-support-preference-v7-fix.

phillat avatar phillat commented on June 2, 2024

I'm having the same problem but my IDE doesn't crash though. I have to mention that I am new to android development and working with very limited resources. Developing on a dell inspiron mini 1018 (can't run an emulator) and testing on huawei y220 (api 10). Also I have to mention that when I open PreferenceFragmentCompatDividers.java I get "Library source does not match the bytecode for class PreferenceFragmentCompatDividers" at the top of the editor. To keep my message shorter here is summary of my environment:

  1. javac version 1.8.0_102
  2. Android Studio 2.2.3
  3. Compile SDK 25
  4. Build tools 25.0.2
  5. Gradle version 2.14.1
  6. Gradle plugin 2.2.3

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
// compile 'com.android.support:design:25.1.0'
compile 'com.takisoft.fix:preference-v7:25.1.0.1'
}
Things I tried:

  1. Cleaning and rebuilding project
  2. Invalidating caches and restarting (error goes away but reappears after building and running)
  3. Included 'com.android.support:design:25.1.0' since it worked for @BuhTigRunner

I'm learning from the udacity-google partnership courses specifically taking the android basics networking course and working on the quake report app. I can't provide you with access to my project because currently I'm experiencing slow and flaky internet connection but here is a link to the follow-up project from the course quake report app. Everything is pretty much the same with the exception of the following:

  1. Minimum sdk is set to 10 (obviously)
  2. Using AsyncTaskLoader from v4 support library
  3. Using PreferenceFragmentCompat from your library in my settings activity:

Working with the limited resources available to me it's not just that I want to include the support library and your library but I need it because without it I couldn't even test the app on my phone. Any help would be greatly appreciated.

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

@phillat What operating system do you use?

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

Okay, so what I think might go wrong here is that the divider settings use two annotations: one for the base and one for the flags. Both of these annotations are annotated with @IntDef. However, repeating annotations were introduced to Java only in the 8th version and I think that gradle / javac messes up something with this. I'm gonna merge the two together (which means some semantical checks will not be available) and hope for the best.

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

Released a new version: v25.1.0.2. Please, check if the problem still exists (make sure you clear the project; also check if gradle really clears build/intermediates/exploded-aar/com.takisoft.fix).

from android-support-preference-v7-fix.

phillat avatar phillat commented on June 2, 2024

First, thank you for your quick response. I'm using windows 7 SP 1. I will be updating to v25.0.2 as soon as my internet connection is restored to normal it's still very slow. Also, does using build->clean clear the project or should I invalidate the cache and restart? I will keep you updated once I download the new version.

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

@phillat Make sure you update to 25.1.0.2. Build -> clean should be enough.

from android-support-preference-v7-fix.

phillat avatar phillat commented on June 2, 2024

One more thing, when I included a switch in my settings activity (just experimenting) using SwitchPreferenceCompat. The switch_thumb is not properly centered on the switch_track. I installed the app on a couple of my friends' phones ranging from api 16 - api 21 and it looks great and perfectly aligned like it's supposed to. I don't have access to another phone running api 10 on which to test the app in order to be sure if it's got to do with my phone or not. But from your readme you said you tested the library on api 10, did you notice anything like that?

from android-support-preference-v7-fix.

phillat avatar phillat commented on June 2, 2024

Thank you, I will update the library ASAP and get back to you.

from android-support-preference-v7-fix.

gregkorossy avatar gregkorossy commented on June 2, 2024

@phillat Could you open a new issue with a screenshot attached? I'm not sure about the problem.

from android-support-preference-v7-fix.

phillat avatar phillat commented on June 2, 2024

Okay, I will in a couple of minutes because it'll take a while for the image to be uploaded. Just to give you an idea of what I'm dealing with it takes almost a minute and half for my comments to be submitted.

from android-support-preference-v7-fix.

phillat avatar phillat commented on June 2, 2024

Finally, I was able to update the library to v25.0.2 and so far everything seems fine. I'm still testing it though will update you of any possible errors (I hope not though). In the meantime I'm going to enjoy using your library. Thank you for your help and awesome library!

from android-support-preference-v7-fix.

eriknyk avatar eriknyk commented on June 2, 2024

still happening even on v7:27.1.1

implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:support-v13:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:preference-v7:27.1.1'

error:

AGPBI: {"kind":"error","text":"error: duplicate value for resource \u0027attr/maxWidth\u0027 with config \u0027\u0027.","sources":[{"file":"/Users/erik/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/de16534766b25cf86037771b3f3fc3f7/res/values/values.xml","position":{"startLine":250,"startColumn":4,"startOffset":27058,"endColumn":68,"endOffset":27122}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource previously defined here.","sources":[{"file":"/Users/erik/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/de16534766b25cf86037771b3f3fc3f7/res/values/values.xml","position":{"startLine":250,"startColumn":4,"startOffset":27058,"endColumn":68,"endOffset":27122}}],"original":"","tool":"AAPT"}
:mergeDebugResources
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
:mergeDebugResources FAILED

from android-support-preference-v7-fix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.