decodedhealth / flutter_zoom_plugin

Flutter plugin for zoom
Apache License 2.0
125 stars 83 forks source link

Direct local .aar file dependencies are not supported when building an AAR. #53

Open praharshbhatt opened 3 years ago

praharshbhatt commented 3 years ago

Your Environment

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0) [√] Android Studio (version 4.0) [√] Connected device (1 available)

• No issues found!

Expected Behavior

Application runs

Actual Behavior

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Note: D:\Multiverse_Projects\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_secure_storage-3.3.4\android\src\main\java\com\it_nomads\fluttersecurestorage\ciphers\RSACipher18Implementation.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: D:\Multiverse_Projects\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\in_app_purchase-0.3.4+9\android\src\main\java\io\flutter\plugins\inapppurchase\MethodCallHandlerImpl.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\Multiverse_Projects\Flutter\flutter\.pub-cache\hosted\pub.dartlang.org\webview_flutter-1.0.0\android\src\main\java\io\flutter\plugins\webviewflutter\FlutterWebView.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_zoom_plugin:bundleDebugAar'.
> Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :flutter_zoom_plugin project caused this error: D:\Multiverse_Projects\Flutter\flutter\.pub-cache\git\flutter_zoom_plugin-88d1fa2685f28d67410d46e094461a0a030d3192\android\libs\commonlib\commonlib.aar, D:\Multiverse_Projects\Flutter\flutter\.pub-cache\git\flutter_zoom_plugin-88d1fa2685f28d67410d46e094461a0a030d3192\android\libs\mobilertc\mobilertc.aar

* 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 2m 45s
Exception: Gradle task assembleDebug failed with exit code 1

Steps to Reproduce

  1. add the dependency in pubspec (0.0.8)
  2. flutter run

praharshbhatt commented 3 years ago

Any updates?

Mallikarjun7657 commented 3 years ago

@praharshbhatt I am also facing same issue ? Did you fixed the issue ? If yes, please let me know how did you fixed.

Execution failed for task ':flutter_zoom_plugin:bundleDebugAar'.

Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :flutter_zoom_plugin project caused this error: C:\Softwares\flutter.pub-cache\git\flutter_zoom_plugin-88d1fa2685f28d67410d46e094461a0a030d3192\android\libs\commonlib\commonlib.aar, C:\Softwares\flutter.pub-cache\git\flutter_zoom_plugin-88d1fa2685f28d67410d46e094461a0a030d3192\android\libs\mobilertc\mobilertc.aar

praharshbhatt commented 3 years ago

@Mallikarjun7657 Can you retry with the following configuration:

  flutter_zoom_plugin:
    git:
      url: git://github.com/decodedhealth/flutter_zoom_plugin.git
      # Android
      #ref: 0.0.8
      # iOS
      ref: master

flutter clean flutter pub cache repair flutter run

amaurya08 commented 3 years ago

Found a solution & it worked with Debug-RELEASE APK/Bundle

if you have a flutter project demo then in android module of demo --> Open build.gradle (app level) insert following code

   **Sample**
  implementation fileTree(include: '*.aar', dir: '<path to zoom-plugin-libs>') //path relative to  folder(aar files are stored) present in zoom-plugin dir

    **Example**
   implementation fileTree(include: '*.aar', dir: '../../flutter_zoom_plugin/android/libs/commonlib/')
   implementation fileTree(include: '*.aar', dir: '../../flutter_zoom_plugin/android/libs/mobilertc/')

--> Open gradle.properties insert following code

   android.enableDexingArtifactTransform=false

One last change is a suggestion to flutter-zoom-plugin, We changed a line in build.gradle of android module of this plugin :

   compileOnly files('libs/commonlib.aar') //path relative to libs folder present in zoom-plugin dir
   compileOnly files('libs/mobilertc.aar')    //path relative to libs folder present in zoom-plugin dir

Don't forget to add the proguard-rules for zoom libs/classes (if you skip it, it may not work in release APK/Bundle)

Preview for file proguard-rules.pro

  -keep class us.zoom.** { *; }
  -keep class us.zipow.** { *; }
  -keep class com.zipow.** { *; }
  -keep class org.webrtc.** { *; }
  -dontwarn us.zoom.**
  -dontwarn com.zipow.**
dulkith commented 3 years ago

Found a solution & it worked with Debug-RELEASE APK/Bundle

