BouncyCastle Error - android

I am developing an android application. In this application I create my own private key by passing pass phrase, user id and keys. When creating the private key, it says "Error: org.bouncycastle.openpgp.PGPException: cannot create cipher: CAST5/CFB/NoPadding"
I have checked the logcat as well as the warning section in the Eclipse but there is error there. SO why I am getting this error and how to solve it.
Any help is greatly appreciated!
I am using bcpg-jdk15on-150.jar and bcprov-jdk15on-150.jar,
which I have downloaded from http://www.bouncycastle.org/latest_releases.html
EDIT
the solution of renaming one or both the jar files does not work. When I run the application it says Unable to execute dex: Multiple dex files define Lorg/bouncycastle/apache/bzip2/BZip2Constants;
and Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/bouncycastle/apache/bzip2/BZip2Constants;
I think there is a problem with the duplication of some files within the two jar files. Can anyone suggest me a solution regarding this?
Thanks

Use latest BouncyCastle and setup security in your code in the following way:
Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME);
Security.insertProviderAt(new BouncyCastleProvider(), 1);
It sets Bouncy Castle library as preferred security provider; Android's default provider config has BC at position 3 so this code will remove it and insert BC again at position 1.
It solved the problem for me.

Related

What is the exact meaning of "Too many field references" in Android?

I can check the classes.dex file through analyze apk in Android studio.
For example.
This dex file defines 9214 clasees with 48592 methods, and references 57284 methods.
If the build fails because of a dex error, I will see the following error message.
Too many field references: 70000; max is 65536.
You may try using --multi-dex option.
What exactly does 70000 mean in this error message?
Number of defined method? or Number of referenced Methods?
If the answer is a number of methods, is it possible to do the following result?
This dex file defines 9214 clasees with 60000 methods, and references 70000 methods.
I've already read sentence below.
The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536
(from Document)
But I don't know exactly what 65536 means.
Please tell me the answer. THX :)
You have to enable multidex for your application.
Refer: https://developer.android.com/studio/build/multidex
Guide: How to enable multidexing with the new Android Multidex support library
What exactly does 70000 mean in this error message?
Ans: Total methods count in your apk(includes methods count from libraries also).

Any library to read mdict *.MDX files in android?

I have a .mdx file that infact is a dictionary database (some android apps like bluedict can read its data).
I have used Daemon.tools but it could not open it.
I was looking for any library or sources which helps me to read MDX dictionary files in Java, I have found some resources already such as KnIfER/mdict-java but it does not work in Android Studio (it has errors on accumulation_blockId_tree.xxing(new myCpr(position,1)).getKey().value line and it is connot resolve symbol 'value'). Does any one knows a good source about these files and possible libraries which could be used for it?.
Well, actually this is my java project.
the error mentioned is just a problem of jdk version. you can add <> parentheses after myCpr and convert return of xxing to type myCpr<Integer,Integer> .
But now, I have very much reduced usage of rbtree and use more binary list searching.have a look there.

Error building openframeworks for android: “ invalid use of incomplete type ‘class Poco::Path’”

I am trying to build an android application with OF. The application runs in two other computers. However, it does not work on mine. I am using a mac.
I run the command "make AndroidDebug" in the project folder, and this is the error I have:
/Library/openFrameworks/addons/ofxHTTP/libs/ofxHTTP/src/PostRouteFileHandler.cpp:98:46: error: invalid use of incomplete type 'class Poco::Path'
ss << Poco::Path(formFileName).getExtension();
I have installed poco, but nothing changes afterwards.
What can I do to solve this?
Thanks
Have you included Poco/Path.h?
A forward declaration might appeared earlier (possibly in another header) without complete definition.

"trouble writing output: Too many field references: 70185; max is 65536. You may try using --multi-dex option." when building Android project

I hit this error and found no hits for the error message, so I thought I'd share the solution I came up with to save anyone else facing the problem repeating my work.
When writing a new Android library (apklib) for use in a (large) application, I'm getting the following error during dexing when I add my new project as a dependency:
trouble writing output: Too many field references: 70185; max is 65536.
You may try using --multi-dex option.
References by package:
<...long list of packages with field counts elided...>
The particular build step it fails on is:
java -jar $ANDROID_SDK/build-tools/19.0.3/lib/dx.jar --dex \
--output=$PROJECT_HOME/target/classes.dex \
<... long list of apklib and jar dependencies elided ...>
Using --multi-dex as recommended by the error message might be a solution, but I'm not the owner of the application project and it already has a large complex build process that I would hesitate to change regardless.
I can reproduce this problem with a no-op test library project that has literally no fields, but in the error output it's listed as having 6000+ fields. Of the packages listed in the error output, there are a handful with similar 6k+ field counts, but then the vast majority have more plausible <1k field counts.
This problem is similar to the "Too many methods" problem that Facebook famously hacked their way around. The FB solution seems insane, and the only other solutions I've found (e.g., this Android bug ticket, or this one, this SO answer, this other SO answer) all involve changing the main app's code which is well beyond the scope of what I want to do.
Is there any other solution?
The solution was to change the package in the AndroidManifest to match the main application's package.
A manifest like this:
<manifest package="com.example.testlibrary" ...
resulted in 6k+ fields and build failure. Changing it to match the main application's package
<manifest package="com.example.mainapplication" ...
resulted in the project building successfully.
Note that only the package in the manifest is changing, I did not make any changes to the library's Java source or its layout (the Java package was still com.example.testlibrary with directory structure to match).
I hypothesize that the different package name is causing all the Android fields to be included again under that package. All the packages in the error listing with 6k+ fields had a different package name than the main application.
I also (later, grr), found this blog post which details the same problem and the eventual same solution.

Android No expanded opcode for R.java

I have an important problem while compiling Android Application.
Using Windev Mobile, it generates java code, compile and create apk, however, when the apk creation, an error happens:
command line: "myjavapath\java.exe" -Xmx1024m -Djava.ext.dirs=.\platform-tools\lib -jar .\platform-tools\lib\dx.jar --dex --output "path\classes.dex" "path\classes" "path\libs"
returned error:
Trouble writing output: No expanded opcode for 0004368d R.java:11#0001: invoke-direct v0:NffffLmynamespace/R$attr;, java.lang.Object.<init>:()v
Furthermore, R$attr in R.java contains nothing:
public static final class attr {
}
I assume there is a hard limit of 64k. But:
The R.java file contains only 364 lines, if these lines are
fields/methods references, I'm very far away from 64k hard limit.
This error happened when I add a specific window, in my Windev Mobile project. Window that I'm using in another project without error.
So, what do you think it comes from?
If you need any information, or document, no problem.
Thanks in advance.
PS: Maybe my english isn't perfect, I sorry for that.
There are various limits in the dex file format. It looks like the one you are encountering is that there can't be more than 64k method references. This limit is for all classes in your dex file, not for just a single class.
The fact that the error is occurring on that class has nothing to do with the class itself, that's just that where it happened to hit the limit.
The only solution currently, is to reduce the size of your code, or to split some classes out into a separate dex file that you load dynamically.

Categories

Resources