Java Question PendingIntent.FLAG_MUTABLE

Johan Schoeman

Expert
Licensed User
Longtime User
I am trying to warp a Github project (fairly recently posted) but getting this error with SLC:

B4X:
error: cannot find symbol
            PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE);
                                                                                                  ^
  symbol:   variable FLAG_MUTABLE
  location: class PendingIntent

Browsing the web for the error indicates it requires Android 31? Is this correct?

This might be a possible solution but have not tried it yet....

 

agraham

Expert
Licensed User
Longtime User
Android 31? Is this correct?
Yes. I think it needs a new SDK for API 31.
 

Johan Schoeman

Expert
Licensed User
Longtime User
Yes. I think it needs a new SDK for API 31.
SLC seems to have allowed this:

B4X:
            PendingIntent pendingIntent=null;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent,
                        PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
            }else {
                pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
            }

....in place of....

B4X:
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE);

But now have some further errors to deal with not related to the above.
 

Johan Schoeman

Expert
Licensed User
Longtime User
Now I get this error:

B4X:
Starting step: Creating XML file.
javadoc: warning - The old Doclet and Taglet APIs in the packages
com.sun.javadoc, com.sun.tools.doclets and their implementations
are planned to be removed in a future JDK release. These
components have been superseded by the new APIs in jdk.javadoc.doclet.
Users are strongly recommended to migrate to the new APIs.
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\gemalto\jp2\JP2Decoder.java:3: error: package android.graphics does not exist
import android.graphics.Bitmap;

.....mind boggling....
 

DonManfred

Expert
Licensed User
Longtime User
Now I get this error
did you added android.jar from platforms\android-30 as a dependency?
Note that i do use Eclipse usuall and need to add this jar to every project in Eclipse as dependency.

Also note that i never worked with an Api >30 so i can not answer if this is of help.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

Johan Schoeman

Expert
Licensed User
Longtime User
I prefer to use the constant values for new constants:


Not sure about the second error. Maybe you are using the B4J SLC tool?
Erel, definately using SLC V1.11 for building Android Libs. Have just downloaded and extracted it again to make sure I am using the right one. This is the complete error - it builds the Jar successfully but fails to create the XML. Is it maybe because I am using Java 11?

B4X:
Starting step: Compiling Java code.
javac 11.0.1

Completed successfully.
Starting step: Creating jar file.
Completed successfully.
Starting step: Creating XML file.
javadoc: warning - The old Doclet and Taglet APIs in the packages
com.sun.javadoc, com.sun.tools.doclets and their implementations
are planned to be removed in a future JDK release. These
components have been superseded by the new APIs in jdk.javadoc.doclet.
Users are strongly recommended to migrate to the new APIs.
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\gemalto\jp2\JP2Decoder.java:3: error: package android.graphics does not exist
import android.graphics.Bitmap;
                       ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\gemalto\jp2\JP2Decoder.java:4: error: package android.graphics.Bitmap does not exist
import android.graphics.Bitmap.Config;
                              ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\gemalto\jp2\JP2Decoder.java:5: error: package android.graphics does not exist
import android.graphics.BitmapFactory;
                       ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\gemalto\jp2\JP2Decoder.java:6: error: package android.os does not exist
import android.os.Build;
                 ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\gemalto\jp2\JP2Decoder.java:7: error: package android.util does not exist
import android.util.Log;
                   ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\gemalto\jp2\JP2Decoder.java:144: error: cannot find symbol
    public Bitmap decode() {
           ^
  symbol:   class Bitmap
  location: class JP2Decoder
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\gemalto\jp2\JP2Decoder.java:209: error: cannot find symbol
    private Bitmap nativeToBitmap(int[] data) {
            ^
  symbol:   class Bitmap
  location: class JP2Decoder
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\ImageUtil.java:18: error: package android.content does not exist
import android.content.Context;
                      ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\ImageUtil.java:19: error: package android.graphics does not exist
import android.graphics.Bitmap;
                       ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\ImageUtil.java:20: error: package android.graphics does not exist
import android.graphics.BitmapFactory;
                       ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\ImageUtil.java:31: error: cannot find symbol
    public static Bitmap decodeImage(Context context, String mimeType, InputStream inputStream) throws IOException {
                                     ^
  symbol:   class Context
  location: class ImageUtil
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\ImageUtil.java:31: error: cannot find symbol
    public static Bitmap decodeImage(Context context, String mimeType, InputStream inputStream) throws IOException {
                  ^
  symbol:   class Bitmap
  location: class ImageUtil
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:18: error: package android.app does not exist
import android.app.Activity;
                  ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:19: error: package android.app does not exist
import android.app.PendingIntent;
                  ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:20: error: package android.content does not exist
import android.content.Intent;
                      ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:21: error: package android.content does not exist
import android.content.SharedPreferences;
                      ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:22: error: package android.graphics does not exist
import android.graphics.Bitmap;
                       ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:23: error: package android.nfc does not exist
import android.nfc.NfcAdapter;
                  ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:24: error: package android.nfc does not exist
import android.nfc.Tag;
                  ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:25: error: package android.nfc.tech does not exist
import android.nfc.tech.IsoDep;
                       ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:26: error: package android.os does not exist
import android.os.AsyncTask;
                 ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:27: error: package android.os does not exist
import android.os.Bundle;
                 ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:28: error: package android.preference does not exist
import android.preference.PreferenceManager;
                         ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:29: error: package android.text does not exist
import android.text.Editable;
                   ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:30: error: package android.text does not exist
import android.text.TextWatcher;
                   ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:31: error: package android.util does not exist
import android.util.Base64;
                   ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:32: error: package android.util does not exist
import android.util.Log;
                   ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:33: error: package android.view does not exist
import android.view.View;
                   ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:34: error: package android.view does not exist
import android.view.WindowManager;
                   ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:35: error: package android.widget does not exist
import android.widget.EditText;
                     ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:37: error: package android.os does not exist
import android.os.Build;
                 ^
C:\Users\johans\Documents\Basic4Android\b4aProjects\PassportReader\src\com\tananaev\passportreader\MainActivity.java:97: error: cannot access ViewGroup
public class MainActivity extends AppCompatActivity {
       ^
  class file for android.view.ViewGroup not found
java.lang.NullPointerException
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$MembersPhase.runPhase(TypeEnter.java:934)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.doCompleteEnvs(TypeEnter.java:282)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$MembersPhase.doCompleteEnvs(TypeEnter.java:877)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:251)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:266)
    at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:198)
    at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:642)
    at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1326)
    at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:583)
    at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:560)
    at jdk.javadoc/com.sun.tools.javadoc.main.JavadocEnter.main(JavadocEnter.java:81)
    at jdk.javadoc/com.sun.tools.javadoc.main.JavadocTool.getRootDocImpl(JavadocTool.java:222)
    at jdk.javadoc/com.sun.tools.javadoc.main.Start.parseAndExecute(Start.java:426)
    at jdk.javadoc/com.sun.tools.javadoc.main.Start.begin(Start.java:238)
    at jdk.javadoc/com.sun.tools.javadoc.main.Start.begin(Start.java:224)
    at jdk.javadoc/com.sun.tools.javadoc.Main.execute(Main.java:174)
    at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:419)
    at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:344)
    at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
    at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
javadoc: error - fatal exception

Error.
 
Top