if you have a flutter project demo then in android module of demo --> Open build.gradle (app level) insert following code

   **Sample**
  implementation fileTree(include: '*.aar', dir: '<path to zoom-plugin-libs>') //path relative to  folder(aar files are stored) present in zoom-plugin dir

    **Example**
   implementation fileTree(include: '*.aar', dir: '../../flutter_zoom_plugin/android/libs/commonlib/')
   implementation fileTree(include: '*.aar', dir: '../../flutter_zoom_plugin/android/libs/mobilertc/')

--> Open gradle.properties insert following code

   android.enableDexingArtifactTransform=false

One last change is a suggestion to flutter-zoom-plugin, We changed a line in build.gradle of android module of this plugin :

   compileOnly files('libs/commonlib.aar') //path relative to libs folder present in zoom-plugin dir
   compileOnly files('libs/mobilertc.aar')    //path relative to libs folder present in zoom-plugin dir

Don't forget to add the proguard-rules for zoom libs/classes (if you skip it, it may not work in release APK/Bundle)

Preview for file proguard-rules.pro

  -keep class us.zoom.** { *; }
  -keep class us.zipow.** { *; }
  -keep class com.zipow.** { *; }
  -keep class org.webrtc.** { *; }
  -dontwarn us.zoom.**
  -dontwarn com.zipow.**

@amaurya08 Where i need to add these lines? compileOnly files('libs/commonlib.aar') //path relative to libs folder present in zoom-plugin dir compileOnly files('libs/mobilertc.aar') //path relative to libs folder present in zoom-plugin dir

amaurya08 commented 3 years ago

@amaurya08 Where i need to add these lines? compileOnly files('libs/commonlib.aar') //path relative to libs folder present in zoom-plugin dir compileOnly files('libs/mobilertc.aar') //path relative to libs folder present in zoom-plugin dir

Just for the sake of making my project work, I added the zoom plugin complete folder into project root folder. Here is the screenshot for the same and for the libs folder

image

larssn commented 3 years ago

I'm facing a similar issue, but Google states:

Note: You can't use the compileOnly configuration with AAR dependencies.

Source: https://developer.android.com/studio/build/dependencies

amaurya08 commented 3 years ago

I'm facing a similar issue, but Google states:

Note: You can't use the compileOnly configuration with AAR dependencies.

Source: https://developer.android.com/studio/build/dependencies

add compileOnly in plugin's android module project level (build.gradle) file. I am using follwoing gradle configuration

`group 'com.decodedhealth.flutter_zoom_plugin' version '1.0-SNAPSHOT'

buildscript { repositories { google() jcenter() }

dependencies {
    classpath 'com.android.tools.build:gradle:3.4.0'
}

}

rootProject.allprojects { repositories { google() jcenter() } }

apply plugin: 'com.android.library'

android { compileSdkVersion 29

defaultConfig {
    minSdkVersion 21
    targetSdkVersion 29
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}
lintOptions {
    disable 'InvalidPackage'
}

}

dependencies { implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.material:material:1.0.0' compileOnly files('libs/commonlib.aar') compileOnly files('libs/mobilertc.aar') } `

Here is my flutter application's project level gradle buildscript { ext.kotlin_version = '1.3.50' repositories { google() jcenter() }

dependencies {
    classpath 'com.android.tools.build:gradle:3.4.3'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.3'
}

}

allprojects { repositories { google() jcenter() } }

rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') }

task clean(type: Delete) { delete rootProject.buildDir }

App level gradle

flutter { source '../..' }

dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support:multidex:1.0.3' implementation fileTree(include: '*.aar', dir: '../../flutter_zoom_plugin-master/android/libs/') }

### And it's working 🗡️

Nishakar561 commented 3 years ago

It is not working. I'm having the same issue. Execution failed for task ':flutter_zoom_plugin:bundleDebugAar'.

Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error).

markfili commented 2 years ago

any progress or solutions to this "direct local .aar file" problem?

CarlBinneman commented 2 years ago

See solution posted to https://github.com/flutter/flutter/issues/28195

abdul-webiixx commented 2 years ago

Execution failed for task ':flutter_zoom_plugin:bundleReleaseAar'.

Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :flutter_zoom_plugin project caused this error: /home/jarves/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_zoom_plugin-0.0.7/android/libs/commonlib/commonlib.aar, /home/jarves/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_zoom_plugin-0.0.7/android/libs/mobilertc/mobilertc.aar

BUILD FAILED in 2m 29s