Android failed to mkdir

Unable to deploy example NDK app to Android 9: ‘remote secure_mkdirs failed: Operation not permitted’ #77

Comments

jgavris commented Sep 18, 2018 •

I’m running bazel 0.17.1, android NDK r17b. When I try to deploy to an Android 9 device I get:

The text was updated successfully, but these errors were encountered:

jin commented Nov 17, 2018

Does regular adb install work? Looks like adb push under Bazel doesn’t have the correct permissions.

As an aside and mentioned in the Slack chat, we’re in the process of open sourcing mobile-install v2. It’s a complete rewrite of mobile-install in Starlark, and thereafter we will deprecate the native mobile-install in Bazel. AFAIUC, mi-v2 will solve this issue.

pandasyr commented Nov 29, 2018

I had this happen before and for me it was because the apk signature mismatch (because I switched computer), which was solved by uninstalling the old apk.

jgavris commented Nov 29, 2018

A regular install works, yes. That’s what we’re using in Android Studio.

jin commented Dec 11, 2018

Update: I managed to repro the issue and found the root cause.

Somewhere between 28 and 29, when creating directories as part of adb push , the behavior changed w.r.t. directory permissions.

On 28, the created directories via adb push have the permissions drwxrwxr-x .
On 29, the permissions are drwxrwx—x . The difference is the read permission for others . For some reason, this causes the adb push to fail.

Источник

Android failed to mkdir() on SD card

I have some code to create/get a folder on SD card:

and I have the permission registered in my Manifest file:

but when I run it, it prints:

I was wondering why this happens?

I have tried all of them:

But they all behave exactly the same.

I am testing with Nexus 5. I saw this post Cannot find storage/emulated/0/ folder of Nexus 7 in Eclipse There might be some issue?

Here is my hasSD() method:

Answers

EDIT: you have misspelled your permission (you have STOREAGE, whereas the correct one is STORAGE)

Unless you’re not doing it already in hasSDCard(), please check if your external media is available at all. As the docs say:

Before you do any work with the external storage, you should always call getExternalStorageState() to check whether the media is available. The media might be mounted to a computer, missing, read-only, or in some other state.

An example they provide:

Читайте также:  Солид воркс для андроид

Hi You can write data to bytes and then create a file in sdcard folder with whatever name and extension you want and then write the bytes to that file. This will save bitmap to sdcard.

I don’t believe there is a way to check for dual sd-cards, but some devices do have 2 types of external storage. For example, I know on some motorola devices, the internal secondary storage is accessed with /sdcard-ext . You could check to see if this directory exists (I know that other devices with secondary storage also use the -ext append) and react accordingly.

does not match this:

Use the same algorithm in both places. So, replace the second line with:

That will get you past the NullPointerException .

does not match this:

Since I don’t know which of those is what you really want, I cannot suggest a fix.

The following is from a blog post that I just published, reproduced here because, hey, why not?

You can put a custom ringtone on a Notification , via methods like setSound() on NotificationCompat.Builder . This requires a Uri , and that causes problems on Android 7.0, as is reported by a few people on Stack Overflow.

If you were using file: Uri values, they no longer work on Android 7.0 if your targetSdkVersion is 24 or higher, as the sound Uri is checked for compliance with the ban on file: Uri values.

However, if you try a content: Uri from, say, FileProvider , your sound will not be played. because Android does not have read access to that content.

Here are some options for addressing this.

The Scalpel: grantUriPermissions()

You can always grant permissions for content to other apps via grantUriPermissions() , a method available on Context . The challenge is in knowing who to grant the permissions to.

What works on a Nexus 6P (Android 6.0. still. ) and a Nexus 9 (Android 7.0) is:

(where sound is the Uri that you are using with setSound() )

Whether this will hold up for all devices and all Android OS versions, I cannot say.

The Guillotine: No More User Files

android.resource as a scheme works fine for Uri values for setSound() . Instead of allowing users to choose their own ringtone from a file, you only allow them to choose one of several ringtones that you ship as raw resources in your app. If this represents a loss of app functionality, though, your users may be unimpressed.

The Axe: Use a Custom ContentProvider

FileProvider cannot be used when it is exported — it crashes on startup. However, for this case, the only content: Uri that will work without other issues is one where the provider is exported and has no read access permissions (or happens to require some permission that com.android.systemui or the equivalent happens to hold).

Читайте также:  Мап фактор для андроид

Eventually, I’ll add options for this to my StreamProvider , as part of some «read only» provider functionality.

But, you could roll your own provider for this.

The Chainsaw: Ban the Ban

The following code snippet blocks all StrictMode checks related to VM behavior (i.e., stuff other than main application thread behavior), including the ban on file: Uri values:

Alternatively, you could configure your own VmPolicy with whatever rules you want, just without calling detectFileUriExposure() .

