[Proguard] java.io.IOException: Can't read [/libs/db4o-version.jar] (No such file or directory)

869 views
Skip to first unread message

Javier Hdez

unread,
Jun 5, 2012, 1:27:38 PM6/5/12
to android...@googlegroups.com
Hola,

A ver si alguien me puede ayudar:

Tengo habilitado Proguard en el proyecto y al momento de exportar cuando está compilando me lanza una excepción por cada dependencia que tiene el proyecto, le añadí esta línea a las reglas del Proguard:

-libraryjars /libs/db4o.jar

 pero aún así me lanza la siguiente excepción: 


[2012-06-05 18:20:01] Proguard returned with error code 1. See console
[2012-06-05 18:20:01] java.io.IOException: Can't read [/libs/db4o.jar] (No such file or directory)
[2012-06-05 18:20:01] at proguard.InputReader.readInput(InputReader.java:230)
[2012-06-05 18:20:01] at proguard.InputReader.readInput(InputReader.java:200)
[2012-06-05 18:20:01] at proguard.InputReader.readInput(InputReader.java:178)
[2012-06-05 18:20:01] at proguard.InputReader.execute(InputReader.java:100)
[2012-06-05 18:20:01] at proguard.ProGuard.readInput(ProGuard.java:196)
[2012-06-05 18:20:01] at proguard.ProGuard.execute(ProGuard.java:78)
[2012-06-05 18:20:01] at proguard.ProGuard.main(ProGuard.java:492)
[2012-06-05 18:20:01] Caused by: java.io.IOException: No such file or directory
[2012-06-05 18:20:01] at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:50)
[2012-06-05 18:20:01] at proguard.InputReader.readInput(InputReader.java:226)
[2012-06-05 18:20:01] ... 6 more


¿No se hace así?

Tengo Proguard 4.8 y Oracle JDK 7 +  ADT 18 + Eclispe 4 + Ubuntu 12.04


Gracias y saludos

Javier Hdez

unread,
Jun 5, 2012, 7:54:46 PM6/5/12
to android...@googlegroups.com
Lo solucioné pero ahora después de compilar cuando instalo la app en el emulador y la inicio se cierra (un ANR):

I/ActivityManager(   78): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=mi.aplicacion/.Main} from pid 183
W/WindowManager(   78): Failure taking screenshot for (90x162) to layer 21005
I/WindowManager(   78): createSurface Window{41165b20 Starting mi.aplicacion paused=false}: DRAW NOW PENDING
I/ActivityManager(   78): Start proc mi.aplicacion for activity mi.aplicacion/.Main: pid=742 uid=10040 gids={3003, 1015}
W/NetworkManagementSocketTagger(   78): setKernelCountSet(10040, 1) failed with errno -2
D/ACRA    (  742): Retrieve application default SharedPreferences.
D/ACRA    (  742): Set OnSharedPreferenceChangeListener.
D/ACRA    (  742): ACRA is enabled for mi.aplicacion, intializing...
D/ACRA    (  742): Looking for error files in /data/data/mi.aplicacion/files
I/MyAppMain(  742): SDK Version: 15
W/NetworkManagementSocketTagger(   78): setKernelCountSet(10005, 0) failed with errno -2
D/dalvikvm(  742): GC_CONCURRENT freed 227K, 10% free 6020K/6663K, paused 4ms+10ms
E/ServerDDBB(  742): Error al iniciar el servidor DDBB java.lang.IllegalArgumentException: Cant find default implementation for interface com.a.l.f: com.a.internal.l.fImpl
D/AndroidRuntime(  742): Shutting down VM
W/dalvikvm(  742): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
E/ACRA    (  742): ACRA caught a RuntimeException exception for mi.aplicacion. Building report.
D/ACRA    (  742): Retrieve application default SharedPreferences.
I/ACRA    (  742): READ_LOGS not allowed. ACRA will not include LogCat and DropBox data.
D/dalvikvm(  742): GC_CONCURRENT freed 317K, 11% free 6177K/6919K, paused 8ms+6ms
D/ACRA    (  742): Writing crash report file.
D/ACRA    (  742): Mark all pending reports as approved.
D/ACRA    (  742): Looking for error files in /data/data/mi.aplicacion/files
V/ACRA    (  742): About to start ReportSenderWorker from #handleException
D/ACRA    (  742): Add user comment to null
D/ACRA    (  742): #checkAndSendReports - start
D/ACRA    (  742): Looking for error files in /data/data/mi.aplicacion/files
I/ACRA    (  742): Sending file 1338940026000-approved.stacktrace
D/ACRA    (  742): #checkAndSendReports - finish

Creo que me pasé ofuscando clases, no sé, parece que el error está al iniciar db4o:

