'I got this error : No signature of method
What do I have to do in build.gradle in order to solve this issue? This error happens when I tried to sync the Gradle project.
I got this error from the terminal:
Build file 'C:\Users\rodri\AndroidStudioProjects\firebase\android\app\build.gradle' line: 28
A problem occurred evaluating project ':app'.
> No signature of method: build_deb3zkmg0w53ryomtrj13taw0.android() is applicable for argument types: (build_deb3zkmg0w53ryomtrj13taw0$_run_closure2) values: [build_deb3zkmg0w53ryomtrj13taw0$_run_closure2@39a3d144]
This is my build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('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.google.gms.google-services'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.db.dbestech.flutterFirebaseApp"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 16
targetSdkVersion 32
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
MultiDexEnable true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
namespace 'com.example.firebase'
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
}
What do I have to do in build.gradle in order to solve this issue? This error happens when I tried to sync the Gradle project.
Thank you in advance
Solution 1:[1]
In my humble opinion, you have things too single-use. My implementation is creating a generic "getUrl" to get any resource from your chosen API, which can then be reused to iterate through characters when you need to.
Observe:
const books = [];
getUrl = async(url) => {
try {
const data = await fetch(url);
return await data.json();
} catch (error) { console.log('Failed to retrieve data: ', error); }
}
getBooks = () => {
getUrl("https://www.anapioficeandfire.com/api/books").then(data => {
data.forEach(b => {
const book = { Name: b.name, ISBN: b.isbn, Authors: b.authors, Pages: b.numberOfPages, Publisher: b.publisher, Released: b.released };
let characters = [],
charLen = b.characters.length >= 5 ? 5 : b.characters.length;
for (let i = 0; i < charLen; i++) {
getUrl(b.characters[i]).then(c => characters.push(c.name));
}
book.Characters = characters;
books.push(book);
});
});
}
getBooks();
console.log(books);
This will create a constant books object which will service your needs in your displayData function above (with capitalized property names). It is my opinion that you should also unpack the Authors and Characters lists using <ul><li> since the data may not be presented as aesthetically pleasing as you might expect with your current markup.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
