I am obfuscating my Java code and I am using Proguard 5.2.1. However, while using the GUI, there is a warning that came up:
ProGuard, version 5.2.1
Reading program jar [/root/Desktop/ACGPlain.jar]
Reading library jar [/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar]
Warning: connection.HttpURLClient: can't find referenced class javax.crypto.SecretKey
Warning: connection.HttpURLClient: can't find referenced class javax.crypto.SecretKey
Warning: connection.HttpURLClient: can't find referenced class javax.crypto.SecretKey
Warning: connection.HttpURLClient: can't find referenced class javax.crypto.SecretKey
Warning: connection.HttpURLClient: can't find referenced class javax.crypto.SecretKey
Warning: there were 5 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Please correct the above warnings first.
I have tried to run it on the command line with the -dontwarnoptions and the obfuscation did not work. I have tried the following too:
java -jar proguard.jar -injar /root/Desktop/ACGPlain.jar -outjar /root/Desktop/ACGOB.jar -keepclass javax.crypto.SecretKey
Is there a way to stop proguard from hiding the javax.crypto.SecretKey class? I am looking for a GUI solution and not through the configuration file. My java code is not for android and is a program to secure transfers between the server and client.
The crypto related classes are located in a different jar file. You will need to add another -libraryjar configuration to your configuration file:
-libraryjar /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jce.jar
Another option would be to ignore the error, as it is harmless in your case:
-ignorewarnings
or
-dontwarn javax.crypto.**
Related
I would put admob adverts in my app, I did everything correctly but when I try to export the .apk:
Error:Execution failed for task ':app:proguardRelease'.
> java.io.IOException: Please correct the above warnings first.
My "proguard-project" is:
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
# -keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
# AdMob Support
-keep class com.google.ads.**
-dontwarn com.google.ads.**
-dontwarn com.google.android.gms.**
Any help?
Is the first time that i write in this blog, I hope I do not have anything wrong
EDIT:
there are also 2 warnings
:app:proguardRelease
Warning:com.google.android.gms.internal.zzac: can't find referenced class android.net.http.AndroidHttpClient
Warning:com.google.android.gms.internal.zzw: can't find referenced method 'void addHeader(java.lang.String,java.lang.String)' in program class com.google.android.gms.internal.zzw$zza
Warning:com.google.android.gms.internal.zzw$zza: can't find referenced method 'void setURI(java.net.URI)' in program class com.google.android.gms.internal.zzw$zza
Warning:there were 2 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning:there were 2 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
:app:proguardRelease FAILED
Error:Execution failed for task ':app:proguardRelease'.
> java.io.IOException: Please correct the above warnings first.
I want to use ProGuard for my android app, but I have some trouble with it. When I build an unsigned apk via android tools (in eclipse) I got following errors:
Warning: com.millennialmedia.android.NVASpeechKit$7: can't find referenced class com.nuance.nmdp.speechkit.Recognizer
[...] //more warnings of the same type as above
You should check if you need to specify additional program jars.
Warning: there were 170 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)
I'm using 5 jar files within my app, which are all located in the libs-folder and are added to the build-path (So they propably appear in 'Referenced Libraries' as well as 'Android Private Libraries' again). Additionally, I put a so-library in libs/armeabi...
My proguard - file look pretty normal, yet:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontpreverify
-dontskipnonpubliclibraryclasses
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** e(...);
}
What should I do to fix this error?
regards
PS: I know that proguard can delete/change some important things (like class-files,..). So, will I notice such 'errors' by exceptions immediately when starting my app or do I have to check every detail and navigate to any part of my app at runtime to make sure that it runs as it should?
EDIT:
I'm using following jars:
alljoyn.jar (there's also a path varibale in linked resources to the alljoyn-sdk)
peergroupmanager.jar
android-support-v4.jar
MMSDK.jar
GoogleAdMobAdsSdk-6.4.1.jar
From http://docs.millennialmedia.com/android-SDK/AndroidFAQ.html
I am using ProGuard with my Android application, what should I do to ensure my Millennial ads still work?
To make sure you still receive ads while using ProGuard, add the following snippet to your proguard.cfg file.
-keepclassmembers class com.millennialmedia.android.* {
public *;
}
-keep class com.millennialmedia.android.**
When using ProGuard and not SpeechKit, add the following line to their proguard-project.txt:
-dontwarn com.millennialmedia.android.NVASpeechKit*
I'm getting desperate with this Problem: I want to export/run my Android Application with one additional .jar I added to the buildpath. I'm sure I added it correctly, there are 5 other .jars included and they all work fine.
with this special one I get the mentioned error.
I've already tried everything that can be found in this question:
"Conversion to Dalvik format failed with error 1" on external JAR
and several other links google spat out. The main Problem is, I actually do not understand what the message I appended want's to tell me because if I add all the jars to a "normal" javaproject, it runs perfectly fine...
Developing on Android 4.0.3,
proguard 4.8,
adt 16.0.1.v201112150204-238534,
eclipse 3.7.1.r37
please help me
[2012-07-18 10:45:48 - myapp] Dx warning: Ignoring InnerClasses attribute for an anonymous inner
class (iaik.xml.crypto.XSecProvider$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a compiler that did not target the modern .class file format. The
recommended solution is to recompile the class from source, using an
up-to-date compiler and without specifying any "-target" type options.
The consequence of ignoring this warning is that reflective operations
on this class will incorrectly indicate that it is not an inner
class.
...
...
[2012-07-18 10:45:48 - myapp] Dx warning: Ignoring InnerClasses attribute for an anonymous inner
class (iaik.xml.crypto.XSecProvider$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced
by a compiler that did not target the modern .class file format. The
recommended solution is to recompile the class from source, using an
up-to-date compiler and without specifying any "-target" type options.
The consequence of ignoring this warning is that reflective operations
on this class will incorrectly indicate that it is not an inner
class.
Ill-advised or mistaken usage of a core class (java.* or javax.*) when
not building a core library.
This is often due to inadvertently including a core library file in
your application's project, when using an IDE (such as Eclipse). If
you are sure you're not intentionally defining a core class, then this
is the most likely explanation of what's going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example, from a
non-Android virtual machine project. This will most assuredly not
work. At a minimum, it jeopardizes the compatibility of your app with
future versions of the platform. It is also often of questionable
legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine distribution,
as opposed to compiling an application -- then use the
"--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact building an
application, then be forewarned that your application will still fail
to build or run, at some point. Please be prepared for angry customers
who find, for example, that your application ceases to function once
they upgrade their operating system. You will be to blame for this
problem.
If you are legitimately using some code that happens to be in a core
package, then the easiest safe alternative you have is to repackage
that code. That is, move the classes in question into your own package
namespace. This means that they will never be in conflict with core
system classes. JarJar is a tool that may help you in this endeavor.
If you find that you cannot do this, then that is an indication that
the path you are on will ultimately lead to pain, suffering, grief,
and lamentation.
[2012-07-18 10:45:48 - myapp] Dx 1 error; aborting
[2012-07-18 10:45:48 - myapp] Conversion to Dalvik format
failed with error 1
This is how my project looks int he explorer:
The problem is that the jar you are including has a class in the java.* or javax.* namespace. dx does not allow this, as mentioned in the last big error message.
If you actually need these classes, you'll need to move them to a different package, using something like the jarjar tool. Otherwise, you'll need to remove them from the jar -- it may be possible to have proguard to remove them before everything gets dx'd, I'm not sure.
I faced the same problem, I finally resolved it by exporting my private library explicitly.
Like:
Project >> properties >> Java Build Path >> Libraries >> Add External Jars.
Note: Removed my all private libraries from libs folder. I know it is not correct but it worked for me.
Thanks,
Anil
Do as follows :
project
> properties
> java build path
> libraries
> remove all including android jars
Now, go the project browser, right click on the project you are working on, then
android tools
> fix project properties.
Do a clean and then build.
Just restart eclipse, and the error won't occur anymore
If you work on Win7 change this line:
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*
in proguard.bat file to this:
call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
proguard.bat is in:
[Android SDK Installation Directory]\tools\proguard\bin\proguard.bat
Edit:
I hope a combine of these help you:
1-Try to delete libraries projects from your project.
2-Try to export your project(as archive file),delete project and it's source from workspace and then import it again.
3-Try to remove your jars from path,do clean-build and then add them again to your project.
I had the same error when using my own obfuscated lib jar.
my log:
warning:Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribte.This class was probably prouduced by a compiler that did not target the morden .class file format...
And I solved it like this:before I obfuscate my jar,I added "-keepattributes EnclosingMethod" to the proguard.cfg(or proguard-project.txt in latest android adt version).
Agree with hasanghaforian. The easiest solution is to remove libraries project.
Right click your project->Properties->Java Build Path then remove Library Projects
I used proguard to obfuscate my jar file.
During processing I got the following errors:
Initializing...
Warning: tdvep.jmNb: can't find referenced class QSYGWO
Warning: tdvep.qmfsfjttKdvEpNz: can't find referenced class FVTYBN
Warning: tdvep.qsfboBcSw$qsffmtssf: can't find referenced class UGKTLU
Warning: tdvep.qsffmtssf: can't find referenced class DREQUQ
Warning: there were 4 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
Please correct the above warnings first.
So guide me to resolve this warnings.
Have you checked the ProGuard troubleshooting section - Problems while processing.
If there are unresolved references to classes or interfaces, you most likely forgot to specify an essential library. For proper processing, all libraries that are referenced by your code must be specified, including the Java run-time library. For specifying libraries, use the -libraryjars option.
For example, if ProGuard complains that it can't find a javax.crypto class, you probably still have to specify jce.jar, next to the more common rt.jar.
If you're missing a library and you're absolutely sure it isn't used anyway, you can try your luck with the -ignorewarnings option, or even the -dontwarn option. Only use these options if you really know what you're doing though.
For example, if you're developing for Android, and ProGuard complains that it can't find a java.awt class, then some library that you are using is referring to java.awt. This is a bit shady, since Android doesn't have this package at all, but if your application works anyway, you can let ProGuard accept it with "-dontwarn java.awt.**".
My project is not compiling, and giving these errors:
Information:
D:\projects\gre\com\site\core\domain\Employee.class:
warning: Cannot find annotation method
'schema()' in type
'javax.persistence.Table': class file
for javax.persistence.Table not found.
Information: D:\projects\gre\com\site\core\domain\Employee.class:
warning: Cannot find annotation method
'name()' in type
'javax.persistence.Table': class file
for javax.persistence.Table not found.
Information: D:\projects\gre\com\site\core\domain\Employee.class:
warning: Cannot find annotation method
'fetch()' in type
'javax.persistence.ManyToOne': class
file for javax.persistence.ManyToOne
not found.
Information: An Exception has occurred in the
compiler(1.6.0_22).Please file a bug
at the Java Developer
Conncetion(http://java.sun.com/webapps/bugreport)
after checking the Bug Parade for
duplicates. Include your program and
the following diagnostic in your
report. Thank you.
Information: com.sun.tools.javac.code.Symbol$CompilationFailure:class
for javax.persistence.FetchType not
found
Information: Compilation completed with 1 error and 0 warnings
Information: 1 error
Error: compiler internal error. Process terminated with exit code 4
I'm using IntelliJ Idea 9, properly attached hibernate-jpa-2.0-api-1.0.0.Final.jar
I've invalidated the cache, deleted out/war folders but still having an error at the compile time.
I use IntelliJ as well and hibernate-jpa-2.0-api-1.0.0.Final.jar and javax/persistence/Table.class and javax/persistence/ManyToOne.class are definitely in this JAR.
I can only think that the JAR is not in your classpath. Where have you placed this JAR? What are you using to try compile your code? Are you certain it is in your classpath?
Unfortunately I do not have my dev. environment here but as far as I remember hibernate jar does not necessarily contain the JPA stuff, so you have to add the persistence.jar to your classpath.
BTW try to use maven as a build tool and forget about resolving dependencies between third party libraries.