apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Build is failing while generating the framework-8.0.0.aar file #757

Closed girigiramesh closed 4 years ago

girigiramesh commented 4 years ago

Bug Report

I am faced with a problem wherein framework-8.0.0.aar file, the build is failing. However, the file is being generated and the same is building versions upto 7.1.4.

Problem

I am faced with a problem wherein framework-8.0.0.aar file, the build is failing.

What is expected to happen?

The aar file should be generated successfully.

What does actually happen?

The build fails and an error is shown.

* What went wrong:
Execution failed for task ':packageDebugResources'.
> Could not resolve all files for configuration ':_internal_aapt2_binary'.
   > Could not find com.android.tools.build:aapt2:3.3.0-5013011.
     Searched in the following locations:
       - file:/Users/Apple/Library/Android/sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.0-5013011/aapt2-3.3.0-5013011.pom
       - file:/Users/Apple/Library/Android/sdk/extras/m2repository/com/android/tools/build/aapt2/3.3.0-5013011/aapt2-3.3.0-5013011-osx.jar
       - file:/Users/Apple/Library/Android/sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.0-5013011/aapt2-3.3.0-5013011.pom
       - file:/Users/Apple/Library/Android/sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.3.0-5013011/aapt2-3.3.0-5013011-osx.jar
       - file:/Users/Apple/Library/Android/sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.0-5013011/aapt2-3.3.0-5013011.pom
       - file:/Users/Apple/Library/Android/sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.3.0-5013011/aapt2-3.3.0-5013011-osx.jar
     Required by:
         project :

Information

I am faced with a problem wherein framework-8.0.0.aar file, the build is failing. However, the file is being generated and the same is building versions upto 7.1.4. Below are the steps I followed to generating the framework-8.0.0.aar file through the cordova-android repo.

Command or Code

I am faced with a problem where in framework-8.0.0.aar file, the build is failing. However, the file is being generated and the same is building versions upto 7.1.4. Below are the steps I followed to generating the framework-8.0.0.aar file through the cordova-android repo.

Environment, Platform, Device

Mentioned above.

Version information

Checklist

ErrorMessage

girigiramesh commented 4 years ago

Hi @janpio, Any update on a resolution on this. Looking forward.

janpio commented 4 years ago

Is this reproducible in a new, plain Cordova app? A minimal reproduction repository would really help to debug and later fix this issue. More information on how to create one: https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md

janpio commented 4 years ago

Also: The image contains a reference to Gradle 6, I am not sure this is supported. Is cordova requirements happy?

breautek commented 4 years ago

The image contains a reference to Gradle 6

Think you're misreading the output here. The reference to Gradle 6 is simply for a warning that deprecated features are used that will be removed in gradle 6. The actual gradle version used is 5.4.1, with the latest version being currently at 5.5.1.

There is known issues using gradle 5.x however, as reported at #754 and #718 so perhaps this is related.

girigiramesh commented 4 years ago

Thanks, @breautek. @janpio Previously we had cloned the git repo: https://github.com/apache/cordova-android.git

As per your suggestion, created a minimal reproduction repository/Sample in https://github.com/girigiramesh/reproduction-sample

FYI: Executed the command "brew upgrade gradle" in the terminal. It updated Gradle from 5.4.1 to 5.5.1. Used 5.5.1 version which seems the latest in both the above scenarios and getting the same errors. Thanks.

janpio commented 4 years ago

Thanks @breautek, I misread that.


Previously we had cloned the git repo: apache/cordova-android.git

  • Check out the 8.0.0 tag => git checkout tags/rel/8.0.0
  • Navigated to cordova-android/framework directory
  • Build => gradle build
  • The build is failing with the error.

I am confused with this workflow. What are you doing exactly and how? Don't you use Cordova CLI to create a project and then build it with cordova build android?

girigiramesh commented 4 years ago

Hi @janpio, We created the minimal reproduction repository in https://github.com/girigiramesh/reproduction-sample by following https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md We are still getting the error. Hopes this clarifies. Let me know. Thanks.

janpio commented 4 years ago

Not really, that looks like a totally vanilla Cordova Android setup.

This is now relevant:

I am confused with this workflow. What are you doing exactly and how? Don't you use Cordova CLI to create a project and then build it with cordova build android?

girigiramesh commented 4 years ago

