AppGalleryConnect / agc-flutter-plugin

This repository including all of exsiting plugins of AppGallery Connect Service in Flutter.
Apache License 2.0
12 stars 3 forks source link

error: package com.huawei.agconnectclouddb.objecttypes does not exist #13

Closed iamshaunwu closed 6 months ago

iamshaunwu commented 6 months ago

Hi!

I encountered the following error for agconnect_clouddb: ^1.9.0+300 on Flutter 3.16.9 despite following the documentation. Please enlighten. Thanks!

  1. I have already unzipped the exported files (ObjectTypeInfoHelper.java & cloudDbZoneTest.java) to the required folder.

  2. This is my app level build.gradle.

    
    plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
    id "com.huawei.agconnect"
    }

def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } }

def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' }

def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' }`

`android { namespace "com.example.app" 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.example.app"
    // You can update the following values to match your application needs.
    // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
    minSdkVersion flutter.minSdkVersion
    targetSdkVersion flutter.targetSdkVersion
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

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
    }
}

}

flutter { source '../..' }

dependencies {}

3. This is android folder level build.gradle.

buildscript { ext.kotlin_version = '1.7.10' repositories { google() mavenCentral() maven {url 'https://developer.huawei.com/repo/'} }

dependencies {
    classpath 'com.android.tools.build:gradle:8.2.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.huawei.agconnect:agcp:1.9.0.300'
}

}

allprojects { repositories { google() mavenCentral() maven {url 'https://developer.huawei.com/repo/'} } }

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

tasks.register("clean", Delete) { delete rootProject.buildDir }


4. Error Message

/Users/myName/.pub-cache/hosted/pub.dev/agconnect_clouddb-1.9.0+300/android/src/main/java/com/huawei/agconnectclouddb/utils/AGCCloudDBUtil.java:8: error: package com.huawei.agconnectclouddb.objecttypes does not exist import com.huawei.agconnectclouddb.objecttypes.ObjectTypeInfoHelper; ^ /Users/myName/.pub-cache/hosted/pub.dev/agconnect_clouddb-1.9.0+300/android/src/main/java/com/huawei/agconnectclouddb/modules/AGCCloudDBModule.java:29: error: package com.huawei.agconnectclouddb.objecttypes does not exist import com.huawei.agconnectclouddb.objecttypes.ObjectTypeInfoHelper; ^ /Users/myName/.pub-cache/hosted/pub.dev/agconnect_clouddb-1.9.0+300/android/src/main/java/com/huawei/agconnectclouddb/utils/AGCCloudDBUtil.java:14: error: cannot find symbol for (Class<? extends CloudDBZoneObject> clazz : ObjectTypeInfoHelper.getObjectTypeInfo().getObjectTypes()) { ^ symbol: variable ObjectTypeInfoHelper location: class AGCCloudDBUtil /Users/myName/.pub-cache/hosted/pub.dev/agconnect_clouddb-1.9.0+300/android/src/main/java/com/huawei/agconnectclouddb/modules/AGCCloudDBModule.java:77: error: cannot find symbol AGConnectCloudDB.getInstance().createObjectType(ObjectTypeInfoHelper.getObjectTypeInfo()); ^ symbol: variable ObjectTypeInfoHelper location: class AGCCloudDBModule

iamshaunwu commented 6 months ago

To add on, I have tried the below steps but the same error still shows.

Appreciate if you can advise urgently, as we have a tight deadline to meet. Thanks!

iamshaunwu commented 6 months ago

Communicated with Huawei Developer Support. Apparently, there is nothing wrong with the package. However, the documentation is still in the process of update.

Solution: Instead of placing the java files onto your own android app folder, paste these files directly onto the package android folder instead - /Users/myName/.pub-cache/hosted/pub.dev/agconnect_clouddb-1.9.0+300/android/src/main/java/com/huawei/agconnectclouddb/objecttypes.

As for my case as I have multiple projects, so as not to complicated the different object types, I duplicated this package onto my project folder and added the path in pubspec.yaml. Then pasted the java files directly onto the replicated package android folder.

Closing this since it is a documentation issue.