zburns 0 Posted December 7, 2020 I have an employee that used our custom apps built for Android 25.x.x and they did not work on his Android 11 OS (he got a new Google Pixel phone). So I wanted to change the SDK so I could build for a newer version of Android (OS Version 10). Now I think it's all messed up. How can I reset RAD Studio's setup and or fix the wrong SDK/NDK. I have screen shots showing my issue. I've setup my SDK/NDK and Java tools - it's not complaining, but it doesn't build my app - so I'm confused. [Exec Error] EXEC(1): Could not create the Java Virtual Machine. [Exec Error] EXEC(1): A fatal exception has occurred. Program will exit. [Exec Error] The command "PATH C:\Program Files\Java\jdk-15.0.1\bin;C:\Users\Public\Documents\Embarcadero\InterBase\redist\InterBase2020\IDE_spoof;C:\Program Files\Android\Android Studio\jre\bin;C:\Program Files (x86)\Embarcadero\Studio\21.0\bin;C:\Users\Public\Documents\Embarcadero\Studio\21.0\Bpl;C:\Program Files (x86)\Embarcadero\Studio\21.0\bin64;C:\Users\Public\Documents\Embarcadero\Studio\21.0\Bpl\Win64;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\dotnet\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files (x86)\nodejs\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\Users\Zachary Burns\AppData\Local\Microsoft\WindowsApps;C:\Users\Zachary Burns\AppData\Roaming\npm;C:\Users\Zachary Burns\AppData\Local\Microsoft\WindowsApps; & "C:\Users\Public\Documents\Embarcadero\Studio\Android\Sdk\build-tools\30.0.2\dx.bat" --dex --output="C:\Users\Zachary Burns\Documents\Embarcadero\Studio\Projects\MidasCCDMobile\Android64\Release\classes.dex" "c:\program files (x86)\embarcadero\studio\21.0\lib\android\Release\android-support-v4.dex.jar" "c:\program files (x86)\embarcadero\studio\21.0\lib\android\Release\cloud-messaging.dex.jar" "c:\program files (x86)\embarcadero\studio\21.0\lib\android\Release\fmx.dex.jar" "c:\program files (x86)\embarcadero\studio\21.0\lib\android\Release\google-play-billing.dex.jar" "c:\program files (x86)\embarcadero\studio\21.0\lib\android\Release\google-play-licensing.dex.jar" " exited with code 1. Share this post Link to post
zburns 0 Posted December 7, 2020 Ok....well I just re-installed NDK and SDK from the Additional Options under RAD Studio and rebuilt my application. It works on Android 9 and Android 10, but not the new Android 11 - stating to contact the developer. Checking out the platform status page - looks like Android 11 isn't supported anyway, so I'm in limbo waiting for a service pack to be released by Embarcadero I guess. That probably won't happen for another 3+ months.....so my guess is my two users (another one bought a phone today) will be out of luck. Share this post Link to post
Dave Nottage 557 Posted December 8, 2020 8 hours ago, zburns said: Checking out the platform status page - looks like Android 11 isn't supported anyway It's yet to be officially supported, however you can build apps with 10.4.1 that will run on Android 11 devices. 8 hours ago, zburns said: stating to contact the developer What is the exact message? Is this an app that was created in an earlier version of Delphi? Share this post Link to post
zburns 0 Posted December 11, 2020 Jim McKeeth had a good article (as always) that I found. It related to Rio 10.3 - but still basically applies for Sydney 10.4 http://delphi.org/2019/06/manually-installing-android-sdk-ndk-and-java-for-firemonkey-development/ I think some of my issue is terminology and all the numbers floating around surrounding SDK version vs NDK version vs Build Tools version, etc. Confusing, but I guess that's why the Android world is a little complex. I rebuilt the app for Android Level 29 64-bit (Android version 10) - which should work. I've asked the user to try and install that and report back. Share this post Link to post
Guest Posted December 11, 2020 hi @zburns in fact, the SDK and NDK is not properly "installed"... but just unziped and copyed to your drive, and, it do use of .bat files and others files in your configuration - nothing in Registy basically. then, you can "copy" from any other pc (the same version used of course) for your pc later, just use "menu" from your IDE to config your SDK Manager and it's ready for use! in my case, my RAD 10.3.3 Arch is in C:\EMB\Studio\200 and my SDK/NDK is in D:\Platforms\XE103NDKr17b and XE103SDKWin then, if I format my drive C for example, I never re-copy or re-"install" it, just config it in my IDE installed! - in case, for RIO edtion! Share this post Link to post
zburns 0 Posted December 11, 2020 emailx45: Thanks - yes - it totally makes sense now after thinking through it. I was going to create a quality issue with Embarcadero asking for a better way to handle installation, but I think they are doing it right. So I didn't make a ticket. I checked with the user again and it does install and does work, but he gets the following error accessing his camera (where other non-Android 11 users do not get an error). So I'll have to track this Android 11 problem down - or just wait for Embarcadero to bless Android 11 development. Share this post Link to post
Guest Posted December 12, 2020 (edited) hi @zburns I am not an xpert in Delphi or Android, but what I can tell you is that all access, even for reading properties (depending on the class / component) you are using, requires verification of the access privilege. and always, verifying if my object is not null/nil For example, using the "TVideoCaptureDevice" class (base class to "CameraComponent") , you can easily access CAMs on your device. I don't know if you have used it? !!! So, I check the permission when reading or writing values in the properties of this class (or, in the device in question). for example, when accessing my CAM in my smartphone Moto G4, my Android is 7.0 Nougat procedure TfrmFormMain.prcCAMStartCapture; begin if not(lMyCAMDevice = nil) then begin // to Mobile (Android), change properties from CAMERA, needs permission! {$IF DEFINED(ANDROID)} if PermissionsService.IsPermissionGranted(lMyCAMPermission) then {$ENDIF} begin try lMyCAMDevice.StopCapture; // to avoid any error below // lMyCAMDevice.Quality := TVideoCaptureQuality.PhotoQuality; // lMyCAMDevice.StartCapture; // starting video capture! // prcMyLog('CAM device = Capture stated!'); prcMyLog('CAM ' + fncMyIIF(lMyCAMDevice.IsDefault, 'is', 'is not') + ' Default'); prcMyLog('CAM ' + fncMyIIF(lMyCAMDevice.HasFlash, 'has', 'has not') + ' Flash'); except on E: Exception do prcMyLog('Error Start CAM' + #13#10 + E.Message); end; end {$IF DEFINED(ANDROID)} else TDialogService.ShowMessage('Then CAM device needs your permission to access it!'); {$ENDIF} end else TDialogService.ShowMessage('None CAM device defined!'); end; and, when close my app test ... if not(lMyCAMDevice = nil) then begin {$IF DEFINED(ANDROID)} // if PermissionsService.IsEveryPermissionGranted([lMyCAMPermission]) then; if PermissionsService.IsPermissionGranted(lMyCAMPermission) then {$ENDIF} begin if (lMyCAMDevice.State = TCaptureDeviceState.Capturing) then lMyCAMDevice.StopCapture; end; ... hug Edited December 12, 2020 by Guest Share this post Link to post
zburns 0 Posted December 29, 2020 @emailx45 Thanks for the snippet - I will try that and see. For others, I also went back to the following as a starting point - I believe something changed between 10.3.x and 10.4.x with TPlatformServices (or my setup) as I can't get the following to work. http://docwiki.embarcadero.com/RADStudio/Sydney/en/Taking_Pictures_Using_FireMonkey_Interfaces I've even tried it in the "Hunter Beta" and same result - so either I've totally messed up something, or something changed when building with 10.4.x and Hunter and I missed the notice. Attached a sample project that demonstrates the link - and have attached for others - notice the code "should" work, but does not. I filed a Hunter Beta bug with Embarcadero also. TestCamera.zip Share this post Link to post
Guest Posted December 29, 2020 hi @zburns you're wellcome if it's all right, click on "thanks" Share this post Link to post
Dave Nottage 557 Posted December 29, 2020 37 minutes ago, zburns said: Attached a sample project that demonstrates the link The test project: Does not have "Secure File Sharing" checked in the Entitlements section of the Project Options, Does not request the required permissions at runtime. Fixing these makes it work for me on Android 11. Share this post Link to post
zburns 0 Posted December 29, 2020 Thanks Dave....would have never thought to turn on "Secure File Sharing" A quick question.....Do I have to request camera and storage permissions at runtime, or can I set them in App Info->Permissions.....I tried this, but no joy. So wondering if it's setting some other type of permission when you prompt the user. Share this post Link to post
Guest Posted December 29, 2020 (edited) in Project-Options, you define "that" you'll needs this permissions: in run-time, you use it! some like this! you see? each access, is necessary always verify the permission, because, the Android can revoke it! you see? some permissions is not necessary "ask", like: use wifi, for example! see in "Android Developer Studio" site about permissions! Edited December 29, 2020 by Guest Share this post Link to post
Guest Posted December 29, 2020 my sample for tests in Android procedure TfrmFormMain.sbtnCAMStartCameraClick(Sender: TObject); begin {$IF DEFINED(ANDROID)} PermissionsService.RequestPermissions( { } [lMyCAMPermission], { } prcPermissionsResulted, { } prcDisplayRationale { = nil, if you DONT WANT show any message! } ); {$ELSE} prcCAMStartCapture; // MSWindows or macOS {$ENDIF} end; {$IF DEFINED(ANDROID)} // DisplayRationale and PermissionsResulted is used only mobile! procedure TfrmFormMain.prcDisplayRationale(Sender: TObject; const APermissions: TArray<string>; const APostRationaleProc: TProc); var lRationaleMsg: string; i : integer; begin for i := 0 to high(APermissions) do begin if APermissions[i] = lMyCAMPermission then lRationaleMsg := lRationaleMsg + 'This app needs access your CAM to works' + SLineBreak + SLineBreak; end; // // Show an explanation to the user *asynchronously* - don't block this thread waiting for the user's response! // After the user sees the explanation, invoke the post-rationale routine to request the permissions // TDialogService.ShowMessage(lRationaleMsg, procedure(const AResult: TModalResult) begin // TProc is defined in System.SysUtils // APostRationaleProc; // used by System to go-back in before function... end) end; procedure TfrmFormMain.prcPermissionsResulted(Sender: TObject; const APermissions: TArray<string>; const AGrantResults: TArray<TPermissionStatus>); begin // verifying if the permissions was granted! - Here, testing only 1 permission = CAM if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then prcCAMStartCapture { execute your procedure here if all it's ok } else TDialogService.ShowMessage('The permission <<CAMERA access>> not allowed by user'); end; {$ENDIF} {$IF DEFINED(ANDROID)} lMyCAMPermission := JStringToString(TJManifest_permission.JavaClass.CAMERA); {$ENDIF} hug Share this post Link to post
Guest Posted December 30, 2020 (edited) my sample complete: thanks to Fernando Rizzato - MVP Embarcadero lead South America by tips! Edited December 30, 2020 by Guest Share this post Link to post