I need to use a react native library called #ihealth/ihealthlibrary-react-native
I added it to my project, but on build I get an error Could not find no.nordicsemi.android:dfu:1.6.1
This package version seems to be no longer available, so I would like to override the version in my react native app.
I added the following in MyProject/android/app/build.gradle
dependencies {
implementation("com.ihealth.ihealthlibrary:iHealthLibrary:1.5.1") {
exclude group:'no.nordicsemi.android:dfu:1.6.1'
}
implementation("no.nordicsemi.android:dfu:1.8.0")
}
I then get this error: Could not find com.ihealth.ihealthlibrary:iHealthLibrary:1.5.1.
Basically I can't figure out what's the correct package name and version to put in my config.
Where can I find this ?
This lib is really outdated. Go into the libraries build.gradle file and replace this implementation 'no.nordicsemi.android:dfu:1.6.1'
with: implementation 'no.nordicsemi.android:dfu:1.8.0'
then create a patch: yarn patch-package #ihealth/ihealthlibrary-react-native
Related
I wrote a Flutter plugin that find the absolute path for a file on an Android system using the PickiT library. The plugin, called Flutter absolute path, has the dependency of the PickiT library added on the plugin build.gradle:
dependencies {
implementation 'com.github.HBiSoft:PickiT:2.0.5'
}
But when I add this plugin to my app and I try to compile it, I receive this error:
<APP_PATH>/GeneratedPluginRegistrant.java:34: error: cannot access PickiTCallbacks
flutterEngine.getPlugins().add(new net.altermundi.flutter_absolute_path.FlutterAbsolutePathPlugin());
^
class file for com.hbisoft.pickit.PickiTCallbacks not found
The only way that I found to make my plugin working is to add the library to my project on the app/build.gradle dependencies also.
How can I make the plugin Android dependency implicit on the whole project without adding it?
I know the way using 'flatDir'.
But android studio warn do not use flatDir.
My project is android library.
I add jniLib in sourcet and use implementation files.
Then, I could add direct aar dependency to my lib and app which use my lib.
But I can't add dependency to androidTest in my android library project.
I want to use androidTestImplementation but my project is multi flavor build and there is no API flavor[Debug|Release]AndroidTestImplementation with files arguments.
I tried to search the way, but failed.
Now, I use flatDir and ignore warning.
How can I solve this problem?
Why do I need this?
I'm creating a Flutter package (for android) and I want to create the MethodCallHandler's code in a separate AAR file that can be added in my plugin's code
So I'll have:
pluginNativeCode/android/MyPlugin.kt
import ir.malv.android.flutter.MySeparateMethodCallHandler
class MyFlutterPlugin: FlutterPlugin {
override fun onAttachedToEngine(...) {
// Here's the source of the problem
channel.setMethodCallHandler(MySeparateMethodCallHandler())
}
}
The MySeparateMethodCallHandler is not in the plugin/android part and it's imported as a gradle dependency
However in that library I don't have access to flutter's codes like MethodCallHandler class.
Similar behaviour in unity and react native
In react-native there is com.facebook.react:react-native:+ that can be added as compileOnly to get the needed react-native codes
In unity we have unity.jar file which contains unity native codes and can be added as compileOnly as well to provide engine's native APIs
What do we have in Flutter for this?
Is there a dependency that I can include as compileOnly and use it to get the needed classes and create my aar file in a separate project?
Here's a solution:
Add this remote to repositories of build.gradle
allprojects {
repositories {
// .. rest of remote urls
maven { url("http://download.flutter.io/")}
}
}
Add this dependency to module's build.gradle
dependencies {
compileOnly("io.flutter:flutter_embedding_debug:1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718")
// rest
}
Notice the compileOnly. This will avoid the class duplication. Plugin just requires it. The flutter app will provide it itself.
What is 0fdb562ac8068ce3dda6b69aca3f355f4d1d2718? It's the engine version that is good to match the version you are developing the plugin with.
in your code you will have access to needed classes such as MethodChannel, MethodChannel.Result and ...
Bonus: How do I know what engine I'm making the plugin with?
I think it should not matter if you just need a class like MethodChannel to invoke a method, but here's a way to get it using Android Studio
Open the project/example/android of your plugin using Android studio (that has Flutter plugin activated)
run gradle plugin_name:dependencies task and look for flutter_embedding_ phrase.
I want to create a single uber/fat aar. I have a library (libA) which is dependant on another library (libB) and I would like to bundle them together, preferably using gradle. This uber/fat aar will then be used in an app.
Initially I looked at 2 similar gradle plugins, shadowJar and fataar but due to version incompatibilities they were a no go. So to do this, I've created a custom configuration in my gradle file and added the dependencies:
configurations { privateLibs }
privateLibs ('libB.1.0.0#aar') {
transitive=true
}
compile configurations.privateLibs.asFileTree
I can then run gradle install to produce libA-1.0.0.aar.
When I inspect libA.aar and look at it's contents using
jar tvf libA-1.0.0.aar
I can see LibB listed under the libs folder:
BST 2018 libs/libB-1.0.0.aar
I've now created an app inclduing my new library libA-1.0.0.aar as a local dependency. Later it will be resolved through an external repository.
implementation files('libs/libA-1.0.0.#aar')
The app compiles and appears to be ready to run. However when I try to run the app in the android simulator it throws up an error message:
error: cannot access ExampleClass class file for com.sample.ExampleClass
ExampleClass is a class created in libB and implemented in libA. It appears as though libA has no knowledge of libB despite it being available in the libs folder of the libA aar. Is the build steps here wrong? Should this be done another way? Thanks in advance!
I'm pretty new to android studio, but i got this error and i can't run my project. I saw a lot of answers which suggest to add the support-annotations dependency, but I'm using appcompat so i don't need that. Any thoughts?
Do you have the Android Support Library?
To do it add this to your build.gradle file of the "app" module:
dependencies {
...
implementation "com.android.support:support-annotations:27.1.0"
}
Then sync the project.
Sometimes you can do this automatically by pressing Alt+Enter over the error message and selecting the solution.
You need to fetch the libraries that contain the imports, in your build gradle file of your module add the line inside dependencies tag:
api 'com.android.support:support-annotations:X.X.X'
or
implementation 'com.android.support:support-annotations:X.X.X'
Where X.X.X is the version of the rest of your support libraries.
You should read this article that explains how to implement this with more detail.