android-smsmms icon indicating copy to clipboard operation
android-smsmms copied to clipboard

Can't build release app when using Proguard because of android.net.LinkProperties (+ my workaround)

Open pdalfarr opened this issue 7 years ago • 6 comments

Hi,

Great library!

On my side I have an issue when building my app (compile & target SDK 27) using your library and Proguard :

Warning: library class android.net.ConnectivityManager depends on program class android.net.LinkProperties Warning: library class android.net.ConnectivityManager$NetworkCallback depends on program class android.net.LinkProperties ... Warning: there were 2 instances of library classes depending on program classes. You must avoid such dependencies, since the program classes will be processed, while the library classes will remain unchanged. (http://proguard.sourceforge.net/manual/troubleshooting.html#dependency) FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':com.test.phone:transformClassesAndResourcesWithProguardForRelease'.

Job failed, see logs for details

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 22s

the problem is that class android.net.LinkProperties now exists in API since API 21 : bad to have this class also in the library. My workaround is to rename class android.net.LinkProperties to android.net.LinkPropertiesNEW in your library.

The app seems to work fine. Do you think it's a valid solution? Would you consider doing this change in your library (and use a better name than 'LinkPropertiesNEW' ;-) ?

Also, would you consider increasing the compileSdkVersion & compileSdkVersion of the library module? For the moment, it's 25

Thanks again for this great library! You did an amazing work!

pdalfarr avatar Jun 29 '18 08:06 pdalfarr

If you had upgrade gradle version to 4.4, you might observe this issue. And I'm downgrade version it's working well. I'm using 3.3 now and trying to make success with Gradle 4.4 now.

BareumSW avatar Aug 25 '18 07:08 BareumSW

I'm not really sure on this issue. I use Proguard, on Gradle 4.4, 4.6, and now 4.9, it has worked fine with all of these versions

klinker24 avatar Aug 25 '18 11:08 klinker24

Hi,

It's working now:

  • Android Studio 3.3
  • Gradle 4.10.1 & 'com.android.tools.build:gradle:3.3.0'
  • Proguard 6.0.3

Question: What about increasing targetSdkVersion & compileSdkVersion of this library? Currently it's 25 for both. My projects have targetSdkVersion 27 & compileSdkVersion 28 and I wonder what is the impact of using libraries with lower SdkVersion number in them. I already noticed that mConnMgr.stopUsingNetworkFeature(...) method could be a problem. Probably other things are preventing you from increasing these SdkVersions?

What about this idea: https://stackoverflow.com/questions/43365391/android-o-preview-connectivitymanager-removed-methods-are-not-backward-compati#answer-46789840

Thanks again for this amazing work!

pdalfarr avatar Feb 14 '19 07:02 pdalfarr

Hey, It's a great work done by you. Thanks for making the library. I'm getting the same compile-time error. My project is set to compileSdkVersion 29 and targetSdkVersion 29. What should I do to get rid of the error? My Gradle version is 5.6.4. Please help me out.

anikket786 avatar May 15 '20 17:05 anikket786

Warning: library class android.net.ConnectivityManager depends on program class android.net.LinkProperties Warning: library class android.net.ConnectivityManager$NetworkCallback depends on program class android.net.LinkProperties ... Warning: there were 2 instances of library classes depending on program classes. You must avoid such dependencies, since the program classes will be processed, while the library classes will remain unchanged.

anikket786 avatar May 15 '20 18:05 anikket786

@anikket786 FYI, I am now using R8 instead of Proguard. Maybe you could give a try and see if it works for you?

pdalfarr-nokia avatar May 16 '20 06:05 pdalfarr-nokia