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
Missing Plugins exception when adding AAR to existing Android project #23944
Comments
I think the problem is that the Flutter gradle module, needs to generate a "FAT" AAR package, with all libraries/dependencies included. |
I am experiencing the same issue with a new channel I am creating myself. I am using Kotlin for my build, by the way. |
I see the problem is, that either you want FAT AAR as I mentioned, or you need to use the part of |
ok I see -- thanks. |
Please add the output of |
I've updated the Flutter SDK since, but the issue should still be there. Also I have 1 license issue, but this should not be the reason for the error. i'm on the master branch:
|
Yeah, that is almost the same problem as #18025, and we've "solved" it by generating a FatAAR (using https://github.com/Mobbeel/fataar-gradle-plugin). |
@Igor1201 Thanks, for the advice, I tried following the instructions on the Mobbeel page and had trouble generating the far aar file. Instead of generating a 17mb flutter-debug.aar like normal, it is generating a 345 byte ARR, and when I see what is inside it is only a lib/ folder, so im probably just doing something wrong. Here is what I did:
Clearly, in these steps I skipped the third step of the docs which is to: Mark with 'api' configuration dependecies that need embed on the final AAR. Thus, my best guess is that it doesn't work because I skipped this step. I tried adding a few things like api project(":path_provider") but it doesn't seem to work. I'm just not sure what to put there, and I would greatly appreciate any assistance. |
@MichaelShnaider Yeah, the third step is needed, I'm using exactly the configuration you said: api project(':flutter')
api project(':path_provider') Also, don't forget to enable the following configuration: aarPlugin {
includeAllInnerDependencies true // It's false for default
} |
@Igor1201 I tried adding the "api project" lines that you recommended, but I get the error:
I'm not sure where the issue lies, but here is my ./android/build.gradle: // Generated file. Do not edit.
buildscript {
repositories {
google()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// Mobbeel to generate the fat aar.
classpath "com.mobbeel.plugin:fat-aar:2.0.1"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}` Here is my ./android/Flutter/build.gradle // Generated file. Do not edit.
apply plugin: "com.mobbeel.plugin"
def localProperties = new Properties()
def localPropertiesFile = new File(buildscript.sourceFile.parentFile.parentFile, 'local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.library'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
aarPlugin {
includeAllInnerDependencies true // It's false for default
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:support-v13:27.1.1'
implementation 'com.android.support:support-annotations:27.1.1'
api project(':flutter')
api project(':path_provider')
}
It's possible I added the "api project" lines in the wrong location or something |
I see. It seems you are editing the generated flutter project directly, am I right? In my setup, we have an Android project with two modules (
Project tree:
(I've omitted iOS folder) |
@Igor1201 Well Igor, first off I appreciate your help so much! I was trying to have it work just by adding and configuring the default AAR generated with "./gradlew flutter:assembleDebug" generated aar, but sadly no success :( And yea, I was using gradle files from the flutter project, lol, woopsies... Ok, so NOW I'm trying it your way with the android-library, and generating a Fat AAR from that, so I have a question. Do you have an activity inside the sample android project which does, the If you have an activity inside the android-library which does
If you are referencing And yes, in my android-library project, I made sure to have the I'll keep playing with it, but those are the errors im getting. Will post if I get updates and any help would be greatly appreciated, thanks! |
My library The This |
@MichaelShnaider Also, I'm not sure why but I have to call |
@Igor1201 Ok cool, so right now you have the 1. Generate the fat AAR from the 2. Make a brand new android project 3. Add the FAT AAR to the new project. I did this by dragging the Fat AAR into the 4. Then from the MainActivity of the newly created class, in my onCreate method, I do: It is at this point when I run the Flutter application that I crash. Not sure if that was your end goal, but that was mine. If I simply import the |
@MichaelShnaider That's exactly our goal too. My library AAR file in release mode has ~6.1M, while the debug version comes with 24M. The only difference of what you are doing is that I'm shipping the library to a private maven repo (using Sorry I can't show you the repo, but that's the tree of the generated AAR: my_library.aar (release)
And the contents of the JARs inside the lib/ folder: android-flutter-unspecified.jar
flutter.jar
io.flutter.plugins.pathprovider-path_provider-1.0-SNAPSHOT.jar
r-classes.jar
Hope this helps! |
@MichaelShnaider What is the stacktrace of your crash? |
@rafaelring the crash I have is above: #23944 (comment) |
@MichaelShnaider Can you send also the tree of your fat AAR files ( |
@rafaelring Yea, maybe you are right, this is my debug aar:
here is release:
|
@MichaelShnaider Got it, this is a problem we've stumbled into also. What happens is that this version of the fat aar plugin you're using (2.0.1) has an issue on this conditions: when merging the dependencies it only considers the name of the artifact. Because there's a |
@rafaelring HAHAHA OMG YOU GOT IT EXACTLY! Thanks so much for your help, @Igor1201 and @rafaelring, I appreciate it a lot! You guys are amazing! |
@MichaelShnaider Nice, just a quick follow up question if you don't mind, did you get it working with which flutter version? On our setup we needed to make a change to flutter in order to get the |
@rafaelring I had to manually drag the So no, it did not work directly, but hopefully that will be fixed in the future.
|
@MichaelShnaider Got it. That's why we did that PR so then you don't have to copy it manually anymore as it will work directly with the generated files. Thanks |
any news on this issue? is there any hope for this PR to be merged soon? :) |
@jelenacarnegie The PR #23782 fixes the missing |
@MichaelShnaider Hello, i have same issue like yours #23944 (comment) with fat-aar-plugin version 2.0.1. How do you solve it? I Try using fat-aar-plugin version 2.0.3 can't build aar. The error is 'R.txt cannot generate'. |
I am facing the same issue. Please help me. |
|
In flutter/packages/flutter_tools/gradle/flutter.gradle findByPath(":app:merge${variant.name.capitalize()}Assets")
findByPath(":presentation:app:merge${variant.name.capitalize()}Assets") or the some how we need to remove |
hi, I'm really curious to know how you solve the problem. I don’t know what I should do after that |
@lsp9876 I think the issue here is that you are editing the generated project file, and not creating another module that imports the generated one (and use fataar on it). What you should do is:
Also, I'm using fataar v2.0.3. |
@Igor1201 |
@Igor1201 I followed your steps, but I got an empty .aar file.
flutter version:
fataar version: Anything wrong? Thanks. |
@Igor1201 It seems the wrong gradle plugin version lead to the empty lib |
@TinoGuo I'm sorry I couldn't reach you sooner. |
@Igor1201 Finally, I found a solution. DONT just run run In addition, this only worked in gradle plugin |
Strange, maybe it's a bug on |
Use caseIn my project we have ios and android native project. But after heard about flutter we decide that new functionality will develop into flutter module ( Now go to my android project and import flutter exported .aar file in android project as module or lib. for reference see the image After import we analyze .aar just like .apk file and here are image for reference How can we call dart route page from Android app`
Call this code from my android activity .. issueNow we create other module in flutter and import same as last time. during the import .aar we can change name of module using android studio. Here are we attaching image reference. Now you can see the .so file in second .aar file with the same name of last one .aar file.. when we run this it gives error |
for me it seems to be working if aar package is release but fails to load plugins if a debug aar is used:
hopefully this sheds some light on the issue |
@blasten Do you have any update on how we can include flutter plugins into AAR file or Maven locale repo? Thanks in advance. |
I'm going to tentatively close this bug now. The 'official' |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to Reproduce
Error from android Logcat:
Look at the bolded parts of the error
The text was updated successfully, but these errors were encountered: