Android Question (SOLVED)error: cannot find symbol: Inline Java Code

Ferdari

Active Member
Licensed User
Longtime User
Hi everyone, im integrating Huawei services like this:

as there is no library i tried with Inline Java code:

Integrated the JARS:
B4X:
    'Huawei
    #AdditionalJar: huawei/hianalytics-4.0.1.300.jar
    #AdditionalJar: huawei/hmssdk-opendevice-4.0.1.300.jar
    #AdditionalJar: huawei/datastore-annotation.jar
    #AdditionalJar: huawei/datastore-core.jar
    #AdditionalJar: huawei/agconnect-https.jar
    #AdditionalJar: huawei/agconnect-credential.jar

Then created an Inline Java code on Create sub to call the initialization:
B4X:
#if Java

    public void initHMS(){
        // TODO: Initiate Analytics Kit
        // Enable Analytics Kit Log
        HiAnalyticsTools.enableLog();
        // Generate the Analytics Instance
        instance = HiAnalytics.getInstance(this);
        // You can also use Context initialization
        // Context context = this.getApplicationContext();
        // instance = HiAnalytics.getInstance(context);

        // Enable collection capability
        instance.setAnalyticsEnabled(true);
        // Enable Automatically collection capability
        instance.setAutoCollectionEnabled(true);

        // TODO: Registering the HMS Service
        // Register the HMS service and collect automatic events (account event or InAppPurchase event).
        // Automatic account event collection requires HMS APK 4.0.0.300 or a later version.
        instance.regHmsSvcEvent();
      
    }

#End If

    If FirstTime Then
        NativeMe.InitializeContext
    End If
    NativeMe.RunMethod("initHMS", Null)

But when compiling to test this error occurs:

B4X:
ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code.    (0.01s)
Organizing libraries.    (1.14s)
    (AndroidX SDK)
Generating R file.    (0.00s)
Compiling generated Java code.    Error
B4A line: 1021
End Sub
javac 1.8.0_231
src\stickers\app\main.java:2232: error: cannot find symbol
        HiAnalyticsTools.enableLog();
        ^
  symbol:   variable HiAnalyticsTools
  location: class main

Help is very appreciated.
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
the .jars aren't enough; you need to import com.huawei.hms.analytics.HiAnalytics (if not more. i didn't study your code). put the import right below #if java.
you may have to import other classes. be ready to find out where they are.
 
Upvote 0

Ferdari

Active Member
Licensed User
Longtime User
the .jars aren't enough; you need to import com.huawei.hms.analytics.HiAnalytics (if not more. i didn't study your code). put the import right below #if java.
you may have to import other classes. be ready to find out where they are.
i just added all jars needed and the imports, Its works, thanks you!
 
Upvote 0
Top