Error while compiling extension

Hi, thanks for the extension :grin: @oseamiya
I can't create extension to add admob app id in androidmanifest.xml, I did as you explained but it gives me error while compiling.
Could you help me?
I'll post the code

package com.ACacciaDiLettere.AdMobIdTestApp;

import android.app.Activity;

import android.content.Context;

import com.google.appinventor.components.annotations.*;

import com.google.appinventor.components.common.ComponentCategory;

import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;

import com.google.appinventor.components.runtime.ComponentContainer;

import com.google.appinventor.components.runtime.EventDispatcher;

@DesignerComponent(

        version = 1,

        description = "",

        category = ComponentCategory.EXTENSION,

        nonVisible = true,

        iconName = "")

@SimpleObject(external = true)

//Libraries

@UsesLibraries(libraries = "")

//Permissions

@UsesPermissions(permissionNames = "")

@UsesApplicationMetadata(metaDataElements={@MetaDataElement(name="com.google.android.gms.ads.APPLICATION_ID", value="ca-app-pub-3940256099942544~3347511713")})

public class AdMobIdTestApp extends AndroidNonvisibleComponent {

    //Activity and Context

    private Context context;

    private Activity activity;

    public AdMobIdTestApp(ComponentContainer container){

        super(container.$form());

        this.activity = container.$context();

        this.context = container.$context();

    }

    @SimpleFunction(description = "Sample Function Generated by Niotron")

    public void TestFunction(){

    }

    @SimpleEvent(description = "Test Event Generated by Niotron")

    public void TestEvent(){

        EventDispatcher.dispatchEvent(this, "TestEvent");

    }

}

what about providing the compilation output including the error?
Taifun

ok, I place you Execution Log.

Started Compiling Project AdMobIdTestApp
Buildfile: /compiler/android/build.xml

javac:
[mkdir] Created dir: /compiler/android/build/gLPMp/classes
[javac] Compiling 1 source file to /compiler/android/build/gLPMp/classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /compiler/android/src/gLPMp/com/ACacciaDiLettere/AdMobIdTestApp/AdMobIdTestApp.java:23: error: cannot find symbol
[javac] @UsesApplicationMetadata(metaDataElements={@MetaDataElement(name="com.google.android.gms.ads.APPLICATION_ID", value="ca-app-pub-3940256099942544~3347511713")})
[javac] ^
[javac] symbol: class MetaDataElement
[javac] error: InvocationTargetException when gathering application metadata and subelements for component AdMobIdTestApp
[javac]
[javac]
[javac] An annotation processor threw an uncaught exception.
[javac] Consult the following stack trace for details.
[javac] java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
[javac] at com.google.appinventor.components.scripts.ComponentProcessor.processComponent(ComponentProcessor.java:1256)
[javac] at com.google.appinventor.components.scripts.ComponentProcessor.process(ComponentProcessor.java:1070)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:802)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:713)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1043)
[javac] at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1184)
[javac] at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
[javac] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:523)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:381)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:370)
[javac] at com.sun.tools.javac.main.Main.compile(Main.java:361)
[javac] at com.sun.tools.javac.Main.compile(Main.java:56)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[javac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[javac] at java.lang.reflect.Method.invoke(Method.java:498)
[javac] at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:57)
[javac] at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1388)
[javac] at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:1117)
[javac] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[javac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[javac] at java.lang.reflect.Method.invoke(Method.java:498)
[javac] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
[javac] at org.apache.tools.ant.Task.perform(Task.java:350)
[javac] at org.apache.tools.ant.Target.execute(Target.java:449)
[javac] at org.apache.tools.ant.Target.performTasks(Target.java:470)
[javac] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1391)
[javac] at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
[javac] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[javac] at org.apache.tools.ant.Project.executeTargets(Project.java:1254)
[javac] at org.apache.tools.ant.Main.runBuild(Main.java:830)
[javac] at org.apache.tools.ant.Main.startAnt(Main.java:223)
[javac] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
[javac] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
[javac] Caused by: java.lang.reflect.InvocationTargetException
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[javac] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[javac] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[javac] at java.lang.reflect.Method.invoke(Method.java:498)
[javac] at com.google.appinventor.components.scripts.ComponentProcessor.elementAttributesToString(ComponentProcessor.java:1645)
[javac] at com.google.appinventor.components.scripts.ComponentProcessor.metaDataElementToString(ComponentProcessor.java:1544)
[javac] at com.google.appinventor.components.scripts.ComponentProcessor.processComponent(ComponentProcessor.java:1247)
[javac] ... 37 more
[javac] Caused by: java.lang.annotation.IncompleteAnnotationException: com.google.appinventor.components.annotations.androidmanifest.MetaDataElement missing element resource
[javac] at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:81)
[javac] at com.sun.proxy.$Proxy7.resource(Unknown Source)
[javac] ... 44 more

try adding this last import

import com.google.appinventor.components.annotations.androidmanifest.MetaDataElement;

i think it should be import com.google.appinventor.components.annotations.android.manifest.MetaDataElement;

I think I forgot to mention in documentation,

Copy this and add it in your imports .

import com.google.appinventor.components.annotations.androidmanifest.*;

Like :
image

I'll edit the documentation and add this. Thankyou !

3 Likes

ok :+1:, now it's okay.
I have compiled the extension.
Thanks everyone for the help :slightly_smiling_face:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.