I open the project: ML Kit Vision Quickstart. https://github.com/googlesamples/mlkit/tree/master/android/vision-quickstart Build and run on phone with no problem. I want to save an object created by the program with Shared Preferences but when I create a new object this error apear:
('PoseLandmark(int, com.google.mlkit.vision.common.PointF3D, float)' is not public in 'com.google.mlkit.vision.pose.PoseLandmark'. Cannot be accessed from outside package)
This class PoseLandmark is read only. And there is 2 clickable link "Download Sources" and "Choose Sources". When a go to the Download sources the task fails with the message:
Task :app:DownloadSources FAILED 1 actionable task: 1 executed
FAILURE: Build failed with an exception.
Where: Initialization script '/tmp/ijmiscinit1.gradle' line: 20
What went wrong: Execution failed for task ':app:DownloadSources'. Could not resolve all files for configuration ':app:downloadSources_0dad3cd2-2bde-4430-8d97-b0c59cc95ab3'. Could not find com.google.mlkit:pose-detection-common:17.1.0-beta2@aar. Required by: project :app
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 5s 23:52:38: Task execution finished 'DownloadSources'.
I try to change this version on the gradle.build file from:
implementation 'com.google.mlkit:pose-detection:17.0.1-beta3
to:
implementation 'com.google.mlkit:pose-detection:17.0.1-beta2
but didn't work!
And I already try many things: invalidate cache/restart, remove .idea and .gradle files, import project again, download files again, install new version oh the studio...
Someone have some suggestion of how can I save this object?
Edit: The object is created here:
@Override
public void draw(Canvas canvas) {
List<PoseLandmark> landmarks = pose.getAllPoseLandmarks();
if (landmarks.isEmpty()) {
return;
}
And used in the sequence:
for (PoseLandmark landmark : landmarks) {
drawPoint(canvas, landmark, whitePaint);
if (visualizeZ && rescaleZForVisualization) {
zMin = min(zMin, landmark.getPosition3D().getZ());
zMax = max(zMax, landmark.getPosition3D().getZ());
}
}
Maybe a can workaround.
I want to save an object created by the program with Shared Preferences
Could you provide the code snippet about how you save the object? What object are you trying to save? Are you using the gson library or something similar?
PoseLandmark(int, com.google.mlkit.vision.common.PointF3D, float) is the constructor for PoseLandmark. It is not public. That is probably why you cannot access it.
Currently, you cannot construct a Pose object by yourself. It is not part of the API. To workaround, could you consider extracting the information you need out of Pose and store them in a class you define?