PhoneGap 1.3 to 1.5 upgrade - android

I have an application for Android using phonegap 1.3.0 and was trying to update to 1.5 (Cordova).
I switched the .jar file, the XML file, and the JS file, and the application builds fine.
But when I run the application and try to access the FileSystem it fires an error with code 5 (FileError.ENCODING_ERR, supposedly).
If I run the Eclipse project which has the 1.3 version, I have no problem at all.

I think this is a bug in Android's Cordova 1.5.
FileUtils.java:161 assumes that the arg[1] is a file name not a full path.
But if you look at cordova-android-1.5.0.js:2360 they are passing the path as the second arg, for which you probably provided something like "file:///mnt/sdcard/somefile.data".
So when this path is given to FileUtils.java:129 as a filename, it fails the check on line 640, and throws a EncodingException. To fix it, make sure you send the fileName and not a path or URL.

Related

Visual Studio 2017 - Xamarin - The file "obj\Debug\android\bin\packaged_resources" does not exist

I'm fighting with that issue for 2 days already and can't find any solution.
I have an Xamarin Android app in Visual Studio 2017 consisting of three projects:
Xamarin.Android project (main one)
Android-specific unit tests run on the device - project of type NUnit 3 Test Project (Android) created using NUnit Templates for Visual Studio
Platform-independent unit tests project (project of type Unit Test Project (.NET Framework))
Everything worked just fine until now. When I selected my main project as the Startup one, my app was deployed to the device/emulator. When I selected my Android-specific unit tests project, the test project was deployed and unit tests executed by nUnit Xamarin Runners on the device/emulator.
However few days ago I updated my Visual Studio 2017 with the newest available update and now, when trying to build this android-specific unit tests project I get the following error:
The file "obj\Debug\android\bin\packaged_resources" does not exist.
I've searched everywhere, including this and this SO topics. I also totally reinstalled Visual Studio 2017 and Xamarin with Android SDK included. Nothing helped. From what I read I suspect there is something wrong with the versions of Android SDK Build-tools I have installed. Here's what I have currently installed in SDK Manager:
As the other SO threads suggested, I tried uninstalling the newest Android SDK Build-tools (25.0.2) and installed version 23.0.3 (all my projects target Android 6.0), but it also doesn't help, I still have the same error.
Maybe it's worth adding that this issue may have started to happen when I tried to implement RecyclerView in my app reading this tutorial, where they suggested to install Android 7.1.1 (API 25) in SDK Manager. However I undoed my all changes after that and even reintalled VS2017 + Xamarin.
Do you have any other idea why this can be ? I'd really appreciate any help. Thanks!
EDIT 2017-04-09:
Egh, I removed VS2017, installed VS2015 with brand new Android SDK and still the same issue :(
I've finally found what was the issue. It wasn't related to any component from SDK Manager or VS version.
Following localization tutorial from developer.xamarin.com, I played a bit with Strings.xml in my Android project. I wanted to have my Activities Label taken from resources as well, so in the ActivityAttribute I defined:
[Activity(Label = "#string/peopleListTitle")]
and added this value in Strings.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-------Other resources values ----->
<string name="peopleListTitle">People List</string>
</resources>
In that case my build is failing with above-mentioned error:
The file "obj\Debug\android\bin\packaged_resources" does not exist
When I change ActivityAttribute to use a string directly:
[Activity(Label = "People List")]
the build is passing without any issues.
I managed to find a solution, but actually I don't know why it's not building when I try to use Label text defined in Strings.xml.
BTW, I managed to find what's the problem by setting build output verbosity to Diagnostic in Tools -> Options -> Projects and Solutions -> Build and Run which gives a detailed info why the build failed in the Output window.
I had the same problem. After removing the dash "-" sign from the image file name, the problem is solved. Bad error message! It should not be:
The file "obj\Debug\android\bin\packaged_resources" does not exist.
Writing an error message like this causing the Developer to think about something else while the problem is the illegal file name.
I had the same issue when I added a new image as a resource.
There was a '-' in the file name (Invalid resource name character). I renamed & removed that character and all good.
Resource name can only consist of 0-9,a-z or A-Z or combination of any.
I had the same problem, and i removed all image file name have "-" character. My problem solved
Another reason for this error is that you may have a float number as your version number. In my case I changed it to a integer and everything worked fine. (I found the error by switching the build output to Detailed)
Simply it worked.
In one case I copied and pasted previous working "packaged_resources"
in the bin folder.[the problem was it did not reflect the UI changes]
Other I opened the visual studio as
administrator.
Next changed the "Minimum target to Android" to lower
apis in the project properties windows.
I suggest not touching the code behind of the design. If you get this error simply pull some button from the tool bar into the design and visual studio will come to its consciousness that there is change in UI. Next click on save all so that it make necessary change in the designer file.
Mine was a different solution (and only half a day lost): I was having trouble getting Hockey app to match crashes against the correct version of the app and realised it uses VersionCode not VersionName so I change my code to "0.0.34" the same as the name. For some still unknown reason the app built and deployed to devices for about 3 days before I started getting this error The file "obj\Debug\android\bin\packaged_resources" does not exist. Setting it back to a numeric value fixed the problem.
I found the problem by looking back through my GIT logs and rebuild each push until I found the one that caused the problem.
It just because the Version Code,I set Code by '1.0',The file "obj\Debug\android\bin\packaged_resources" does not exist.;And I set it by '1',everything is ok.
Had the same error, the way I got over it was crank up the Android SDK manager and install all updates and remove any obsolete packages. This happened to me because I was targeting something newer which was not installed.
Check to see if there are any unused entries in resources.designer.cs if there are any manually remove those entries.
This will fix the issue.
After following several online suggestions - updating SDK, updating Xamarin etc - none of which worked for me.
Finally found that I had an activity for a Android provider to Alarm clock in my AndroidManifest file as below
<activity
android:name="com.njcommuter.droid/android.provider.AlarmClock"
android:label="AlarmClock"
.....
/>
Removing this line - and rebuilding worked fine without any errors and was able to deploy solution successfully.
Note : testing this by putting the line back, and I get same error again on rebuilding.
It can be linked to using any android provider which creates the package for it, not necessarily AlarmClock only.
This error is, somewhat of, a wrapper for what can be multiple reasons that that the file was not created. The key is to look in the detailed output and look for the underlying error causing the file creation failure.
In my case, I had corrupted icon.png files (generated right from from the VS xamarin nunit template, no less!). Once I put in valid png files, everything was built fine.
Another reason for this error, if that the android NDK (not android SDK) isn't right, change de version can resolve the problem: go to Tools/Options/Xamarin/android Configurator and change de folder, in my case I've three, the last one can't compile, but the second folder with version xx.r11c do it.
For me it was Target Android Version.I had it set to
but changing it to Compiling version(for me it was the latest platform) resolved the issue.

CordovaResourceApi import unresolved phonegap

I am using phonegap-2.9.0 with file plugin. When I build project for android platform it creates two packages within the src/ folder:
org.apache.cordova.file
org.apache.cordova.filetransfer
I get below errors within these two packages:
1 - org.apache.cordova.file.FileUtils
Method testSaveLocationExists() from the type DirectoryManager is not visible
Method getFreeDiskSpace() from the type DirectoryManager is not visible
Method testFileExists() from the type DirectoryManager is not visible
2 - org.apache.cordova.filetransfer.FileTransfer
import org.apache.cordova.CordovaResourceApi unresolved
import org.apache.cordova.CordovaResourceApi.OpenForReadResult unresolved
Could someone please tell me what I should do to resolve these?
Thanks.
You have two problems.
1) Version of Phonegap is outdated
2) The way to install a plugin is:
-> phonegap plugin add "urlofplugin" or "/path""
-> phonegap platform add android
-> phonegap prepare
-> phonegap build
sometimes the plugin has a different default installation, the files need to change the platform.
Well, I dont know if I can help you, but I had similar problems. When I installed exactly those two plugins I got an error too. A different one, which I dont perticularly remember, something to do with a missing file that I can easily find in the file manager. Anyway, what helped me was:
I updated to a more recent version, if you are able to I advice for it.
After installing the plugins through cordova cmd api (.nodejs command prompt ... you know what I mean) I was forgetting to build in the api itself. It sounds stupid but I was using wp8 and thus using a template for visual studio. The studio gave me the error, the building process (in cmd) also gave errors, but it was fixed by updating to the newer version.
You need to configure you build path and then add library from external source and select the library then it will resolve or u can make copy and paste cordova library .jar file in your lib folder. then it will remove, if not happen then tell me .......
I am not sure if that will work but first uninstall these plugins using phonegap/cordova CLI and than reinstall it in the root of application folder using the CLI only like this:
phonegap local plugin add <required plugin>
This worked for me after reinstallation.