E/ServerDDBB(  742): Error al iniciar el servidor DDBB java.lang.IllegalArgumentException: Cant find default implementation for interface com.a.l.f: com.a.internal.l.fImpl

German Viscuso

unread,
Jun 9, 2012, 8:09:34 AM6/9/12
to android...@googlegroups.com
Pufff! Dime si pruebas con db4o 7 o anterior tambien esta el error?
Estoy tratando de determinar si el error sucede por estar db4o
actualizado o por estar el ADT actualizado. Saludos
German

Javier Hdez

unread,
Jun 9, 2012, 4:47:11 PM6/9/12
to android...@googlegroups.com
Hola German,

db4o-8.0.236.16058-core-java5.jar 

Tenía el SDK Tools rev 18 (ahora estoy instalando el 19.0.0 que veo que ya está disponible en el SDK Manager).

El plugin ADT para Eclipse es el 20 (había desinstalado el 20 preview 3 e instalado el 18 pero en estos días Eclipse detectó una versión nueva (la 20) e instaló esa, no sé si será oficial o es que no desinstalé bien el 20 preview 3).

  Android DDMS 20.0.0.v201206010423-369331 com.android.ide.eclipse.ddms.feature.group The Android Open Source Project
  Android Development Tools 20.0.0.v201206010423-369331 com.android.ide.eclipse.adt.feature.group The Android Open Source Project
  Android Hierarchy Viewer 20.0.0.v201206010423-369331 com.android.ide.eclipse.hierarchyviewer.feature.group The Android Open Source Project
  Android Traceview 20.0.0.v201206010423-369331 com.android.ide.eclipse.traceview.feature.group The Android Open Source Project

El IDE que uso es el Eclipse4 en Ubuntu 12.04 TLS 64bits (cambié para probarlo, pero en cuanto tenga la ocasión me vuelvo a Fedora 17 con Gnome3).

Pero creo que nada de esto tiene que ver con el "error", yo creo que es porque no estoy añadiendo las reglas necesarias para DB4O, con ACRA me pasaba algo parecido y después de añadir esto se solucionó http://code.google.com/p/acra/wiki/ACRAProGuardHowTo y empezó a lanzarme el de DB4O. El asunto es que no sé que clase añadir, añadiré la que me está indicando a ver si por ahí, tampoco he tenido tiempo de hacerlo porque estoy con la UI, pero ya he avanzado bastante voy a ver si hago pruebas con esto de proguard.

Gracias y Saludos!

PD:  Por si acaso, ya que el error del primer hilo es diferente al del segundo,  La excepción se lanza en tiempo de ejecución, no durante la compilación, durante la compilación todo bien, se ofusca todo y se crean los archivos dump.txt - mapping.txt - seeds.txt - usage.txt pero después de instalarlo en el terminal y ejecutar la aplicación es cuando se lanza la excepción.

PD:  Por cierto, esos archivos (dump.txt, mapping.txt, seeds.txt y usage.txt) ¿no tendrían que estar fuera del apk? ¿eso no se distribuye no? ¿o sí?

Javier Hdez

unread,
Jun 9, 2012, 5:10:57 PM6/9/12
to android...@googlegroups.com
Por cierto, 

Supongo que guardar el archivo de las reglas aquí:

proguard.config=/dir/android-sdk-linux/tools/proguard/proguard-android.txt

sea mejor que aquí:

proguard.config=proguard.cfg

¿o no?

Javier Hdez

unread,
Jun 13, 2012, 4:43:28 PM6/13/12
to android...@googlegroups.com
Hola,

No he tenido tiempo de hacer más pruebas en cuanto termine una cosa me pongo con ello.

Estuve buscando por 'db4o proguard' y encontré un issue en el tracker de db4o "Investigate issue with proguard with android" pero parece que se creó y se quedó ahí, ¿existirá otro que tenga alguna solución?

¿No hay en la web de db4o para android algún howto para proguard como en la web de acra?

#ACRA specifics
# we need line numbers in our stack traces otherwise they are pretty useless
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable

# ACRA needs "annotations" so add this...
-keepattributes *Annotation*

# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'.
# Note: if you are removing log messages elsewhere in this file then this isn't necessary
-keep class org.acra.ACRA {
       
*;
}

