gregkorossy / Android-Support-Preference-V7-Fix

Android androidx.preference support library has some issues, this lib tries to fix them.
https://discord.gg/87NVsSK
Apache License 2.0
497 stars 46 forks source link

How to import preference-v7 modules #157

Closed mik61 closed 6 years ago

mik61 commented 6 years ago

Hi there Not sure if this is the place to ask for assistance but i'm having trouble importing your modules into Android Studio. I am new to Android and have been trying everything. But i cannot get it to appear in the Android Project window panel.

It seems that Android Studio will only allow AAR and JAR modules to be imported.

I have also tried your lib references and recompiling the gradle.

Also had no luck using Android Studio's Project Structure dialog.

I am also using the latest Gradle v4.4 and your lib v27.1.1.1.

Hope someone can point me in the right direction.

Thanks Mik

gregkorossy commented 6 years ago

You don't see the lib in your project window because you shouldn't. This is not part of your project per se but merely an imported "thing". You can access the lib's content the same way you access anything else by importing the classes in your files like you do with other java classes.

Do you get any build errors when you add the necessary line to your gradle file?

mik61 commented 6 years ago

Hi there Thanks for your quick reply. Android Studio needs to know where your library classes are located. All the blogs i read refer to importing library modules. But Android Studio will only accept AAR of JAR files so i am at a loss what to do.

gregkorossy commented 6 years ago

I think you should read the guide on how to configure your builds. In a nutshell, you need to add the implementation 'com.takisoft.fix:preference-v7:27.1.1.1' line to your dependencies in your module's (probably the "app" named module's) gradle file.

mik61 commented 6 years ago

Thanks for the excellent reference Gergely, just what i needed.

On 14 May 2018 at 00:27, Gergely Kőrössy notifications@github.com wrote:

I think you should read the guide on how to configure your builds https://developer.android.com/studio/build/. In a nutshell, you need to add the implementation 'com.takisoft.fix:preference-v7:27.1.1.1' line to your dependencies in your module's (probably the "app" named module's) gradle file.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Gericop/Android-Support-Preference-V7-Fix/issues/157#issuecomment-388630961, or mute the thread https://github.com/notifications/unsubscribe-auth/Alavo9Qo4Cl3P1Cq8V2Gd10ywOrAW9BRks5tyELsgaJpZM4T8vMT .

mik61 commented 6 years ago

Hi there Read through most of the references you provided me thanks. I am now able to link to your modules thanks to your instructions. But i still have issues compiling your modules. Attribute references between you modules don't get recognized. I have set the following in my 'build.gradle (Module:app) dependencies { ...... // compile 'com.android.support:preference-v7:27.0.2' compile 'com.takisoft.fix:preference-v7:27.1.1.1' compile 'com.takisoft.fix:preference-v7-extras:27.1.1.1' compile 'com.takisoft.fix:preference-v7-ringtone:27.1.1.1' compile 'com.takisoft.fix:preference-v7-datetimepicker:27.1.1.1' compile 'com.takisoft.fix:preference-v7-colorpicker:27.1.1.1' compile 'com.takisoft.fix:preference-v7-simplemenu:27.1.1.1' } When i try to compile (even tried cleaning project) i get the following errors img

gregkorossy commented 6 years ago

Instead of including all of the artifacts, use only

implementation 'com.takisoft.fix:preference-v7:27.1.1.1'
implementation 'com.takisoft.fix:preference-v7-extras:27.1.1.1'

The extras one contains all of the extra ones, like ringtone and datetimepicker.

Also, try File > Invalidate Caches/Restart...

mik61 commented 6 years ago

Hi there Thanks for pointing that out to me. It definitely fixed some issues with my build cradle. But i also found that i had to remove the following reference from my dependency build, before i could get everything working. Not sure why, but perhaps there was a conflict with your modules.

implementation 'com.android.support:appcompat-v7:27.0.3'

gregkorossy commented 6 years ago

That is because you have to use the same version of the support libs. This preferences fix lib always follows this version name syntax: the first three numbers come from the official support lib version (so 27.1.1 as of now), and the last number is the lib's own version code so bugs can be fixed between official versions.

This means that you need to use the 27.1.1 version of the appcompat-v7 lib:

implementation 'com.android.support:appcompat-v7:27.1.1'