Android OCR Application Using Tesseract

I am currently developping an android application based on OCR (Optical Character Recognition). I've downloaded the "tesseract- android" project that contains tools for compiling the Tesseract, Leptonica, and JPEG libraries for use on Android. I am developping via Eclipse on Windows Vista OS.
I've also downloaded the necessary tools (android-ndk;apache ant..), and I've done carefully all the steps to build this project and add it as a library to my basic application.
My app consists of opening the camera for taking a picture and then processing this picture via tesseract API in order to transform it into text.
My question is:
1. Is it true that this procedure doesn't work under Windows OS?
2. When compiling, I am having the following error:
"java.lang.IllegalArgumentException: Data path must contain subfolder tessdata!"
What could be the potential error? The concerned portion of the java code is:
File myDir = getExternalFilesDir(Environment.MEDIA_MOUNTED);
TessBaseAPI baseApi = new TessBaseAPI();
baseApi.init(myDir, "eng");
I've also tried to use "/tess-two/external/tesseract-3.01/tessdata/tessconfigs" instead of "myDir", but the error remains the same.
I would highly appreciate any help.
Thanks in advance.
Q1. It should work on any operating system, I've been able to ndk-build on Win7, Mac OS Lion, and Ubuntu without any issues.
Q2. Make sure that you have permissions to write to the external storage, and have sufficient space to do so.
If that still fails, have a look at the DDMS and see the file explorer and double check your application is setting up the directory structure and copying over the traineddata.
I had an odd issue where it was creating the eng.traineddata file, but it was 0 bytes which led to all sorts of odd issues.
You could also create the directory structure manually to get you progressing, and fix this initialisation issue later on (but don't forget it!)
I was facing the same problem. Worked for me when I removed "tessdata" from the path.
Before (fail): path = "/mnt/sdcard/tesseract/tessdata";
After (success): path = "/mnt/sdcard/tesseract/";
Then, baseApi.init(path, "eng") worked with no exceptions.
Of course, tessdata folder should be in the path with the desired.traineddata file.
Path errors while compiling native stuff usually is not related with your java code. Your java code would be responsible for runtime problems. Check your build scripts and post more log messages.

Unity Android plugin - package rename issue

I'm developing a simple plugin to Unity Android, that displays an image from the web.
I've created a Jar using my Java files, and loaded it (in a blank Unity sample application) using AndroidJavaClass.
All worked fine, but then I've wanted to rename my Java package.
From now on - I can't see the image. The plugin doesn't even trying to access it.
I've changed the package name in the Java files, and also in the AndroidManifest.xml and in the CS file that's calling it.
The Jar compiles successfully, the application runs on the device, but... nothing.
I've also created a new application that uses the plugin with his new name, but no success.
What have I done wrong?
Or - what can I do to make it work?
Thanks,
Keren
Why would you code a plug-in to display a web image ?
Just use unity native WWW call, then put the result in a texture.
Look at the unity docs.

How to build Android NDK sample: "bitmap-plasma"

I am trying to build the bitmap-plasma sample that is included with the ndk, but getting an error. I run ndk-build from the samples/bitmap-plasma directory, and the error it displays is that it cannnot locate android/bitmap.h file.
How do i direct the ndk-build script to the file it needs?
Using android-ndk-r4 on Ubuntu Lucid 10.04
Well it's working now, so in case anyone was having my same problem:
There as an android-ndk-r4b bugfix release today, which it seems no longer has this problem.
Available to download here.
http://developer.android.com/sdk/ndk/index.html
With Ubuntu 10.04 and NDK r5b, I have just posted a bug report (with the fix included) for build_platforms.sh. See http://code.google.com/p/android/issues/detail?id=15180 for details. Essentially, the local declarations in the symlink routine must be amended. Otherwise, it only links the first file (alphabetically) from each directory, and truncates the remainder from the list.
Correcting this allowed the symbolic links to be fully populated, thereby filling in the missing header files and libraries and allowing the samples to build successfully.

Categories

Resources