Hi @janpio,

  1. Basically, I am trying to generate an aar file. It is being generated while using any branch/tags upto 7.1.x (https://github.com/apache/cordova-android/tree/7.1.x), but not in branch/tags 8.0.x (https://github.com/apache/cordova-android/tree/8.0.x) and I am getting the attached error.
  2. It is usually generated under framework/build/outputs/aar directory.
  3. I have created the minimal reproduction repository in https://github.com/girigiramesh/reproduction-sample as you had suggested to debug.
  4. Please let me know if you require further. Thanks. error_screenshot
janpio commented 4 years ago

Why are you trying to create that aar file manually outside of the usual build context of Cordova Android?

girigiramesh commented 4 years ago

Hi @janpio, I am trying to create an aar file to place the same in one of my projects targeting API 28 in Android. https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html However, the issue here is that the aar file is being generated in branch/tags upto 7.1.x (supports upto API 27) and not in 8.0.x (require for API 28). That is the reason for opening this issue. Thanks.

janpio commented 4 years ago

I have to sound like a broken record, by why are you doing this? To support API 28 you usually would remove the old Cordova Android 7.x platform, then add the new Cordova Android 8.x and just build your app using cordova build android. If you do that, the framework will be built just fine and included in your app.

girigiramesh commented 4 years ago

Hi @janpio, As per your suggestion, I have created a sample below steps:

cordova create reproduction-sample cd reproduction-sample I am not using any plugins in this build. cordova platform add android@7.1.x or cordova platform add android@8.0.x cordova build android In both the scenarios the build is succeeded using the Cordova CLI process. However, I am unable to find the aar file with this process. Have I used the right method? Please let me know where and how to find the .aar file. Thank you.

janpio commented 4 years ago

Why do you need the .aar? cordova build android will create an .apk file of your app for your that is ready to be used.

girigiramesh commented 4 years ago

Hi @janpio, We don't require the .apk file. We are following a similar method wherein we are generating the .aar file and using the same in our project. This was possible in versions upto 7.1.x but not now in 8.0.x. Please let me know how to get the .aar file.

janpio commented 4 years ago

I still don't know what you are doing with that .aar 🤷‍♀ .

But well, I tried to reproduce and failed with master of cordova-android:

E:\Projects\throwaway
λ git clone https://github.com/apache/cordova-android
Cloning into 'cordova-android'...
remote: Enumerating objects: 54, done.
remote: Counting objects: 100% (54/54), done.
remote: Compressing objects: 100% (37/37), done.
remote: Total 35534 (delta 22), reused 29 (delta 16), pack-reused 35480
Receiving objects: 100% (35534/35534), 35.83 MiB | 5.40 MiB/s, done.
Resolving deltas: 100% (19066/19066), done.

E:\Projects\throwaway
λ cd cordova-android/framework

E:\Projects\throwaway\cordova-android\framework (master -> origin)
λ set ANDROID_HOME
Environment variable ANDROID_HOME not defined

E:\Projects\throwaway\cordova-android\framework (master -> origin)
λ set ANDROID_HOME=C:\Users\Jan\AppData\Local\Android\sdk

E:\Projects\throwaway\cordova-android\framework (master -> origin)
λ set ANDROID_HOME
ANDROID_HOME=C:\Users\Jan\AppData\Local\Android\sdk

E:\Projects\throwaway\cordova-android\framework (master -> origin)
λ gradle build

> Task :lint
Calling mockable JAR artifact transform to create file: C:\Users\Jan\.gradle\caches\transforms-2\files-2.1\348b935b29355b3f5533ec2be760cd20\android.jar with input C:\Users\Jan\AppData\Local\Android\sdk\platforms\android-28\android.jar
Ran lint on variant debug: 1 issues found
Ran lint on variant release: 1 issues found
Wrote HTML report to file:///E:/Projects/throwaway/cordova-android/framework/build/reports/lint-results.html
Wrote XML report to file:///E:/Projects/throwaway/cordova-android/framework/build/reports/lint-results.xml

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 1m 36s
49 actionable tasks: 49 executed
E:\Projects\throwaway\cordova-android\framework (master -> origin)
λ
girigiramesh commented 4 years ago

Hi @janpio, I am able to generate the .aar file in versions upto 7.1.x and not in 8.0.x. Do you agree that this may be an issue? If it is being generated in 8.0.x, under which framework/build/outputs can I find it. The only difference between the method followed by me is that I had checkout from "master" to "git checkout tags/rel/8.0.0".

dpogue commented 4 years ago

Just as an FYI, the aar files for all Cordova-Android releases are also published to Bintray: https://bintray.com/cordova/maven/cordova-android/8.0.0

janpio commented 4 years ago

Fails with 8.0.0 for me as well. But as it is fixed in master already, this will be included in the next release as well.

girigiramesh commented 4 years ago

Thank you @dpogue. Got it. Shall test and keep you posted.

erisu commented 4 years ago

This was fixed in https://github.com/apache/cordova-android/pull/676.

As for the released contents that are on Bintray, for version 8.0.0, I manually patched to create that release.

This fix came after 8.0.0 was released to npm and that is why master was fixed and not 8.0.0.

girigiramesh commented 4 years ago

Hi @erisu, @dpogue, I was able to download the 8.0.0 .aat file. One question from my end is could I use the same to build a project that targets API 28? This I ask because as per the requirements of the Google play store, all apps submitted beyond August 2019 need to target API 28 (Attached screenshot).

playstore_reqiuement

girigiramesh commented 4 years ago

Fails with 8.0.0 for me as well. But as it is fixed in master already, this will be included in the next release as well.

Hi @janpio, Could you please let me know when your next release with this fix would be?

janpio commented 4 years ago

No, there is no ETA for releasing this. You can always check out master and work from there if you really need this, or apply #676 manually to a fork of yours.

girigiramesh commented 4 years ago

Hi @janpio, Thanks, I have tried that and the build is succeeding. However, when I compared the older versions with this .aar file, I found that several folders in the older versions are not available in the 8.0.x version. I am attaching the screenshots of the folders. Please let me know if it would make any difference. 7 1 4_folders 8 0 0_folders

girigiramesh commented 4 years ago

Hi @janpio, According to google play requirements for 2019, new apps releasing post-August 2019 are required to target API Level 28(i.e. Android 9) or higher as mentioned here: https://android-developers.googleblog.com/2019/02/expanding-target-api-level-requirements.html. As we need to use the ".aar file" in our project to release apps further and we are inclined towards using official releases (which we have been using up till now), I just wanted to know if there is any tentative date around which you plan to make your next release. Thanks.

girigiramesh commented 4 years ago

Hi @janpio, Touching base again to know if there is any update on the tentative date around which you plan to make your next release.

erisu commented 4 years ago

cordova-android@8.1.0 has been released and contains PR https://github.com/apache/cordova-android/pull/676 that should have resolved the issue of building the framework.