# keep this around for some enums that ACRA needs
-keep class org.acra.ReportingInteractionMode {
   
*;
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter
{
public void addCustomData(java.lang.String,java.lang.String);
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter
{
public org.acra.ErrorReporter$ReportsSenderWorker handleSilentException(java.lang.Throwable);
}

Saludos

German Viscuso

unread,
Jun 15, 2012, 9:46:27 AM6/15/12
to android...@googlegroups.com
Javier, estoy consultando con el equipo de db4o. Es posible que se
necesite una configuracion para Proguard apra hacerlo funcionar. Te
mantengo al tanto.

German

Javier Hdez

unread,
Jun 15, 2012, 12:12:48 PM6/15/12
to android...@googlegroups.com
Ok, gracias.

Yo estoy haciendo unas pruebas y creo que me resuelve el error que me sale pero aún tengo que hacer algunas pruebas más a ver si es eso o no.

Saludos

Javier Hdez

unread,
Jun 15, 2012, 12:38:17 PM6/15/12
to android...@googlegroups.com
No funciona,

Esta es la configuración:

# 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

# 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 *;
#}


###########################################################################
###########################################################################
# This is a configuration file for ProGuard.

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
#-dontoptimize
-dontpreverify

# If you want to enable optimization, you should include the
# following:
 -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
 -optimizationpasses 7
 -allowaccessmodification
#
# Note that you cannot just include these flags in your own
# configuration file; if you are including this file, optimization
# will be turned off. You'll need to either edit this file, or
# duplicate the contents of this file and remove the include of this
# file from your project's proguard.config path property.

-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgent
-keep public class * extends android.preference.Preference
-keep public class * extends android.support.v4.app.Fragment
-keep public class * extends android.app.Fragment
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
}

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}


-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
-dontwarn android.support.**



####  MIS AÑADIDOS  ####

-dontwarn java.awt.**, javax.security.**,java.beans.**

# Dependencies
-libraryjars /root/workspace/PackageName/libs/acra-4.2.3.jar
-libraryjars /root/workspace/PackageName/libs/db4o-8.0.236.16058-core-java5.jar
-libraryjars /root/workspace/PackageName/libs/db4o-8.0.236.16058-cs-java5.jar


#####  ACRA specifics  #####
# we need line numbers in our stack traces otherwise they are pretty useless
# necesitamos los números de línea de nuestro stack traces de lo contrario, son bastante inútiles
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable


# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'.
# Note: if you are removing log messages elsewhere in this file then this isn't necessary
# Retiene esta clase de manera que el registro se mostrará "ACRA" y no un nombre ofuscado como 'a'. 
# Nota: si va a quitar los mensajes de registro en otras partes de este archivo, entonces esto no es necesario
-keep class org.acra.ACRA {
        *;
}

# keep this around for some enums that ACRA needs
# Retiene esta alrededor de unos enums que necesita ACRA
-keep class org.acra.ReportingInteractionMode {
   *;
}

# keep this otherwise it is removed by ProGuard
# Retiene esto de otra manera es eliminado por ProGuard
-keep public class org.acra.ErrorReporter
{
public void addCustomData(java.lang.String,java.lang.String);
}

# keep this otherwise it is removed by ProGuard
-keep public class org.acra.ErrorReporter
{
public org.acra.ErrorReporter$ReportsSenderWorker handleSilentException(java.lang.Throwable);
}


####  ActionBarSherlock specifics ####
-keep class android.support.v4.** { *; }
-keep interface android.support.v4.** { *; }
-keep class com.actionbarsherlock.internal.** { *; }
-keep interface com.actionbarsherlock.internal.** { *; }


#####  DB4O specifics #####
 -keep class com.packagename.ServerDDBB.** { *; }


Luego después de instalarla en el onCreate lanza esto:

06-15 17:27:55.010: E/ServerDDBB(664):  java.lang.IllegalArgumentException: Cant find default implementation for interface com.a.l.f: com.a.internal.l.fImpl
06-15 17:28:01.700: E/AndroidRuntime(664): FATAL EXCEPTION: main
06-15 17:28:01.700: E/AndroidRuntime(664): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.packagename/com.packagename.Main}: java.lang.NullPointerException
06-15 17:28:01.700: E/AndroidRuntime(664): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
06-15 17:28:01.700: E/AndroidRuntime(664): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-15 17:28:01.700: E/AndroidRuntime(664): at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-15 17:28:01.700: E/AndroidRuntime(664): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-15 17:28:01.700: E/AndroidRuntime(664): at android.os.Handler.dispatchMessage(Handler.java:99)
06-15 17:28:01.700: E/AndroidRuntime(664): at android.os.Looper.loop(Looper.java:137)
06-15 17:28:01.700: E/AndroidRuntime(664): at android.app.ActivityThread.main(ActivityThread.java:4424)
06-15 17:28:01.700: E/AndroidRuntime(664): at java.lang.reflect.Method.invokeNative(Native Method)
06-15 17:28:01.700: E/AndroidRuntime(664): at java.lang.reflect.Method.invoke(Method.java:511)
06-15 17:28:01.700: E/AndroidRuntime(664): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-15 17:28:01.700: E/AndroidRuntime(664): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-15 17:28:01.700: E/AndroidRuntime(664): at dalvik.system.NativeStart.main(Native Method)
06-15 17:28:01.700: E/AndroidRuntime(664): Caused by: java.lang.NullPointerException
06-15 17:28:01.700: E/AndroidRuntime(664): at com.packagename.Main.onCreate(SourceFile:141)
06-15 17:28:01.700: E/AndroidRuntime(664): at android.app.Activity.performCreate(Activity.java:4465)
06-15 17:28:01.700: E/AndroidRuntime(664): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-15 17:28:01.700: E/AndroidRuntime(664): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
06-15 17:28:01.700: E/AndroidRuntime(664): ... 11 more


