Calsign / APDE

Source code for APDE: Create and run Processing sketches on an Android device.
GNU General Public License v2.0
348 stars 76 forks source link

compileSdkVersion #101

Closed EmmanuelPil closed 2 years ago

EmmanuelPil commented 3 years ago

@Calsign Due to Android's mandatory use of Scoped Storage on Android 11 I have to use MediaStore.MediaColumns.RELATIVE_PATH In this code snippet I get the error: "sketch [106]: RELATIVE_PATH cannot be resolved or is not a field"

private File createImageFile() throws IOException { 
  String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); 
  String imageFileName = "JPEG_" + timeStamp + "_"; 
  ContentResolver resolver = context.getContentResolver(); 
  ContentValues contentValues = new ContentValues(); 
  contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, imageFileName); 
  contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg"); 
  contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DCIM); 
  Uri uri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
}

To make the string acceptable I need to set the targetSdkVersion to 29, but it seems that I also need to set the compileSdkVersion to 29. How can I do that? Thanks in advance.

Calsign commented 2 years ago

I know this is very old, but I'm responding for posterity.

compileSdkVersion refers to the version of the Android platform that the sketch is compiled against. Practically, I think this means the version of the platform that android.jar in assets was taken from. Unfortunately, APDE does not currently let you change the version of android.jar because it is packaged as part of APDE. I am about to update it (for a future release), to API level 29 incidentally.

APDE could have an option to let you select an alternate, user-supplied android.jar as a means of getting around this.