This allows you to use file: Uri values anywhere. There are good reasons why Google is banning the file: Uri , and so trying to avoid the ban may bite you in unfortunate body parts in the long term.

The Nuke: Use a Lower targetSdkVersion

This also removes the ban on file: Uri values, along with all other behavior that a targetSdkVersion of 24+ opts into. Of note, this will cause your app to display a «may not work with split-screen» Toast if the user enters split-screen multi-window mode.

The Real Solution: A Fix in Android

The NotificationManager should be calling grantUriPermissions() for us, or there should be some other way for us to associate FLAG_GRANT_READ_URI_PERMISSION with the Uri that we use for custom Notification sounds. Stay tuned for further developments.

Источник

Сообщение read only file system в android

Установил adb, сделал при помощи usb_modeswitch что бы adb видело устройство, получил рут права через superoneclick, вроде бы все хорошо и можно спокойно заходить через adb shell вот только при выполнении практически любой серьезной команды пишет сообщение read only file system. Вот так например:

По умолчанию начинаешь в корне, ведройд всё монтирует в ro, остальное анально огораживает через selinux, потому ты без соответствующих разрешений в манифесте приложения пукнуть не можешь даже на флешке.

Но вернёмся к adb. Тут всё куда проще, нужно просто перемонрировать fs в rw, делается это так: #mount -o rw,remount mountpoint, в твоём случае корень скорее всего.

Большое вам спасибо, ввел команду mount -o rw,remount mountpoint / и все заработало!

-_- mountpoint не нужно было писать. Под mountpoint подразумевалось то, что нужно перемонировать, т.е. / или /system или /data или что тебе там надо.

Если это то самое устройство со вторым андроидом из прошлой темы, то там selinux нет.

Источник

error ADB1000: Xamarin.AndroidTools.AndroidDeploymentException: FailedToSynchronizeFastDevAssemblies —> Mono.AndroidTools.AdbException: secure_mkdirs failed: Permission denied #5147

Comments

pmahend1 commented Sep 23, 2020 •

Steps to Reproduce

  1. Download Visual Studio 2019 Preview 8.3 or Visual Studio for Mac Preview 8.3
  2. Create Xamarin forms solution
  3. Target android project to API level 30 (Android 11) in both manifest and compilation levels
  4. Turn on Shared Debug runtime and Fast Debug options
  5. Build and try to deploy android project to Android 11 emulator
Читайте также:  Русификатор для dead space для андроид

Could be related to #4996

Expected Behavior

Fast debug should work with new Xamarin android 11 changes

Actual Behavior

Not deploying app.

Version Information

Log File

adb log and msbuild.log shared over email to @dellis1972

The text was updated successfully, but these errors were encountered:

brendanzagaeski commented Sep 23, 2020 •

I just thought of one idea for a first quick check that might be interesting to test if you get a chance. If you replace the Mono.Android.DebugRuntime-*.apk in the Visual Studio Preview installation with the versions from #4996 (comment) similar to how you tested before, does that by chance resolve the problem again?

The default installation location for the Mono.Android.DebugRuntime-*.apk files to replace in the Preview version is:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android

Источник

error building image: error building stage: failed to get filesystem from image: mkdir /usr/share/file/magic: not a directory #1469

Comments

Anugushashank commented Oct 28, 2020 •

Actual behavior
When kaniko executor is run as a binary from another image, it fails with error
error building image: error building stage: failed to get filesystem from image: mkdir /usr/share/file/magic: not a directory

This issue occurs only when there is a difference in filesystem of container image and the base image of the dockerfile. Ex: /usr/share/file/magic is a directory in the base image whereas it a file in container filesystem.

Why is this happening:
While building a stage, FS is extracted in each layer from tar and gets created on the container except for the mounted directories. While extracting the FS, if there is a dir(/usr/share/file/magic) which needs to be created on the container, and there is already a file(/usr/share/file/magic) with same path on the container then an error( not a directory ) is thrown

Expected behavior
Kaniko executor should not fail while creating a dir if there is already a file with the same path.

There should be a check here, if there exists a file with the dir path then it should be deleted before proceeding with the dir creation

To Reproduce
Steps to reproduce the behavior:

  1. Build this dockerfile using docker and tag it as container_image, docker build -t container_image .
  1. Build below docker file using kaniko executor from above created image, docker run -v :/workspace container_image /kaniko/executor —dockerfile /workspace/Dockerfile —no-push —verbosity=trace
  1. Above build fails with error error building image: error building stage: failed to get filesystem from image: mkdir /usr/share/file/magic: not a directory

Additional Information

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
Please check if the build works in docker but not in kaniko
Please check if this error is seen when you use —cache flag
Please check if your dockerfile is a multistage dockerfile

The text was updated successfully, but these errors were encountered:

Источник

Оцените статью