Javier Hdez

unread,
Jul 7, 2012, 9:58:28 AM7/7/12
to android...@googlegroups.com
Pongo aquí la solución por si encuentra el hilo buscando por la excepción:


Funciona perfectamente.

Gracias!

jlmo...@gmail.com

unread,
Jul 8, 2012, 4:51:16 AM7/8/12
to android...@googlegroups.com
Gracias por volver y poner la solución :D

2012/7/7 Javier Hdez <droi...@gmail.com>

German Viscuso

unread,
Jul 10, 2012, 5:34:16 PM7/10/12
to android...@googlegroups.com
De nada!! :)

2012/7/7 Javier Hdez <droi...@gmail.com>:

Javier Hdez

unread,
Sep 3, 2012, 8:27:57 AM9/3/12
to android...@googlegroups.com
Buenas,

Llevo varios días haciendo pruebas con la exportación de la aplicación y es que una vez exportada, todo funciona excepto una cosa, que no mustra la metadata por pantalla, y creo que tiene que ver con la DDBB.

El asunto es que recupera bien los datos desde el servidor, luego los debería de insertar en la DDBB pero creo que esto no está pasando porque justo después del .commit() (no creo que haya que cerrar el cliente para que se guarden los datos, supongo que con el commit es suficiente) puse un Log.d con la cantidad de mensajes que tiene la DDBB y sale esto por consola:

D/AppNameServiceRemote( 6174): CANTIDAD DE MENSAJES EN LA DDBB 0


¿Alguna idea de que puede ser? Si necesitan algo más lo pongo.

Saludos

PD:Esta es la configuración:

#####  DB4O specifics #####
-keep class com.db4odoc.android.**
-keepnames class com.db4odoc.android.**
-keepclassmembers class com.db4odoc.android.** {
    !static !transient <fields>;
    !private <fields>;
    !private <methods>;
}

Javier Hdez

unread,
Sep 3, 2012, 10:44:29 AM9/3/12
to android...@googlegroups.com
Disculpa German,

Está todo bien, soy yo el problema.

Lo dice bien claro aquí:

The Android SDK includes Proguard to shrink the size of the application by removing unused stuff, shorting names and other optimisations.

db4o relies heavily on reflection, which can lead to major issues when code is processed with Proguard. db4o has not been tested under such a environment. When you're using Proguard you need to test yourself if your application is still working.

You should to exclude all persisted classes from the shrinking process, because db4o manages objects by their name. Therefore db4o will have issue when those name changes by the shrinking process. Read the Proguard documentation for the right configuration. For example when your persisted classes in a certain package you can exclude them like this:


Hice una prueba así:


-keep class es.jsys.ddbb.**{*;}


Y como no funcaba probé a la fuerza bruta:


-keep class es.jsys.** {*;}


Y después de la exportación todo funciona de lujo.


Entonces no solo tengo que mantener las clases del package de la DDBB como los Inserts, Selects, Deletes o Updates sino que además tengo que mantener todas las clases que abran y cierren la ddbb para hacer una consulta o un insert. Resulta que lo hago en varias clases entonces que me recomendarían ¿mover todas las llamadas a Insert, Selects, Deletes y Updates a una clase y mantener esa clase?


Por ejemplo en OperacionesDDBB.java y ponerlo dentro de es.jsys.ddbb y luego solo tener que mantener ese package, así:


-keep class es.jsys.ddbb.** { *; }


Saludos


Javier Hdez

unread,
Sep 3, 2012, 2:38:15 PM9/3/12
to android...@googlegroups.com
Ya está solucionado.

No era por eso, ni hay que mantener ninguna clase que tenga que ver con DB4O (a excepción de lo que está en la doc), lo único que hacía falta era añadir los pojos, si se ofuscan DB4O no los encuentra.

-keep class es.jsys.models.** {*;}


Saludos
Reply all
Reply to author
Forward
0 new messages