async-storage: ERROR: Could not find method android()
can’t build the application on android studio
android {
buildToolsVersion '28.0.0'
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
Environment
- Async Storage version:
- React-Native version:
- Platform tested:
- Logs/Error that are relevant:
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (8 by maintainers)
@HelSirius Right, so in your root
build.gradle
you havesubprojects { afterEvaluate { } }
configurations. This goes through all modules that are added to your project, including AsyncStorage.If Async Storage is used a module (in your case, it is) it does not include
android
plugin, hence noandroid
block is available.To fix that, add a check if
android
block exists:Did you get any solution to this problem?
@tido64 Yes I did and thank you @Krizzu
@HelSirius Please add
if(it.hasProperty('android'))
, like in my example. This will ensure thatandroid
block will be used in modules that useandroid
build tools.