Invalid file path android

Problems opening pdf in Android: Invalid file path

i need to open a pdf file from my android app. I have the pdf saved in the app package folder (/data/data/com.app.example/files). I have installed in the android emulator the adobe reader app. The problem is that when i try to open the pdf file with adobe reader the emulator shows me the next message: Invalid file path.

I don’t know why is this happening but i’m stuck on this point. The file is saved correctly, because i can open it in my computer.

Here is the code:

Thanks in advance.

2 Answers 2

This is because the PDF file resides in your own package and Adobe reader trying to access PDF file from your package which is not allowed for Android application development.

You can try to save file on SDCARD and then open it

Don’t use the direct path to access files in application’s private to your application. Instead use

Not the answer you’re looking for? Browse other questions tagged java android pdf or ask your own question.

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.12.3.40888

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

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

Источник

Starting in Xamarin.Android 11.0, «error APT2144: invalid file path» can prevent building successfully because Android resources in unrecognized subdirectories are no longer silently ignored #5052

Comments

brendanzagaeski commented Aug 26, 2020 •

Steps to reproduce

  1. Create a new Mobile App (Xamarin.Forms) > Master-Detail project that targets Android.
  2. In the Solution Explorer, under the Resources\drawable directory, add a subdirectory like subdirectory.
  3. Copy the existing xamarin_logo.png resource from Resources\drawable into the new subdirectory.
  4. Build the project.

Alternatively, extract the attached test case and build it on the command line:

Expected behavior

The build should succeed.

For example, the build succeeds in Visual Studio 2019 version 16.6.5 with Xamarin.Android SDK version 10.3.1.4 (d16-6@3a10de9).

I think the relevant invocation of Aapt2Compile from the diagnostic build output is:

It appears drawable\subdirectory\xamarin_logo.png is ignored in this case. It seems only drawable\xamarin_logo.png is packaged into the app:

Actual behavior

In Visual Studio 2019 version 16.7.2 with Xamarin.Android SDK version 11.0.2.0, the build fails:

It looks like the difference is that Aapt2Compile now passes each resource path individually to AAPT2:

(I’ll omit the full list of items from ResourcesToCompile for compactness.)

Since it seems that files in unrecognized Resources\drawable subdirectories were previously silently ignored by AAPT2, this new behavior could arguably be considered more useful to help users avoid unexpected behaviors, so it might be OK to close this issue as a desirable change.

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

Источник

question

«Invalid file path» error

I added a «icons1.ttf» file under \Android\Resources\Fonts directory and VS 2019 keeps on giving the error message : «invalid file path ‘S:\Ulvi\Apps\samples\Mobile1\Mobile1.Android\obj\Debug\90\res\fonts\icons1.ttf’. And it does not build.

I also followed some comments that I should delete bin and obj directories : exited, deleted dirs and started VS again. No difference :/

Any idea what is happening ? Frustrating 🙁

4 Answers

why you want to access the font file?
If you want to use your font you can use embedded fonts.

just add the «icons1.ttf» to the shared projects’s folder and set it to EmbeddedResource.

and add the code to anywhere in your code file.
[assembly: ExportFont(«icons1.ttf», Alias = «icons1»)]

Читайте также:  Не могу взломать рут права андроид

Then you can use it in your Label.

Thanks for the hint 65841535; that’s what I eventually did anyways.

On the other hand, I simply followed-up another «set of instructions» to copy the ttf file under /Android/Resources/Fonts. Since it did not work (which is still not clear why), I just want to remove all that.

So, it still is stuck there :/

Did you set the /Android/Resources/Fonts/ttf. as AndroidAsset?

Then set the resources

then set the font-family:

«As I was writing that, I found that the resources that cause these errors would have been silently excluded from the applications in the previous versions of Visual Studio and Xamarin.Android, so I think the Xamarin.Android team might decide to keep the new behavior because it can help prevent unexpected behaviors for app authors.»

It looks like it is not wanted under «Android/Resource» tree. So I moved it to «drawable», it works.

Yet, my original issue persists. I cannot delete the «wrong» directory. This should not be so difficult :/

question details

5 people are following this question.

Источник

error: invalid file path. Can’t run in android emulator #273

Comments

Yamilquery commented May 15, 2018 •

Hi guys. I have problems to run my application in Android emulator.

