-
Notifications
You must be signed in to change notification settings - Fork 646
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
Ionic 4+ android build error: package android.support.annotation does not exist; import android.support.annotation.RequiresApi; #4562
Comments
Any updates on the above issue? I just found out that Cordova Platforms : android 9.0.0 is causing the issue. Hope this will help to resolve the issue with latest version of android 9.0.0 |
any news on that? |
Any updates? The latest cordova-android 9.0.0 causing this issue. |
Hi Guys, I hope i am not very late to reply but i think, this issue can be avoided by adding |
It really worked for me thanks a lot !! |
Works for me, thanks so much! |
Although this does make your app build, it doesn't really solve the problem, as the plugin author @dpa99c notes: https://github.com/dpa99c/cordova-plugin-androidx#deprecation-notice
So I'm kinda hoping this issue "is" going to get looked at Edit: The way I got this to build with cordova-android 9:
---only downside, is my /platform/android/gradle.properties now seems to fill up with spurious additions of android.useAndroidX and android.enableJetifier--- <- nope, this doesn't happen if you "don't" use this cordova-plugin-androidx plugin Further Edit: I just realised that all the cordova-plugin-androidx plugin does is add in the androidx=true stuff in config.xml. if you then use the recommended
as suggested by the OP (and referenced here: https://cordova.apache.org/announcements/2020/06/29/cordova-android-9.0.0.html) then you don't actually need that plugin, but you "do" still need the cordova-plugin-androidx-adapter plugin |
This fix worked for me. Thank you very much... |
thnx... its working |
Thank you, your solution works |
It really worked for me Thank you |
|
It really worked for me Thank you It really worked for me Thank you |
ionic cordova plugin add cordova-plugin-androidx |
In case people miss it... you don't actually need cordova-plugin-androidx |
Description:
Ionic 4+ app fails to build after adding the firebasex package
Steps to Reproduce:
Step 1: Create a latest blank ionic project
Step 2: Added the firebasex package onto the Ionic 4+ project
Step 3: Generate google-services.json from firebase project and add to the project folder
Step 4: Add android platform and build for android
Error received: Getting the following error when build for android
This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to
true in the gradle.properties file and retry.
Step 5: Modify platforms/android/gradle.properties as follows and rebuild
android.useAndroidX=true,
android.enableJetifier=true
Step 6: Add < preference name="AndroidXEnabled" value="true" /> in config.xml
ionic cordova prepare android
build for android
/Users/XXX/Development/app1/platforms/android/app/src/main/java/com/ionicframework/cordova/webview/IonicWebViewEngine.java:11: error: package android.support.annotation does not exist
import android.support.annotation.RequiresApi;
Output:
/-----------------------------------------------------------------------------------------/
***** Output for Step4 error
Prepared android project successfully
Executing script found in plugin cordova-plugin-firebasex for hook "after_prepare": plugins/cordova-plugin-firebasex/scripts/after_prepare.js
cordova-plugin-firebasex: Preparing Firebase on Android
No scripts found for hook "before_compile".
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/XXX/Library/Android/sdk (DEPRECATED)
Using Android SDK: /Users/XXX/Library/Android/sdk
Subproject Path: CordovaLib
Subproject Path: app
Gradle Distribution URL: https://services.gradle.org/distributions/gradle-6.5-all.zip
FAILURE: Build failed with an exception.
Execution failed for task ':app:mergeDebugResources'.
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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 959ms
9 actionable tasks: 2 executed, 7 up-to-date
Command failed with exit code 1: /Users/gireesh.viswanathan@radian.com/Development/radian_rates_v5/platforms/android/gradlew cdvBuildDebug -b /Users/gireesh.viswanathan@radian.com/Development/radian_rates_v5/platforms/android/build.gradle
Error: Command failed with exit code 1: /Users/gireesh.viswanathan@radian.com/Development/radian_rates_v5/platforms/android/gradlew cdvBuildDebug -b /Users/gireesh.viswanathan@radian.com/Development/radian_rates_v5/platforms/android/build.gradle
at makeError (/Users/gireesh.viswanathan@radian.com/Development/radian_rates_v5/platforms/android/cordova/node_modules/execa/lib/error.js:59:11)
at handlePromise (/Users/gireesh.viswanathan@radian.com/Development/radian_rates_v5/platforms/android/cordova/node_modules/execa/index.js:114:26)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
[ERROR] An error occurred while running subprocess cordova.
ionic:utils-process onBeforeExit handler: 'process.exit' received +0ms
ionic:utils-process onBeforeExit handler: running 2 functions +0ms
ionic:utils-process processExit: exiting (exit code: 1) +37ms
/-----------------------------------------------------------------------------------------/
****Note: The following error occurs when < preference name="AndroidXEnabled" value="true" > is added in the config.xml
cordova-plugin-firebasex: Preparing Firebase on Android
No scripts found for hook "before_compile".
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/XXX/Library/Android/sdk (DEPRECATED)
Using Android SDK: /Users/XXX/Library/Android/sdk
Subproject Path: CordovaLib
Subproject Path: app
Gradle Distribution URL: https://services.gradle.org/distributions/gradle-6.5-all.zip
FAILURE: Build failed with an exception.
Execution failed for task ':app:compileDebugJavaWithJavac'.
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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1s
23 actionable tasks: 2 executed, 21 up-to-date
Command failed with exit code 1: /Users/XXX/Development/app1/platforms/android/gradlew cdvBuildDebug -b /Users/XXX/Development/app1/platforms/android/build.gradle
Error: Command failed with exit code 1: /Users/XXX/Development/app1/platforms/android/gradlew cdvBuildDebug -b /Users/XXX/Development/app1/platforms/android/build.gradle
at makeError (/Users/XXX/Development/app1/platforms/android/cordova/node_modules/execa/lib/error.js:59:11)
at handlePromise (/Users/XXX/Development/app1/platforms/android/cordova/node_modules/execa/index.js:114:26)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
[ERROR] An error occurred while running subprocess cordova.
ionic:utils-process onBeforeExit handler: 'process.exit' received +0ms
ionic:utils-process onBeforeExit handler: running 2 functions +0ms
ionic:utils-process processExit: exiting (exit code: 1) +41ms
/-----------------------------------------------------------------------------------------/
My
ionic info
:Ionic:
Ionic CLI : 6.11.0 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.3.3
@angular-devkit/build-angular : 0.1000.8
@angular-devkit/schematics : 10.0.8
@angular/cli : 10.0.8
@ionic/angular-toolkit : 2.3.3
Cordova:
Cordova CLI : 10.0.0
Cordova Platforms : android 9.0.0, ios 6.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 8 other plugins)
Utility:
cordova-res (update available: 0.15.1) : 0.14.0
native-run (update available: 1.1.0) : 1.0.0
System:
Android SDK Tools : 26.1.1 (/Users/XXX/Library/Android/sdk)
ios-deploy : 1.10.0
ios-sim : 8.0.2
NodeJS : v12.18.0 (/usr/local/bin/node)
npm : 6.14.8
OS : macOS Catalina
Xcode : Xcode 12.0 Build version 12A7209
The text was updated successfully, but these errors were encountered: