-
Notifications
You must be signed in to change notification settings - Fork 582
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
Deprecated features in gradle files #751
Comments
Hi, what is the command you execute? Deprecation does not mean it is already not supported and you have not provided an error you encounter. AFAIK you cannot package an Android library to a jar, only aar is supported. |
Thanks for the response. I'm trying to do what should be a very simple thing in most other languages and build systems: clone the Git repos exactly as they are, make a small change to one source file, then rebuild the repos. I have forked RxAndroidBle, MultiPlatformBleAdapter, and FlutterBleLib but made no changes yet. I downloaded the up-to-the-minute version of Android Studio, and I'm running Gradle 6.7.1, and Maven 3.6.3. All of this on Ubuntu 20.04 LTS, with OpenJDK 11. So, I first cloned RxAndroidBle, master branch. Running "./gradlew build" produces screenfuls of errors: /home/lee/work/RxAndroidBle/mockrxandroidble/src/main/java/com/polidea/rxandroidble2/mockrxandroidble /RxBleConnectionMock.java:5: error: cannot find symbol symbol: class NotificationSetupMode FAILURE: Build failed with an exception.
======== So, I tried Android Studio. It loaded the project, I pressed the little hammer icon, and it said "Gradle build finished in 10s". But then "find . -name '*.aar'" does not find any .aar files, so I'm not sure what it built or where. So, moving on to MultiPlatformBleAdapter, it too fails attempts at gradle but builds something with Studio. So I tried to do what I'll need for phase 2: I'll need Multi to use an RxAndroidBle .aar built from my fork rather than the one at JCenter. But since I couldn't build one yet, I just downloaded the latest from JCenter and put it into a libs directory, added a "flatDIr" entry to repositories, and changed the implementation line in dependencies to "implementation files('libs/rxandroidble-1.12.1.aar'). That gave me errors that it couldn't find some of the things that are marked as dependencies of Rx in Maven, so I added jars for rxjava and rxrelay to the libs dir as well. Now it complains that it can't find something called "Package", but I can't find that text in any file of the repo, so I'm stuck there. Once again I abandoned Gradle and tried to do this through the Studio GUI ("Module Settings") but no luck. I am working at a company where I have access to other kinds of computers. If you can tell me what kind of setup actually built these products for Android, I can go get an Apple machine or a Windows machine if I have to. My personal experience with other languages and build systems, though, is that Linux is usually the simplest and most reliable. Anyway, I'd be grateful any build help you can give me, even if I have to resort to Studio. If we can get it running with gradle, I might even help you create some CI scripts in Github to run builds. |
Android Studio comes with a packaged JDK 8 AFAIK and that is what Android officially supports – you may want to start with that. |
Thanks. I'll try a clean machine with JDK8. |
TIL. New Android Studio does not list Gradle Tasks by default (need to change the setting under experimental) and it seems that Robolectric is now incompatible when run under AS. I foresee lots of maintenance in the near future |
@dariuszseweryn I looked at upgrading, but electricspock is the limiting factor. I tried to update its dependencies but it is very complex and I just got lost hkhc/electricspock#11 (comment) |
Moving the entire test suite from Spock to something else is a major investment I think. I am looking into making stubs of used Android dependency classes in tests and getting rid of ElectricSpock and Robolectric. This could be less demanding |
Possibly, you would need to do the same for RxAndroid |
RxAndroid does not seem to be used in the tests? |
Ah I thought the library used RxAndroid, but I guess not. |
RxAndroid is used only in example apps. They are not tested at all, so no problem there ;D |
On a clean machine with Oracle JDK8, Gradle 6.5, and the Android tools, I am able to build the AARs for this, as well as for MultiPlatform. "gradlew build" still fails because it tries to run the "lint" task. So now I can build the AARs, I can build this one with the minimal change I need to support connectGatt(...phy). Now the issue will be getting the FlutterBleLib code to use my modified lib. Darius, if this is something you could do relatively easily, my boss would be happy to throw some money and a phone your way. |
FYI, there's a StackOverflow bounty on my workaround question: https://stackoverflow.com/questions/69184440/replacing-a-gradle-dependency-in-flutter-library |
I've managed to build RxAndroidBle with custom code and include it in a React Native project starting with a basis of react-native-ble-plx (v2.0.3) -> MultiPlatformBleAdapter (commit b0272c0fae040cc90f790481c54e8f2d45304339) -> RxAndroidBle (v1.7.1 RxJava1, commit a24ca50). At first I tried to build everything at once in a multiproject including this old RxAndroidBle dependency. No success. Therefore I changed to building the RxAndroidBle separately using older Java from the command line, and added the .aar file to the MultiPlatformBleAdapter build.gradle. The following actions are what worked for my React Native project. Hopefully they can be adapted for your Flutter project.
At this point your project should build with the local source version of MultiPlatformBleAdapter, but still downloading the Maven Polidea.RxAndroidBle. The following steps will finally use a locally build .aar file:
I think that was everything needed to get a build working. |
This issue is resolved with #763 |
We are now building with Gradle 7. Unfortunately there will be an issue when Gradle 8 comes but doesn't seem to be a big problem:
Related search in groovy-android-gradle-plugin |
Can't build Android library with recent versions of gradle.
Just cloned the repo, and tried to build any target with ./gradlew (in particular, I want to build the "jar" target so I can make some changes, and use my version in Multiplatform, and then use that in FlutterBleLib...)
I get "maven plugin is deprecated...use the maven-publish plugin instead...kotlin-android-extensions is deprecated...use migration guide..."
I tried gradle 6.7.1 and 7.0.2. Here's the output of gradle --version:
Gradle 7.0.2
Build time: 2021-05-14 12:02:31 UTC
Revision: 1ef1b260d39daacbf9357f9d8594a8a743e2152e
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.11 (Ubuntu 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OS: Linux 5.8.0-53-generic amd64
Alternatively, is there a way to build a jar file with Android Studio to then propagate up the chain? Or is there a way to maybe use the dex files produced by the AS build in Multi and Flutter?
My ultimate goal is a Flutter app...but I need to add a bit of my own Java code to Rx. I'm happy to do it, but if I can't compile, I'm out of luck...
The text was updated successfully, but these errors were encountered: