Extension Error! Help

Hi, I’m trying to make an extension which returns true if a particular permission is granted or not in the app. I’m new for creating extensions. I know Java but I don’t know how extensions work. Please can anyone help me? I’m getting this error!

Buildfile: /home/Makeroid/appinventor/build.xml

extensions:

clean:

init:
[mkdir] Created dir: /home/Makeroid/appinventor/build/buildserver
[mkdir] Created dir: /home/Makeroid/appinventor/buildserver/build
[mkdir] Created dir: /home/Makeroid/appinventor/buildserver/build/classes
[mkdir] Created dir: /home/Makeroid/appinventor/buildserver/reports
[mkdir] Created dir: /home/Makeroid/appinventor/buildserver/reports/raw
[mkdir] Created dir: /home/Makeroid/appinventor/buildserver/reports/html

common_CommonUtils:

init:
[mkdir] Created dir: /home/Makeroid/appinventor/build/common
[mkdir] Created dir: /home/Makeroid/appinventor/common/build
[mkdir] Created dir: /home/Makeroid/appinventor/common/build/classes
[mkdir] Created dir: /home/Makeroid/appinventor/common/reports
[mkdir] Created dir: /home/Makeroid/appinventor/common/reports/raw
[mkdir] Created dir: /home/Makeroid/appinventor/common/reports/html

CommonUtils:
[mkdir] Created dir: /home/Makeroid/appinventor/common/build/classes/CommonUtils
[javac] Compiling 3 source files to /home/Makeroid/appinventor/common/build/classes/CommonUtils
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning
[javac] Creating empty /home/Makeroid/appinventor/common/build/classes/CommonUtils/com/google/appinventor/common/utils/package-info.class
[jar] Building jar: /home/Makeroid/appinventor/build/common/CommonUtils.jar
[jar] Building jar: /home/Makeroid/appinventor/build/common/CommonUtils-gwt.jar

common_CommonVersion:

init:

CommonVersion:
[mkdir] Created dir: /home/Makeroid/appinventor/common/build/classes/CommonVersion
[mkdir] Created dir: /home/Makeroid/appinventor/common/build/src/com/google/appinventor/common/version
[copy] Copying 1 file to /home/Makeroid/appinventor/common/build/src/com/google/appinventor/common/version
[javac] Compiling 3 source files to /home/Makeroid/appinventor/common/build/classes/CommonVersion
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning
[javac] Creating empty /home/Makeroid/appinventor/common/build/classes/CommonVersion/com/google/appinventor/common/version/package-info.class
[jar] Building jar: /home/Makeroid/appinventor/build/common/CommonVersion.jar
[jar] Building jar: /home/Makeroid/appinventor/build/common/CommonVersion-gwt.jar

CopyToRunLibDir:
[mkdir] Created dir: /home/Makeroid/appinventor/buildserver/build/run/lib
[copy] Copying 36 files to /home/Makeroid/appinventor/buildserver/build/run/lib

components_AndroidRuntime:

init:
[mkdir] Created dir: /home/Makeroid/appinventor/build/components
[mkdir] Created dir: /home/Makeroid/appinventor/components/build
[mkdir] Created dir: /home/Makeroid/appinventor/components/build/classes
[mkdir] Created dir: /home/Makeroid/appinventor/components/reports
[mkdir] Created dir: /home/Makeroid/appinventor/components/reports/raw
[mkdir] Created dir: /home/Makeroid/appinventor/components/reports/html

CommonConstants:
[mkdir] Created dir: /home/Makeroid/appinventor/components/build/classes/CommonConstants
[javac] Compiling 7 source files to /home/Makeroid/appinventor/components/build/classes/CommonConstants
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning
[javac] Creating empty /home/Makeroid/appinventor/components/build/classes/CommonConstants/com/google/appinventor/components/common/package-info.class
[jar] Building jar: /home/Makeroid/appinventor/build/components/CommonConstants.jar
[jar] Building jar: /home/Makeroid/appinventor/build/components/CommonConstants-gwt.jar

HtmlEntities:
[mkdir] Created dir: /home/Makeroid/appinventor/components/build/classes/HtmlEntities
[javac] Compiling 1 source file to /home/Makeroid/appinventor/components/build/classes/HtmlEntities
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] 1 warning
[jar] Building jar: /home/Makeroid/appinventor/components/build/HtmlEntities.jar

common_CommonVersion:

init:

CommonVersion:

AndroidRuntime:
[mkdir] Created dir: /home/Makeroid/appinventor/components/build/classes/AndroidRuntime
[javac] Compiling 362 source files to /home/Makeroid/appinventor/components/build/classes/AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /home/Makeroid/appinventor/components/src/com/google/appinventor/components/runtime/permissionChecker.java:41: error: cannot find symbol
[javac] if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.READ_SMS)
[javac] ^
[javac] symbol: variable thisActivity
[javac] location: class permissionChecker
[javac] /home/Makeroid/appinventor/components/src/com/google/appinventor/components/runtime/permissionChecker.java:41: error: cannot find symbol
[javac] if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.READ_SMS)
[javac] ^
[javac] symbol: variable ContextCompat
[javac] location: class permissionChecker
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 errors
[javac] 1 warning

My code:

package io.makeroid.jmodi6.permissionChecker;

import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.PropertyCategory;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.annotations.UsesPermissions;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.common.PropertyTypeConstants;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import android.content.pm.PackageManager;
import android.Manifest;
import android.support.v4.content.PermissionChecker;
import static android.Manifest.permission;
import android.app.Activity;

@DesignerComponent(
version = 1,
description = “Extension made with Kodular IDE”,
category = ComponentCategory.EXTENSION,
nonVisible = true,
iconName = “https://ide.kodular.io/assets/logo.png”)

@SimpleObject(external = true)
public final class permissionChecker extends AndroidNonvisibleComponent {

/**

  • Creates a new component
    */
    public permissionChecker(ComponentContainer container) {
    super(container.$form());
    }
    @SimpleFunction(description = “This extension will check if a particular permission is granted or not”)
    public static boolean isPermissionGranted(String permissionName){
    permissionName = “READ_SMS”;
    if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.READ_SMS)
    != PackageManager.PERMISSION_GRANTED) {
    return true;
    } else{
    return false;
    }
    }
    }
1 Like

The two variables (thisActivity, ContextCompat) you’re using aren’t defined.

3 Likes