package.json

Expected

Run on Android emulator

Occurred

Unable to apply changes on device: emulator-5554. Error is: Failed to build plugin nativescript-google-maps-sdk :
Error: Command ./gradlew failed with exit code 1 Error output:
error: invalid file path ‘/Users/yamildiazaguirre/Documents/node/LAaps/zafo/zafo_app/platforms/tempPlugin/nativescript_google_maps_sdk/build/intermediates/manifests/aapt/release/output.json’.

error: invalid file path ‘/Users/yamildiazaguirre/Documents/node/LAaps/zafo/zafo_app/platforms/tempPlugin/nativescript_google_maps_sdk/build/intermediates/manifests/aapt/release/AndroidManifest.xml’.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:verifyReleaseResources’.

java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

Try:
Run with —stacktrace option to get the stack trace. Run with —info or —debug option to get more log output.

BUILD FAILED in 1s

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

hackerunet commented Jun 11, 2018

I have exactly the same issue and no possible fix.

matt-psaltis commented Jul 8, 2018

So for me, I am on a Windows 10 box with a reasonably long project path. This seems to be caused by hitting max path length issues with the gradle build.

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

To diagnose this I ran:

cls && tns run android —log trace > log.txt

This gave me the gradlew.bat command line that was being executed. I ran it manually:

cls && platforms\android\gradlew.bat «-p» «

\platforms\tempPlugin\nativescript_google_maps_sdk» «assembleRelease» «-PcompileSdk=android-27» «-PbuildToolsVersion=27.0.3» «-PsupportVersion=26.0.0-alpha1»

platforms\tempPlugin\nativescript_google_maps_sdk\build\intermediates\res\merged\release\drawable-xxhdpi-v4\common_google_signin_btn_icon_light_normal_background.9.png: error: file not found.

platforms\tempPlugin\nativescript_google_maps_sdk\build\intermediates\res\merged\release\drawable-xxhdpi-v4\common_google_signin_btn_icon_dark_normal_background.9.png: error: file not found.

platforms\tempPlugin\nativescript_google_maps_sdk\build\intermediates\res\merged\release\drawable-xhdpi-v4\common_google_signin_btn_text_light_normal_background.9.png: error: file not found.

platforms\tempPlugin\nativescript_google_maps_sdk\build\intermediates\res\merged\release\drawable-xxhdpi-v4\common_google_signin_btn_text_light_normal_background.9.png: error: file not found.

platforms\tempPlugin\nativescript_google_maps_sdk\build\intermediates\res\merged\release\drawable-xhdpi-v4\common_google_signin_btn_icon_light_normal_background.9.png: error: file not found.

platforms\tempPlugin\nativescript_google_maps_sdk\build\intermediates\res\merged\release\drawable-xxhdpi-v4\common_google_signin_btn_text_dark_normal_background.9.png: error: file not found.

Most of these file paths exceeded 240 characters (when you include the full project path).

I created a junction point with mklink to shorten the path to my project and it built successfully.

Источник

question

[Android] Invalid file path

I can’t build my XF solution anymore, due to a build error such as:

Error invalid file path ‘R:\Levitica\AWDServiceMobile\AWDServiceMobile\AWDServiceMobile.Android\obj\Debug\110\res\logo.png’. AWDService.Android

I tried to clean the entire solution, manually delete all the obj and bin folders, restart VS 2019, rebuild. no luck. I always get the same error, but if I open that path in file explorer, the log file is there:

Last time I built the solution was when I made a package for the store, no changes after that except VS 2019 updates.

Is there a way to solve this and keep working?

1 Answer

Welcome to our Microsoft Q&A platform!

Error invalid file path ‘R:\Levitica\AWDServiceMobile\AWDServiceMobile\AWDServiceMobile.Android\obj\Debug\110\res\logo.png’. AWDService.Android

Please move your logo.png file to the Drawable folder or mipmap- folders(if you want to make your logo.png as application icon), do not put it in the Resource folder directly.

I notice your png’s name is logo.png , if you want to change a new icon for your application. Here is thread about changing the icon for xamarin application.

If you want to know more details about there folders in the Drawable path, you can refer to default-resources thread.

If the answer is the right solution, please click «Accept Answer» and kindly upvote it. If you have extra questions about this answer, please click «Comment».

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Источник

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